* elf32-xtensa.c (property_table_compare): Remove assertion about
[deliverable/binutils-gdb.git] / bfd / elf32-xtensa.c
index 56f317f7fba311d71365041fe6d3c46b3a355c85..f3eba9fe0335711cb4f7c537c7b030307b1d944d 100644 (file)
@@ -37,8 +37,6 @@
 
 #define XTENSA_NO_NOP_REMOVAL 0
 
-extern flagword elf_xtensa_get_private_bfd_flags (bfd *);
-
 /* Local helper functions.  */
 
 static bfd_boolean add_extra_plt_sections (bfd *, int);
@@ -525,12 +523,6 @@ property_table_compare (const void *ap, const void *bp)
 
   if (a->address == b->address)
     {
-      /* The only circumstance where two entries may legitimately have the
-        same address is when one of them is a zero-size placeholder to
-        mark a place where fill can be inserted.  The zero-size entry should
-        come first.  */
-      BFD_ASSERT ((a->size == 0 || b->size == 0));
-
       if (a->size != b->size)
        return (a->size - b->size);
 
@@ -587,7 +579,7 @@ xtensa_read_table_entries (bfd *abfd,
   bfd_size_type table_size = 0;
   bfd_byte *table_data;
   property_table_entry *blocks;
-  int block_count;
+  int blk, block_count;
   bfd_size_type num_records;
   Elf_Internal_Rela *internal_relocs;
   bfd_vma section_addr;
@@ -702,6 +694,25 @@ xtensa_read_table_entries (bfd *abfd,
       /* Now sort them into address order for easy reference.  */
       qsort (blocks, block_count, sizeof (property_table_entry),
             property_table_compare);
+
+      /* Check that the table contents are valid.  Problems may occur,
+         for example, if an unrelocated object file is stripped.  */
+      for (blk = 1; blk < block_count; blk++)
+       {
+         /* The only circumstance where two entries may legitimately
+            have the same address is when one of them is a zero-size
+            placeholder to mark a place where fill can be inserted.
+            The zero-size entry should come first.  */
+         if (blocks[blk - 1].address == blocks[blk].address &&
+             blocks[blk - 1].size != 0)
+           {
+             (*_bfd_error_handler) (_("%B(%A): invalid property table"),
+                                    abfd, section);
+             bfd_set_error (bfd_error_bad_value);
+             free (blocks);
+             return -1;
+           }
+       }
     }
 
   *table_p = blocks;
@@ -2767,13 +2778,6 @@ elf_xtensa_set_private_flags (bfd *abfd, flagword flags)
 }
 
 
-extern flagword
-elf_xtensa_get_private_bfd_flags (bfd *abfd)
-{
-  return elf_elfheader (abfd)->e_flags;
-}
-
-
 static bfd_boolean
 elf_xtensa_print_private_bfd_data (bfd *abfd, void *farg)
 {
@@ -3641,7 +3645,6 @@ narrow_instruction (bfd_byte *contents,
              || xtensa_format_length (isa, o_fmt) != 2)
            return FALSE;
 
-         xtensa_format_encode (isa, o_fmt, o_slotbuf);
          xtensa_format_encode (isa, o_fmt, o_insnbuf);
          operand_count = xtensa_opcode_num_operands (isa, opcode);
          o_operand_count = xtensa_opcode_num_operands (isa, o_opcode);
@@ -3789,7 +3792,6 @@ widen_instruction (bfd_byte *contents,
              || xtensa_format_length (isa, o_fmt) != 3)
            return FALSE;
 
-         xtensa_format_encode (isa, o_fmt, o_slotbuf);
          xtensa_format_encode (isa, o_fmt, o_insnbuf);
          operand_count = xtensa_opcode_num_operands (isa, opcode);
          o_operand_count = xtensa_opcode_num_operands (isa, o_opcode);
@@ -5595,8 +5597,6 @@ insn_block_decodable_len (bfd_byte *contents,
 }
 
 
-static void ebb_add_proposed_action (ebb_constraint *, proposed_action *);
-
 static void
 ebb_propose_action (ebb_constraint *c,
                    bfd_vma alignment_pow,
@@ -5606,25 +5606,15 @@ ebb_propose_action (ebb_constraint *c,
                    int removed_bytes,
                    bfd_boolean do_action)
 {
-  proposed_action paction;
-  paction.align_type = align_type;
-  paction.alignment_pow = alignment_pow;
-  paction.action = action;
-  paction.offset = offset;
-  paction.removed_bytes = removed_bytes;
-  paction.do_action = do_action;
-  ebb_add_proposed_action (c, &paction);
-}
+  proposed_action *act;
 
-
-static void
-ebb_add_proposed_action (ebb_constraint *c, proposed_action *action)
-{
-  unsigned i;
   if (c->action_allocated <= c->action_count)
     {
-      unsigned new_allocated = (c->action_count + 2) * 2;
-      proposed_action *new_actions = (proposed_action *)
+      unsigned new_allocated, i;
+      proposed_action *new_actions;
+
+      new_allocated = (c->action_count + 2) * 2;
+      new_actions = (proposed_action *)
        bfd_zmalloc (sizeof (proposed_action) * new_allocated);
 
       for (i = 0; i < c->action_count; i++)
@@ -5634,7 +5624,15 @@ ebb_add_proposed_action (ebb_constraint *c, proposed_action *action)
       c->actions = new_actions;
       c->action_allocated = new_allocated;
     }
-  c->actions[c->action_count] = *action;
+
+  act = &c->actions[c->action_count];
+  act->align_type = align_type;
+  act->alignment_pow = alignment_pow;
+  act->action = action;
+  act->offset = offset;
+  act->removed_bytes = removed_bytes;
+  act->do_action = do_action;
+
   c->action_count++;
 }
 
This page took 0.02473 seconds and 4 git commands to generate.