Ignore:
Timestamp:
Aug 16, 2003, 6:59:22 PM (22 years ago)
Author:
bird
Message:

binutils v2.14 - offical sources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/binutils/bfd/elf32-arm.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* 32-bit ELF support for ARM
    2    Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
     2   Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
    33
    44   This file is part of BFD, the Binary File Descriptor library.
     
    1818   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
    1919
     20#ifndef USE_REL
     21#define USE_REL 0
     22#endif
     23
    2024typedef unsigned long int insn32;
    2125typedef unsigned short int insn16;
    2226
    23 static boolean elf32_arm_set_private_flags
     27static bfd_boolean elf32_arm_set_private_flags
    2428  PARAMS ((bfd *, flagword));
    25 static boolean elf32_arm_copy_private_bfd_data
     29static bfd_boolean elf32_arm_copy_private_bfd_data
    2630  PARAMS ((bfd *, bfd *));
    27 static boolean elf32_arm_merge_private_bfd_data
     31static bfd_boolean elf32_arm_merge_private_bfd_data
    2832  PARAMS ((bfd *, bfd *));
    29 static boolean elf32_arm_print_private_bfd_data
     33static bfd_boolean elf32_arm_print_private_bfd_data
    3034  PARAMS ((bfd *, PTR));
    3135static int elf32_arm_get_symbol_type
     
    3640  PARAMS ((reloc_howto_type *, bfd *, bfd *, asection *, bfd_byte *,
    3741           Elf_Internal_Rela *, bfd_vma, struct bfd_link_info *, asection *,
    38            const char *, unsigned char, struct elf_link_hash_entry *));
     42           const char *, int, struct elf_link_hash_entry *));
    3943static insn32 insert_thumb_branch
    4044  PARAMS ((insn32, int));
    4145static struct elf_link_hash_entry *find_thumb_glue
    42   PARAMS ((struct bfd_link_info *, CONST char *, bfd *));
     46  PARAMS ((struct bfd_link_info *, const char *, bfd *));
    4347static struct elf_link_hash_entry *find_arm_glue
    44   PARAMS ((struct bfd_link_info *, CONST char *, bfd *));
    45 static void record_arm_to_thumb_glue
    46   PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
    47 static void record_thumb_to_arm_glue
    48   PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
     48  PARAMS ((struct bfd_link_info *, const char *, bfd *));
    4949static void elf32_arm_post_process_headers
    5050  PARAMS ((bfd *, struct bfd_link_info *));
     
    5555  PARAMS ((struct bfd_link_info *, const char *, bfd *, bfd *, asection *,
    5656           bfd_byte *, asection *, bfd_vma, bfd_signed_vma, bfd_vma));
    57 
    58 #define INTERWORK_FLAG(abfd)   (elf_elfheader (abfd)->e_flags & EF_INTERWORK)
     57static bfd_boolean elf32_arm_relocate_section
     58  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
     59           Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
     60static asection * elf32_arm_gc_mark_hook
     61  PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *,
     62           struct elf_link_hash_entry *, Elf_Internal_Sym *));
     63static bfd_boolean elf32_arm_gc_sweep_hook
     64  PARAMS ((bfd *, struct bfd_link_info *, asection *,
     65           const Elf_Internal_Rela *));
     66static bfd_boolean elf32_arm_check_relocs
     67  PARAMS ((bfd *, struct bfd_link_info *, asection *,
     68           const Elf_Internal_Rela *));
     69static bfd_boolean elf32_arm_find_nearest_line
     70  PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **,
     71           const char **, unsigned int *));
     72static bfd_boolean elf32_arm_adjust_dynamic_symbol
     73  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
     74static bfd_boolean elf32_arm_size_dynamic_sections
     75  PARAMS ((bfd *, struct bfd_link_info *));
     76static bfd_boolean elf32_arm_finish_dynamic_symbol
     77  PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
     78           Elf_Internal_Sym *));
     79static bfd_boolean elf32_arm_finish_dynamic_sections
     80  PARAMS ((bfd *, struct bfd_link_info *));
     81static struct bfd_hash_entry * elf32_arm_link_hash_newfunc
     82  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
     83#if USE_REL
     84static void arm_add_to_rel
     85  PARAMS ((bfd *, bfd_byte *, reloc_howto_type *, bfd_signed_vma));
     86#endif
     87static enum elf_reloc_type_class elf32_arm_reloc_type_class
     88  PARAMS ((const Elf_Internal_Rela *));
     89static bfd_boolean elf32_arm_object_p
     90  PARAMS ((bfd *));
     91
     92#ifndef ELFARM_NABI_C_INCLUDED
     93static void record_arm_to_thumb_glue
     94  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
     95static void record_thumb_to_arm_glue
     96  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
     97bfd_boolean bfd_elf32_arm_allocate_interworking_sections
     98  PARAMS ((struct bfd_link_info *));
     99bfd_boolean bfd_elf32_arm_get_bfd_for_interworking
     100  PARAMS ((bfd *, struct bfd_link_info *));
     101bfd_boolean bfd_elf32_arm_process_before_allocation
     102  PARAMS ((bfd *, struct bfd_link_info *, int));
     103#endif
     104
     105
     106#define INTERWORK_FLAG(abfd)   (elf_elfheader (abfd)->e_flags & EF_ARM_INTERWORK)
    59107
    60108/* The linker script knows the section names for placement.
     
    79127   called before the relocation has been set up calls the dynamic
    80128   linker first.  */
    81 static const unsigned long elf32_arm_plt0_entry [PLT_ENTRY_SIZE / 4] =
    82 {
    83   0xe52de004,   /* str   lr, [sp, #-4]!     */
    84   0xe59fe010,   /* ldr   lr, [pc, #16]      */
    85   0xe08fe00e,   /* add   lr, pc, lr         */
    86   0xe5bef008    /* ldr   pc, [lr, #8]!      */
    87 };
     129static const bfd_vma elf32_arm_plt0_entry [PLT_ENTRY_SIZE / 4] =
     130  {
     131    0xe52de004, /* str   lr, [sp, #-4]!     */
     132    0xe59fe010, /* ldr   lr, [pc, #16]      */
     133    0xe08fe00e, /* add   lr, pc, lr         */
     134    0xe5bef008  /* ldr   pc, [lr, #8]!      */
     135  };
    88136
    89137/* Subsequent entries in a procedure linkage table look like
    90138   this.  */
    91 static const unsigned long elf32_arm_plt_entry [PLT_ENTRY_SIZE / 4] =
    92 {
    93   0xe59fc004,   /* ldr   ip, [pc, #4]       */
    94   0xe08fc00c,   /* add   ip, pc, ip         */
    95   0xe59cf000,   /* ldr   pc, [ip]           */
    96   0x00000000    /* offset to symbol in got  */
    97 };
     139static const bfd_vma elf32_arm_plt_entry [PLT_ENTRY_SIZE / 4] =
     140 {
     141   0xe59fc004,  /* ldr   ip, [pc, #4]       */
     142   0xe08fc00c,  /* add   ip, pc, ip         */
     143   0xe59cf000,  /* ldr   pc, [ip]           */
     144   0x00000000   /* offset to symbol in got  */
     145 };
    98146
    99147/* The ARM linker needs to keep track of the number of relocs that it
     
    106154   have copied for a given symbol.  */
    107155struct elf32_arm_pcrel_relocs_copied
    108 {
    109   /* Next section.  */
    110   struct elf32_arm_pcrel_relocs_copied * next;
    111   /* A section in dynobj.  */
    112   asection * section;
    113   /* Number of relocs copied in this section.  */
    114   bfd_size_type count;
    115 };
     156  {
     157    /* Next section.  */
     158    struct elf32_arm_pcrel_relocs_copied * next;
     159    /* A section in dynobj.  */
     160    asection * section;
     161    /* Number of relocs copied in this section.  */
     162    bfd_size_type count;
     163  };
    116164
    117165/* Arm ELF linker hash entry.  */
    118166struct elf32_arm_link_hash_entry
    119 {
    120   struct elf_link_hash_entry root;
    121 
    122   /* Number of PC relative relocs copied for this symbol.  */
    123   struct elf32_arm_pcrel_relocs_copied * pcrel_relocs_copied;
    124 };
     167  {
     168    struct elf_link_hash_entry root;
     169
     170    /* Number of PC relative relocs copied for this symbol.  */
     171    struct elf32_arm_pcrel_relocs_copied * pcrel_relocs_copied;
     172  };
    125173
    126174/* Declare this now that the above structures are defined.  */
    127 static boolean elf32_arm_discard_copies
     175static bfd_boolean elf32_arm_discard_copies
    128176  PARAMS ((struct elf32_arm_link_hash_entry *, PTR));
    129177
     
    132180  (elf_link_hash_traverse                                               \
    133181   (&(table)->root,                                                     \
    134     (boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func),  \
     182    (bfd_boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \
    135183    (info)))
    136184
     
    141189/* ARM ELF linker hash table.  */
    142190struct elf32_arm_link_hash_table
    143 {
    144   /* The main hash table.  */
    145   struct elf_link_hash_table root;
    146 
    147   /* The size in bytes of the section containg the Thumb-to-ARM glue.  */
    148   long int thumb_glue_size;
    149 
    150   /* The size in bytes of the section containg the ARM-to-Thumb glue.  */
    151   long int arm_glue_size;
    152 
    153   /* An arbitary input BFD chosen to hold the glue sections.  */
    154   bfd * bfd_of_glue_owner;
    155 
    156   /* A boolean indicating whether knowledge of the ARM's pipeline
    157      length should be applied by the linker.  */
    158   int no_pipeline_knowledge;
    159 };
     191  {
     192    /* The main hash table.  */
     193    struct elf_link_hash_table root;
     194
     195    /* The size in bytes of the section containg the Thumb-to-ARM glue.  */
     196    bfd_size_type thumb_glue_size;
     197
     198    /* The size in bytes of the section containg the ARM-to-Thumb glue.  */
     199    bfd_size_type arm_glue_size;
     200
     201    /* An arbitary input BFD chosen to hold the glue sections.  */
     202    bfd * bfd_of_glue_owner;
     203
     204    /* A boolean indicating whether knowledge of the ARM's pipeline
     205       length should be applied by the linker.  */
     206    int no_pipeline_knowledge;
     207  };
    160208
    161209/* Create an entry in an ARM ELF linker hash table.  */
     
    196244{
    197245  struct elf32_arm_link_hash_table *ret;
    198 
    199   ret = ((struct elf32_arm_link_hash_table *)
    200          bfd_alloc (abfd, sizeof (struct elf32_arm_link_hash_table)));
     246  bfd_size_type amt = sizeof (struct elf32_arm_link_hash_table);
     247
     248  ret = (struct elf32_arm_link_hash_table *) bfd_malloc (amt);
    201249  if (ret == (struct elf32_arm_link_hash_table *) NULL)
    202250    return NULL;
     
    205253                                      elf32_arm_link_hash_newfunc))
    206254    {
    207       bfd_release (abfd, ret);
     255      free (ret);
    208256      return NULL;
    209257    }
     
    222270find_thumb_glue (link_info, name, input_bfd)
    223271     struct bfd_link_info *link_info;
    224      CONST char *name;
     272     const char *name;
    225273     bfd *input_bfd;
    226274{
     
    232280  hash_table = elf32_arm_hash_table (link_info);
    233281
    234   tmp_name = ((char *)
    235        bfd_malloc (strlen (name) + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1));
     282  tmp_name = (char *) bfd_malloc ((bfd_size_type) strlen (name)
     283                                  + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1);
    236284
    237285  BFD_ASSERT (tmp_name);
     
    240288
    241289  hash = elf_link_hash_lookup
    242     (&(hash_table)->root, tmp_name, false, false, true);
     290    (&(hash_table)->root, tmp_name, FALSE, FALSE, TRUE);
    243291
    244292  if (hash == NULL)
    245293    /* xgettext:c-format */
    246     _bfd_error_handler (_("%s: unable to find THUMB glue '%s' for `%s'"),
    247                         bfd_get_filename (input_bfd), tmp_name, name);
     294    (*_bfd_error_handler) (_("%s: unable to find THUMB glue '%s' for `%s'"),
     295                           bfd_archive_filename (input_bfd), tmp_name, name);
    248296
    249297  free (tmp_name);
     
    257305find_arm_glue (link_info, name, input_bfd)
    258306     struct bfd_link_info *link_info;
    259      CONST char *name;
     307     const char *name;
    260308     bfd *input_bfd;
    261309{
     
    267315  hash_table = elf32_arm_hash_table (link_info);
    268316
    269   tmp_name = ((char *)
    270        bfd_malloc (strlen (name) + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1));
     317  tmp_name = (char *) bfd_malloc ((bfd_size_type) strlen (name)
     318                                  + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1);
    271319
    272320  BFD_ASSERT (tmp_name);
     
    275323
    276324  myh = elf_link_hash_lookup
    277     (&(hash_table)->root, tmp_name, false, false, true);
     325    (&(hash_table)->root, tmp_name, FALSE, FALSE, TRUE);
    278326
    279327  if (myh == NULL)
    280328    /* xgettext:c-format */
    281     _bfd_error_handler (_("%s: unable to find ARM glue '%s' for `%s'"),
    282                         bfd_get_filename (input_bfd), tmp_name, name);
     329    (*_bfd_error_handler) (_("%s: unable to find ARM glue '%s' for `%s'"),
     330                           bfd_archive_filename (input_bfd), tmp_name, name);
    283331
    284332  free (tmp_name);
     
    322370static const insn32 t2a3_b_insn = 0xea000000;
    323371
    324 static const insn16 t2a1_push_insn = 0xb540;
    325 static const insn16 t2a2_ldr_insn = 0x4e03;
    326 static const insn16 t2a3_mov_insn = 0x46fe;
    327 static const insn16 t2a4_bx_insn = 0x4730;
    328 static const insn32 t2a5_pop_insn = 0xe8bd4040;
    329 static const insn32 t2a6_bx_insn = 0xe12fff1e;
    330 
    331 boolean
     372#ifndef ELFARM_NABI_C_INCLUDED
     373bfd_boolean
    332374bfd_elf32_arm_allocate_interworking_sections (info)
    333375     struct bfd_link_info * info;
     
    345387      BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
    346388
    347       s = bfd_get_section_by_name
    348         (globals->bfd_of_glue_owner, ARM2THUMB_GLUE_SECTION_NAME);
     389      s = bfd_get_section_by_name (globals->bfd_of_glue_owner,
     390                                  ARM2THUMB_GLUE_SECTION_NAME);
    349391
    350392      BFD_ASSERT (s != NULL);
    351393
    352       foo = (bfd_byte *) bfd_alloc
    353         (globals->bfd_of_glue_owner, globals->arm_glue_size);
     394      foo = (bfd_byte *) bfd_alloc (globals->bfd_of_glue_owner,
     395                                    globals->arm_glue_size);
    354396
    355397      s->_raw_size = s->_cooked_size = globals->arm_glue_size;
     
    366408      BFD_ASSERT (s != NULL);
    367409
    368       foo = (bfd_byte *) bfd_alloc
    369         (globals->bfd_of_glue_owner, globals->thumb_glue_size);
     410      foo = (bfd_byte *) bfd_alloc (globals->bfd_of_glue_owner,
     411                                    globals->thumb_glue_size);
    370412
    371413      s->_raw_size = s->_cooked_size = globals->thumb_glue_size;
     
    373415    }
    374416
    375   return true;
     417  return TRUE;
    376418}
    377419
     
    382424{
    383425  const char * name = h->root.root.string;
    384   register asection * s;
     426  asection * s;
    385427  char * tmp_name;
    386428  struct elf_link_hash_entry * myh;
     429  struct bfd_link_hash_entry * bh;
    387430  struct elf32_arm_link_hash_table * globals;
     431  bfd_vma val;
    388432
    389433  globals = elf32_arm_hash_table (link_info);
     
    397441  BFD_ASSERT (s != NULL);
    398442
    399   tmp_name = ((char *)
    400        bfd_malloc (strlen (name) + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1));
     443  tmp_name = (char *) bfd_malloc ((bfd_size_type) strlen (name)
     444                                  + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1);
    401445
    402446  BFD_ASSERT (tmp_name);
     
    405449
    406450  myh = elf_link_hash_lookup
    407     (&(globals)->root, tmp_name, false, false, true);
     451    (&(globals)->root, tmp_name, FALSE, FALSE, TRUE);
    408452
    409453  if (myh != NULL)
     
    417461     though the section isn't allocated yet, this is where we will be putting
    418462     it.  */
    419   _bfd_generic_link_add_one_symbol (link_info, globals->bfd_of_glue_owner, tmp_name,
    420                                     BSF_GLOBAL,
    421                                     s, globals->arm_glue_size + 1,
    422                                     NULL, true, false,
    423                                     (struct bfd_link_hash_entry **) &myh);
     463  bh = NULL;
     464  val = globals->arm_glue_size + 1;
     465  _bfd_generic_link_add_one_symbol (link_info, globals->bfd_of_glue_owner,
     466                                    tmp_name, BSF_GLOBAL, s, val,
     467                                    NULL, TRUE, FALSE, &bh);
    424468
    425469  free (tmp_name);
     
    436480{
    437481  const char *name = h->root.root.string;
    438   register asection *s;
     482  asection *s;
    439483  char *tmp_name;
    440484  struct elf_link_hash_entry *myh;
     485  struct bfd_link_hash_entry *bh;
    441486  struct elf32_arm_link_hash_table *hash_table;
    442487  char bind;
     488  bfd_vma val;
    443489
    444490  hash_table = elf32_arm_hash_table (link_info);
     
    452498  BFD_ASSERT (s != NULL);
    453499
    454   tmp_name = (char *) bfd_malloc (strlen (name) + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1);
     500  tmp_name = (char *) bfd_malloc ((bfd_size_type) strlen (name)
     501                                  + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1);
    455502
    456503  BFD_ASSERT (tmp_name);
     
    459506
    460507  myh = elf_link_hash_lookup
    461     (&(hash_table)->root, tmp_name, false, false, true);
     508    (&(hash_table)->root, tmp_name, FALSE, FALSE, TRUE);
    462509
    463510  if (myh != NULL)
     
    468515    }
    469516
    470   _bfd_generic_link_add_one_symbol (link_info, hash_table->bfd_of_glue_owner, tmp_name,
    471                              BSF_GLOBAL, s, hash_table->thumb_glue_size + 1,
    472                                     NULL, true, false,
    473                                     (struct bfd_link_hash_entry **) &myh);
     517  bh = NULL;
     518  val = hash_table->thumb_glue_size + 1;
     519  _bfd_generic_link_add_one_symbol (link_info, hash_table->bfd_of_glue_owner,
     520                                    tmp_name, BSF_GLOBAL, s, val,
     521                                    NULL, TRUE, FALSE, &bh);
    474522
    475523  /* If we mark it 'Thumb', the disassembler will do a better job.  */
     524  myh = (struct elf_link_hash_entry *) bh;
    476525  bind = ELF_ST_BIND (myh->type);
    477526  myh->type = ELF_ST_INFO (bind, STT_ARM_TFUNC);
     
    483532
    484533  /* Allocate another symbol to mark where we switch to Arm mode.  */
    485   tmp_name = (char *) bfd_malloc (strlen (name) + strlen (CHANGE_TO_ARM) + 1);
     534  tmp_name = (char *) bfd_malloc ((bfd_size_type) strlen (name)
     535                                  + strlen (CHANGE_TO_ARM) + 1);
    486536
    487537  BFD_ASSERT (tmp_name);
     
    489539  sprintf (tmp_name, CHANGE_TO_ARM, name);
    490540
    491   myh = NULL;
    492 
    493   _bfd_generic_link_add_one_symbol (link_info, hash_table->bfd_of_glue_owner, tmp_name,
    494                               BSF_LOCAL, s, hash_table->thumb_glue_size + 4,
    495                                     NULL, true, false,
    496                                     (struct bfd_link_hash_entry **) &myh);
     541  bh = NULL;
     542  val = hash_table->thumb_glue_size + 4,
     543  _bfd_generic_link_add_one_symbol (link_info, hash_table->bfd_of_glue_owner,
     544                                    tmp_name, BSF_LOCAL, s, val,
     545                                    NULL, TRUE, FALSE, &bh);
    497546
    498547  free (tmp_name);
     
    501550
    502551  return;
     552}
     553
     554/* Add the glue sections to ABFD.  This function is called from the
     555   linker scripts in ld/emultempl/{armelf}.em.  */
     556
     557bfd_boolean
     558bfd_elf32_arm_add_glue_sections_to_bfd (abfd, info)
     559     bfd *abfd;
     560     struct bfd_link_info *info;
     561{
     562  flagword flags;
     563  asection *sec;
     564
     565  /* If we are only performing a partial
     566     link do not bother adding the glue.  */
     567  if (info->relocateable)
     568    return TRUE;
     569
     570  sec = bfd_get_section_by_name (abfd, ARM2THUMB_GLUE_SECTION_NAME);
     571
     572  if (sec == NULL)
     573    {
     574      /* Note: we do not include the flag SEC_LINKER_CREATED, as this
     575         will prevent elf_link_input_bfd() from processing the contents
     576         of this section.  */
     577      flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_CODE | SEC_READONLY;
     578
     579      sec = bfd_make_section (abfd, ARM2THUMB_GLUE_SECTION_NAME);
     580
     581      if (sec == NULL
     582          || !bfd_set_section_flags (abfd, sec, flags)
     583          || !bfd_set_section_alignment (abfd, sec, 2))
     584        return FALSE;
     585
     586      /* Set the gc mark to prevent the section from being removed by garbage
     587         collection, despite the fact that no relocs refer to this section.  */
     588      sec->gc_mark = 1;
     589    }
     590
     591  sec = bfd_get_section_by_name (abfd, THUMB2ARM_GLUE_SECTION_NAME);
     592
     593  if (sec == NULL)
     594    {
     595      flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_CODE | SEC_READONLY;
     596
     597      sec = bfd_make_section (abfd, THUMB2ARM_GLUE_SECTION_NAME);
     598
     599      if (sec == NULL
     600          || !bfd_set_section_flags (abfd, sec, flags)
     601          || !bfd_set_section_alignment (abfd, sec, 2))
     602        return FALSE;
     603
     604      sec->gc_mark = 1;
     605    }
     606
     607  return TRUE;
    503608}
    504609
     
    507612   {armelf/pe}.em  */
    508613
    509 boolean
     614bfd_boolean
    510615bfd_elf32_arm_get_bfd_for_interworking (abfd, info)
    511616     bfd *abfd;
     
    513618{
    514619  struct elf32_arm_link_hash_table *globals;
    515   flagword flags;
    516   asection *sec;
    517 
    518   /* If we are only performing a partial link do not bother
    519      getting a bfd to hold the glue.  */
     620
     621  /* If we are only performing a partial link
     622     do not bother getting a bfd to hold the glue.  */
    520623  if (info->relocateable)
    521     return true;
     624    return TRUE;
    522625
    523626  globals = elf32_arm_hash_table (info);
     
    526629
    527630  if (globals->bfd_of_glue_owner != NULL)
    528     return true;
    529 
    530   sec = bfd_get_section_by_name (abfd, ARM2THUMB_GLUE_SECTION_NAME);
    531 
    532   if (sec == NULL)
    533     {
    534       /* Note: we do not include the flag SEC_LINKER_CREATED, as this
    535          will prevent elf_link_input_bfd() from processing the contents
    536          of this section.  */
    537       flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_CODE | SEC_READONLY;
    538 
    539       sec = bfd_make_section (abfd, ARM2THUMB_GLUE_SECTION_NAME);
    540 
    541       if (sec == NULL
    542           || !bfd_set_section_flags (abfd, sec, flags)
    543           || !bfd_set_section_alignment (abfd, sec, 2))
    544         return false;
    545 
    546       /* Set the gc mark to prevent the section from being removed by garbage
    547          collection, despite the fact that no relocs refer to this section.  */
    548       sec->gc_mark = 1;
    549     }
    550 
    551   sec = bfd_get_section_by_name (abfd, THUMB2ARM_GLUE_SECTION_NAME);
    552 
    553   if (sec == NULL)
    554     {
    555       flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_CODE | SEC_READONLY;
    556 
    557       sec = bfd_make_section (abfd, THUMB2ARM_GLUE_SECTION_NAME);
    558 
    559       if (sec == NULL
    560           || !bfd_set_section_flags (abfd, sec, flags)
    561           || !bfd_set_section_alignment (abfd, sec, 2))
    562         return false;
    563 
    564       sec->gc_mark = 1;
    565     }
     631    return TRUE;
    566632
    567633  /* Save the bfd for later use.  */
    568634  globals->bfd_of_glue_owner = abfd;
    569635
    570   return true;
     636  return TRUE;
    571637}
    572638
    573 boolean
     639bfd_boolean
    574640bfd_elf32_arm_process_before_allocation (abfd, link_info, no_pipeline_knowledge)
    575641     bfd *abfd;
     
    578644{
    579645  Elf_Internal_Shdr *symtab_hdr;
    580   Elf_Internal_Rela *free_relocs = NULL;
     646  Elf_Internal_Rela *internal_relocs = NULL;
    581647  Elf_Internal_Rela *irel, *irelend;
    582648  bfd_byte *contents = NULL;
    583   bfd_byte *free_contents = NULL;
    584   Elf32_External_Sym *extsyms = NULL;
    585   Elf32_External_Sym *free_extsyms = NULL;
    586649
    587650  asection *sec;
     
    591654     to construct any glue.  */
    592655  if (link_info->relocateable)
    593     return true;
     656    return TRUE;
    594657
    595658  /* Here we have a bfd that is to be included on the link.  We have a hook
     
    606669
    607670  if (sec == NULL)
    608     return true;
     671    return TRUE;
    609672
    610673  for (; sec != NULL; sec = sec->next)
     
    616679
    617680      /* Load the relocs.  */
    618       irel = (_bfd_elf32_link_read_relocs (abfd, sec, (PTR) NULL,
    619                                         (Elf_Internal_Rela *) NULL, false));
    620 
    621       BFD_ASSERT (irel != 0);
    622 
    623       irelend = irel + sec->reloc_count;
    624       for (; irel < irelend; irel++)
     681      internal_relocs
     682        = _bfd_elf32_link_read_relocs (abfd, sec, (PTR) NULL,
     683                                       (Elf_Internal_Rela *) NULL, FALSE);
     684
     685      if (internal_relocs == NULL)
     686        goto error_return;
     687
     688      irelend = internal_relocs + sec->reloc_count;
     689      for (irel = internal_relocs; irel < irelend; irel++)
    625690        {
    626691          long r_type;
     
    650715                    goto error_return;
    651716
    652                   free_contents = contents;
    653 
    654717                  if (!bfd_get_section_contents (abfd, sec, contents,
    655                                               (file_ptr) 0, sec->_raw_size))
    656                     goto error_return;
    657                 }
    658             }
    659 
    660           /* Read this BFD's symbols if we haven't done so already.  */
    661           if (extsyms == NULL)
    662             {
    663               /* Get cached copy if it exists.  */
    664               if (symtab_hdr->contents != NULL)
    665                 extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
    666               else
    667                 {
    668                   /* Go get them off disk.  */
    669                   extsyms = ((Elf32_External_Sym *)
    670                              bfd_malloc (symtab_hdr->sh_size));
    671                   if (extsyms == NULL)
    672                     goto error_return;
    673 
    674                   free_extsyms = extsyms;
    675 
    676                   if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
    677                       || (bfd_read (extsyms, 1, symtab_hdr->sh_size, abfd)
    678                           != symtab_hdr->sh_size))
     718                                                 (file_ptr) 0, sec->_raw_size))
    679719                    goto error_return;
    680720                }
     
    720760            }
    721761        }
    722     }
    723 
    724   return true;
     762
     763      if (contents != NULL
     764          && elf_section_data (sec)->this_hdr.contents != contents)
     765        free (contents);
     766      contents = NULL;
     767
     768      if (internal_relocs != NULL
     769          && elf_section_data (sec)->relocs != internal_relocs)
     770        free (internal_relocs);
     771      internal_relocs = NULL;
     772    }
     773
     774  return TRUE;
    725775
    726776error_return:
    727   if (free_relocs != NULL)
    728     free (free_relocs);
    729   if (free_contents != NULL)
    730     free (free_contents);
    731   if (free_extsyms != NULL)
    732     free (free_extsyms);
    733 
    734   return false;
     777  if (contents != NULL
     778      && elf_section_data (sec)->this_hdr.contents != contents)
     779    free (contents);
     780  if (internal_relocs != NULL
     781      && elf_section_data (sec)->relocs != internal_relocs)
     782    free (internal_relocs);
     783
     784  return FALSE;
    735785}
     786#endif
    736787
    737788/* The thumb form of a long branch is a bit finicky, because the offset
     
    808859{
    809860  asection * s = 0;
    810   long int my_offset;
     861  bfd_vma my_offset;
    811862  unsigned long int tmp;
    812863  long int ret_offset;
     
    816867  myh = find_thumb_glue (info, name, input_bfd);
    817868  if (myh == NULL)
    818     return false;
     869    return FALSE;
    819870
    820871  globals = elf32_arm_hash_table (info);
     
    838889          && !INTERWORK_FLAG (sym_sec->owner))
    839890        {
    840           _bfd_error_handler
     891          (*_bfd_error_handler)
    841892            (_("%s(%s): warning: interworking not enabled."),
    842              bfd_get_filename (sym_sec->owner), name);
    843           _bfd_error_handler
     893             bfd_archive_filename (sym_sec->owner), name);
     894          (*_bfd_error_handler)
    844895            (_("  first occurrence: %s: thumb call to arm"),
    845              bfd_get_filename (input_bfd));
    846 
    847           return false;
     896             bfd_archive_filename (input_bfd));
     897
     898          return FALSE;
    848899        }
    849900
     
    851902      myh->root.u.def.value = my_offset;
    852903
    853       bfd_put_16 (output_bfd, t2a1_bx_pc_insn,
     904      bfd_put_16 (output_bfd, (bfd_vma) t2a1_bx_pc_insn,
    854905                  s->contents + my_offset);
    855906
    856       bfd_put_16 (output_bfd, t2a2_noop_insn,
     907      bfd_put_16 (output_bfd, (bfd_vma) t2a2_noop_insn,
    857908                  s->contents + my_offset + 2);
    858909
     
    873924
    874925      bfd_put_32 (output_bfd,
    875                   t2a3_b_insn | ((ret_offset >> 2) & 0x00FFFFFF),
     926                  (bfd_vma) t2a3_b_insn | ((ret_offset >> 2) & 0x00FFFFFF),
    876927                  s->contents + my_offset + 4);
    877928    }
     
    879930  BFD_ASSERT (my_offset <= globals->thumb_glue_size);
    880931
    881   /* Now go back and fix up the original BL insn to point
    882      to here.  */
     932  /* Now go back and fix up the original BL insn to point to here.  */
    883933  ret_offset =
    884     s->output_offset
    885     + my_offset
    886     - (input_section->output_offset
    887        + offset + addend)
     934    /* Address of where the stub is located.  */
     935    (s->output_section->vma + s->output_offset + my_offset)
     936     /* Address of where the BL is located.  */
     937    - (input_section->output_section->vma + input_section->output_offset + offset)
     938    /* Addend in the relocation.  */
     939    - addend
     940    /* Biassing for PC-relative addressing.  */
    888941    - 8;
    889942
     
    892945
    893946  bfd_put_32 (output_bfd,
    894               insert_thumb_branch (tmp, ret_offset),
     947              (bfd_vma) insert_thumb_branch (tmp, ret_offset),
    895948              hit_data - input_section->vma);
    896949
    897   return true;
     950  return TRUE;
    898951}
    899952
     
    915968{
    916969  unsigned long int tmp;
    917   long int my_offset;
     970  bfd_vma my_offset;
    918971  asection * s;
    919972  long int ret_offset;
     
    923976  myh = find_arm_glue (info, name, input_bfd);
    924977  if (myh == NULL)
    925     return false;
     978    return FALSE;
    926979
    927980  globals = elf32_arm_hash_table (info);
     
    943996          && !INTERWORK_FLAG (sym_sec->owner))
    944997        {
    945           _bfd_error_handler
     998          (*_bfd_error_handler)
    946999            (_("%s(%s): warning: interworking not enabled."),
    947              bfd_get_filename (sym_sec->owner), name);
    948           _bfd_error_handler
     1000             bfd_archive_filename (sym_sec->owner), name);
     1001          (*_bfd_error_handler)
    9491002            (_("  first occurrence: %s: arm call to thumb"),
    950              bfd_get_filename (input_bfd));
     1003             bfd_archive_filename (input_bfd));
    9511004        }
    9521005
     
    9541007      myh->root.u.def.value = my_offset;
    9551008
    956       bfd_put_32 (output_bfd, a2t1_ldr_insn,
     1009      bfd_put_32 (output_bfd, (bfd_vma) a2t1_ldr_insn,
    9571010                  s->contents + my_offset);
    9581011
    959       bfd_put_32 (output_bfd, a2t2_bx_r12_insn,
     1012      bfd_put_32 (output_bfd, (bfd_vma) a2t2_bx_r12_insn,
    9601013                  s->contents + my_offset + 4);
    9611014
     
    9711024
    9721025  /* Somehow these are both 4 too far, so subtract 8.  */
    973   ret_offset = s->output_offset
    974     + my_offset
    975     + s->output_section->vma
    976     - (input_section->output_offset
    977        + input_section->output_section->vma
    978        + offset + addend)
    979     - 8;
     1026  ret_offset = (s->output_offset
     1027                + my_offset
     1028                + s->output_section->vma
     1029                - (input_section->output_offset
     1030                   + input_section->output_section->vma
     1031                   + offset + addend)
     1032                - 8);
    9801033
    9811034  tmp = tmp | ((ret_offset >> 2) & 0x00FFFFFF);
    9821035
    983   bfd_put_32 (output_bfd, tmp, hit_data
    984               - input_section->vma);
    985 
    986   return true;
     1036  bfd_put_32 (output_bfd, (bfd_vma) tmp, hit_data - input_section->vma);
     1037
     1038  return TRUE;
    9871039}
    9881040
     
    10031055     asection *             sym_sec;
    10041056     const char *           sym_name;
    1005      unsigned char          sym_flags;
     1057     int                    sym_flags;
    10061058     struct elf_link_hash_entry * h;
    10071059{
     
    10231075     flag.  Setting this more than once is redundant, but the cost is
    10241076     not too high, and it keeps the code simple.
    1025      
     1077
    10261078     The test is done  here, rather than somewhere else, because the
    10271079     start address is only set just before the final link commences.
     
    10311083  if (bfd_get_start_address (output_bfd) != 0)
    10321084    elf_elfheader (output_bfd)->e_flags |= EF_ARM_HASENTRY;
    1033      
     1085
    10341086  globals = elf32_arm_hash_table (info);
    10351087
     
    10451097  r_symndx = ELF32_R_SYM (rel->r_info);
    10461098
    1047 #ifdef USE_REL
     1099#if USE_REL
    10481100  addend = bfd_get_32 (input_bfd, hit_data) & howto->src_mask;
    10491101
     
    10741126         into the output file to be resolved at run time.  */
    10751127      if (info->shared
     1128          && r_symndx != 0
    10761129          && (r_type != R_ARM_PC24
    1077               || (h != NULL
     1130              || (h != NULL
    10781131                  && h->dynindx != -1
    10791132                  && (! info->symbolic
     
    10811134                          & ELF_LINK_HASH_DEF_REGULAR) == 0))))
    10821135        {
    1083           Elf_Internal_Rel outrel;
    1084           boolean skip, relocate;
     1136          Elf_Internal_Rela outrel;
     1137          bfd_byte *loc;
     1138          bfd_boolean skip, relocate;
    10851139
    10861140          if (sreloc == NULL)
     
    11041158            }
    11051159
    1106           skip = false;
    1107 
    1108           if (elf_section_data (input_section)->stab_info == NULL)
    1109             outrel.r_offset = rel->r_offset;
    1110           else
    1111             {
    1112               bfd_vma off;
    1113 
    1114               off = (_bfd_stab_section_offset
    1115                      (output_bfd, &elf_hash_table (info)->stab_info,
    1116                       input_section,
    1117                       & elf_section_data (input_section)->stab_info,
    1118                       rel->r_offset));
    1119               if (off == (bfd_vma) -1)
    1120                 skip = true;
    1121               outrel.r_offset = off;
    1122             }
    1123 
     1160          skip = FALSE;
     1161          relocate = FALSE;
     1162
     1163          outrel.r_offset =
     1164            _bfd_elf_section_offset (output_bfd, info, input_section,
     1165                                     rel->r_offset);
     1166          if (outrel.r_offset == (bfd_vma) -1)
     1167            skip = TRUE;
     1168          else if (outrel.r_offset == (bfd_vma) -2)
     1169            skip = TRUE, relocate = TRUE;
    11241170          outrel.r_offset += (input_section->output_section->vma
    11251171                              + input_section->output_offset);
    11261172
    11271173          if (skip)
    1128             {
    1129               memset (&outrel, 0, sizeof outrel);
    1130               relocate = false;
    1131             }
     1174            memset (&outrel, 0, sizeof outrel);
    11321175          else if (r_type == R_ARM_PC24)
    11331176            {
    11341177              BFD_ASSERT (h != NULL && h->dynindx != -1);
    1135               if ((input_section->flags & SEC_ALLOC) != 0)
    1136                 relocate = false;
    1137               else
    1138                 relocate = true;
     1178              if ((input_section->flags & SEC_ALLOC) == 0)
     1179                relocate = TRUE;
    11391180              outrel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_PC24);
    11401181            }
     
    11461187                          & ELF_LINK_HASH_DEF_REGULAR) != 0))
    11471188                {
    1148                   relocate = true;
     1189                  relocate = TRUE;
    11491190                  outrel.r_info = ELF32_R_INFO (0, R_ARM_RELATIVE);
    11501191                }
     
    11521193                {
    11531194                  BFD_ASSERT (h->dynindx != -1);
    1154                   if ((input_section->flags & SEC_ALLOC) != 0)
    1155                     relocate = false;
    1156                   else
    1157                     relocate = true;
     1195                  if ((input_section->flags & SEC_ALLOC) == 0)
     1196                    relocate = TRUE;
    11581197                  outrel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_ABS32);
    11591198                }
    11601199            }
    11611200
    1162           bfd_elf32_swap_reloc_out (output_bfd, &outrel,
    1163                                     (((Elf32_External_Rel *)
    1164                                       sreloc->contents)
    1165                                      + sreloc->reloc_count));
    1166           ++sreloc->reloc_count;
     1201          loc = sreloc->contents;
     1202          loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rel);
     1203          bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
    11671204
    11681205          /* If this reloc is against an external symbol, we do not want to
     
    11891226                 instruction instead ?  */
    11901227              if (sym_flags != STT_ARM_TFUNC)
    1191                 _bfd_error_handler (_("\
     1228                (*_bfd_error_handler) (_("\
    11921229%s: Warning: Arm BLX instruction targets Arm function '%s'."),
    1193                                     bfd_get_filename (input_bfd),
    1194                                     h ? h->root.root.string : "(local)");
     1230                                       bfd_archive_filename (input_bfd),
     1231                                       h ? h->root.root.string : "(local)");
    11951232            }
    11961233          else
     
    12961333        case R_ARM_REL32:
    12971334          value -= (input_section->output_section->vma
    1298                     + input_section->output_offset);
     1335                    + input_section->output_offset + rel->r_offset);
    12991336          value += addend;
    13001337          break;
     
    13351372    case R_ARM_THM_ABS5:
    13361373      /* Support ldr and str instructions for the thumb.  */
    1337 #ifdef USE_REL
     1374#if USE_REL
    13381375      /* Need to refetch addend.  */
    13391376      addend = bfd_get_16 (input_bfd, hit_data) & howto->src_mask;
     
    13581395      /* Thumb BL (branch long instruction).  */
    13591396      {
    1360         bfd_vma        relocation;
    1361         boolean        overflow = false;
    1362         bfd_vma        upper_insn = bfd_get_16 (input_bfd, hit_data);
    1363         bfd_vma        lower_insn = bfd_get_16 (input_bfd, hit_data + 2);
    1364         bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1;
     1397        bfd_vma relocation;
     1398        bfd_boolean overflow = FALSE;
     1399        bfd_vma upper_insn = bfd_get_16 (input_bfd, hit_data);
     1400        bfd_vma lower_insn = bfd_get_16 (input_bfd, hit_data + 2);
     1401        bfd_signed_vma reloc_signed_max = ((1 << (howto->bitsize - 1)) - 1) >> howto->rightshift;
    13651402        bfd_signed_vma reloc_signed_min = ~ reloc_signed_max;
    1366         bfd_vma        check;
     1403        bfd_vma check;
    13671404        bfd_signed_vma signed_check;
    13681405
    1369 #ifdef USE_REL
     1406#if USE_REL
    13701407        /* Need to refetch the addend and squish the two 11 bit pieces
    13711408           together.  */
     
    13851422               instruction instead ?  */
    13861423            if (sym_flags == STT_ARM_TFUNC)
    1387               _bfd_error_handler (_("\
     1424              (*_bfd_error_handler) (_("\
    13881425%s: Warning: Thumb BLX instruction targets thumb function '%s'."),
    1389                                   bfd_get_filename (input_bfd),
    1390                                   h ? h->root.root.string : "(local)");
     1426                                     bfd_archive_filename (input_bfd),
     1427                                     h ? h->root.root.string : "(local)");
    13911428          }
    13921429        else
     
    14411478        /* Assumes two's complement.  */
    14421479        if (signed_check > reloc_signed_max || signed_check < reloc_signed_min)
    1443           overflow = true;
    1444 
     1480          overflow = TRUE;
     1481
     1482#ifndef OLD_ARM_ABI
     1483        if (r_type == R_ARM_THM_XPC22
     1484            && ((lower_insn & 0x1800) == 0x0800))
     1485          /* For a BLX instruction, make sure that the relocation is rounded up
     1486             to a word boundary.  This follows the semantics of the instruction
     1487             which specifies that bit 1 of the target address will come from bit
     1488             1 of the base address.  */
     1489          relocation = (relocation + 2) & ~ 3;
     1490#endif
    14451491        /* Put RELOCATION back into the insn.  */
    14461492        upper_insn = (upper_insn & ~(bfd_vma) 0x7ff) | ((relocation >> 12) & 0x7ff);
    14471493        lower_insn = (lower_insn & ~(bfd_vma) 0x7ff) | ((relocation >> 1) & 0x7ff);
    14481494
    1449 #ifndef OLD_ARM_ABI
    1450         if (r_type == R_ARM_THM_XPC22
    1451             && ((lower_insn & 0x1800) == 0x0800))
    1452           /* Remove bit zero of the adjusted offset.  Bit zero can only be
    1453              set if the upper insn is at a half-word boundary, since the
    1454              destination address, an ARM instruction, must always be on a
    1455              word boundary.  The semantics of the BLX (1) instruction, however,
    1456              are that bit zero in the offset must always be zero, and the
    1457              corresponding bit one in the target address will be set from bit
    1458              one of the source address.  */
    1459           lower_insn &= ~1;
    1460 #endif 
    14611495        /* Put the relocated value back in the object file:  */
    14621496        bfd_put_16 (input_bfd, upper_insn, hit_data);
     
    14671501      break;
    14681502
     1503    case R_ARM_THM_PC11:
     1504      /* Thumb B (branch) instruction).  */
     1505      {
     1506        bfd_signed_vma relocation;
     1507        bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1;
     1508        bfd_signed_vma reloc_signed_min = ~ reloc_signed_max;
     1509        bfd_signed_vma signed_check;
     1510
     1511#if USE_REL
     1512        /* Need to refetch addend.  */
     1513        addend = bfd_get_16 (input_bfd, hit_data) & howto->src_mask;
     1514        if (addend & ((howto->src_mask + 1) >> 1))
     1515          {
     1516            signed_addend = -1;
     1517            signed_addend &= ~ howto->src_mask;
     1518            signed_addend |= addend;
     1519          }
     1520        else
     1521          signed_addend = addend;
     1522        /* The value in the insn has been right shifted.  We need to
     1523           undo this, so that we can perform the address calculation
     1524           in terms of bytes.  */
     1525        signed_addend <<= howto->rightshift;
     1526#endif
     1527        relocation = value + signed_addend;
     1528
     1529        relocation -= (input_section->output_section->vma
     1530                       + input_section->output_offset
     1531                       + rel->r_offset);
     1532
     1533        relocation >>= howto->rightshift;
     1534        signed_check = relocation;
     1535        relocation &= howto->dst_mask;
     1536        relocation |= (bfd_get_16 (input_bfd, hit_data) & (~ howto->dst_mask));
     1537
     1538        bfd_put_16 (input_bfd, relocation, hit_data);
     1539
     1540        /* Assumes two's complement.  */
     1541        if (signed_check > reloc_signed_max || signed_check < reloc_signed_min)
     1542          return bfd_reloc_overflow;
     1543
     1544        return bfd_reloc_ok;
     1545      }
     1546
    14691547    case R_ARM_GNU_VTINHERIT:
    14701548    case R_ARM_GNU_VTENTRY:
     
    14901568      if (sgot == NULL)
    14911569        return bfd_reloc_notsupported;
     1570
     1571      /* If we are addressing a Thumb function, we need to adjust the
     1572         address by one, so that attempts to call the function pointer will
     1573         correctly interpret it as Thumb code.  */
     1574      if (sym_flags == STT_ARM_TFUNC)
     1575        value += 1;
    14921576
    14931577      /* Note that sgot->output_offset is not involved in this
     
    14981582      value -= sgot->output_section->vma;
    14991583      return _bfd_final_link_relocate (howto, input_bfd, input_section,
    1500                                        contents, rel->r_offset, value,
    1501                                        (bfd_vma) 0);
     1584                                       contents, rel->r_offset, value,
     1585                                       (bfd_vma) 0);
    15021586
    15031587    case R_ARM_GOTPC:
     
    15101594      value = sgot->output_section->vma;
    15111595      return _bfd_final_link_relocate (howto, input_bfd, input_section,
    1512                                        contents, rel->r_offset, value,
    1513                                        (bfd_vma) 0);
     1596                                       contents, rel->r_offset, value,
     1597                                       (bfd_vma) 0);
    15141598
    15151599    case R_ARM_GOT32:
     
    15431627              else
    15441628                {
     1629                  /* If we are addressing a Thumb function, we need to
     1630                     adjust the address by one, so that attempts to
     1631                     call the function pointer will correctly
     1632                     interpret it as Thumb code.  */
     1633                  if (sym_flags == STT_ARM_TFUNC)
     1634                    value |= 1;
     1635
    15451636                  bfd_put_32 (output_bfd, value, sgot->contents + off);
    15461637                  h->got.offset |= 1;
     
    15711662                {
    15721663                  asection * srelgot;
    1573                   Elf_Internal_Rel outrel;
     1664                  Elf_Internal_Rela outrel;
     1665                  bfd_byte *loc;
    15741666
    15751667                  srelgot = bfd_get_section_by_name (dynobj, ".rel.got");
     
    15801672                                     + off);
    15811673                  outrel.r_info = ELF32_R_INFO (0, R_ARM_RELATIVE);
    1582                   bfd_elf32_swap_reloc_out (output_bfd, &outrel,
    1583                                             (((Elf32_External_Rel *)
    1584                                               srelgot->contents)
    1585                                              + srelgot->reloc_count));
    1586                   ++srelgot->reloc_count;
     1674                  loc = srelgot->contents;
     1675                  loc += srelgot->reloc_count++ * sizeof (Elf32_External_Rel);
     1676                  bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
    15871677                }
    15881678
     
    15941684
    15951685      return _bfd_final_link_relocate (howto, input_bfd, input_section,
    1596                                        contents, rel->r_offset, value,
    1597                                        (bfd_vma) 0);
     1686                                       contents, rel->r_offset, value,
     1687                                       (bfd_vma) 0);
    15981688
    15991689    case R_ARM_PLT32:
     
    16051695      if (h == NULL)
    16061696        return _bfd_final_link_relocate (howto, input_bfd, input_section,
    1607                                          contents, rel->r_offset, value,
    1608                                          (bfd_vma) 0);
     1697                                 contents, rel->r_offset, value,
     1698                                 (bfd_vma) 0);
    16091699
    16101700      if (h->plt.offset == (bfd_vma) -1)
     
    16241714               + h->plt.offset);
    16251715      return _bfd_final_link_relocate (howto, input_bfd, input_section,
    1626                                        contents, rel->r_offset, value,
    1627                                        (bfd_vma) 0);
     1716                               contents, rel->r_offset, value,
     1717                               (bfd_vma) 0);
    16281718
    16291719    case R_ARM_SBREL32:
     
    16561746}
    16571747
    1658 #ifdef USE_REL
     1748#if USE_REL
    16591749/* Add INCREMENT to the reloc (of type HOWTO) at ADDRESS.  */
    16601750static void
     
    16841774      lower_insn = (lower_insn & 0xf800) | (addend & 0x7ff);
    16851775
    1686       bfd_put_16 (abfd, upper_insn, address);
    1687       bfd_put_16 (abfd, lower_insn, address + 2);
     1776      bfd_put_16 (abfd, (bfd_vma) upper_insn, address);
     1777      bfd_put_16 (abfd, (bfd_vma) lower_insn, address + 2);
    16881778    }
    16891779  else
     
    17131803        case R_ARM_PC24:
    17141804          addend <<= howto->size;
    1715           addend +=  increment;
     1805          addend += increment;
    17161806
    17171807          /* Should we check for overflow here ?  */
     
    17301820
    17311821/* Relocate an ARM ELF section.  */
    1732 static boolean
     1822static bfd_boolean
    17331823elf32_arm_relocate_section (output_bfd, info, input_bfd, input_section,
    17341824                            contents, relocs, local_syms, local_sections)
    1735      bfd *                  output_bfd;
    1736      struct bfd_link_info * info;
    1737      bfd *                  input_bfd;
    1738      asection *             input_section;
    1739      bfd_byte *             contents;
    1740      Elf_Internal_Rela *    relocs;
    1741      Elf_Internal_Sym *     local_syms;
    1742      asection **            local_sections;
     1825     bfd *output_bfd;
     1826     struct bfd_link_info *info;
     1827     bfd *input_bfd;
     1828     asection *input_section;
     1829     bfd_byte *contents;
     1830     Elf_Internal_Rela *relocs;
     1831     Elf_Internal_Sym *local_syms;
     1832     asection **local_sections;
    17431833{
    1744   Elf_Internal_Shdr *           symtab_hdr;
    1745   struct elf_link_hash_entry ** sym_hashes;
    1746   Elf_Internal_Rela *           rel;
    1747   Elf_Internal_Rela *           relend;
    1748   const char *                  name;
     1834  Elf_Internal_Shdr *symtab_hdr;
     1835  struct elf_link_hash_entry **sym_hashes;
     1836  Elf_Internal_Rela *rel;
     1837  Elf_Internal_Rela *relend;
     1838  const char *name;
     1839
     1840#if !USE_REL
     1841  if (info->relocateable)
     1842    return TRUE;
     1843#endif
    17491844
    17501845  symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
     
    17751870      howto = bfd_reloc.howto;
    17761871
     1872#if USE_REL
    17771873      if (info->relocateable)
    17781874        {
     
    17871883                {
    17881884                  sec = local_sections[r_symndx];
    1789 #ifdef USE_REL
    17901885                  arm_add_to_rel (input_bfd, contents + rel->r_offset,
    1791                                   howto, sec->output_offset + sym->st_value);
    1792 #else
    1793                   rel->r_addend += (sec->output_offset + sym->st_value)
    1794                     >> howto->rightshift;
    1795 #endif
     1886                                  howto,
     1887                                  (bfd_signed_vma) (sec->output_offset
     1888                                                    + sym->st_value));
    17961889                }
    17971890            }
     
    17991892          continue;
    18001893        }
     1894#endif
    18011895
    18021896      /* This is a final link.  */
     
    18091903          sym = local_syms + r_symndx;
    18101904          sec = local_sections[r_symndx];
     1905#if USE_REL
    18111906          relocation = (sec->output_section->vma
    18121907                        + sec->output_offset
    18131908                        + sym->st_value);
     1909          if ((sec->flags & SEC_MERGE)
     1910                   && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
     1911            {
     1912              asection *msec;
     1913              bfd_vma addend, value;
     1914
     1915              if (howto->rightshift)
     1916                {
     1917                  (*_bfd_error_handler)
     1918                    (_("%s(%s+0x%lx): %s relocation against SEC_MERGE section"),
     1919                     bfd_archive_filename (input_bfd),
     1920                     bfd_get_section_name (input_bfd, input_section),
     1921                     (long) rel->r_offset, howto->name);
     1922                  return FALSE;
     1923                }
     1924
     1925              value = bfd_get_32 (input_bfd, contents + rel->r_offset);
     1926
     1927              /* Get the (signed) value from the instruction.  */
     1928              addend = value & howto->src_mask;
     1929              if (addend & ((howto->src_mask + 1) >> 1))
     1930                {
     1931                  bfd_signed_vma mask;
     1932
     1933                  mask = -1;
     1934                  mask &= ~ howto->src_mask;
     1935                  addend |= mask;
     1936                }
     1937              msec = sec;
     1938              addend =
     1939                _bfd_elf_rel_local_sym (output_bfd, sym, &msec, addend)
     1940                - relocation;
     1941              addend += msec->output_section->vma + msec->output_offset;
     1942              value = (value & ~ howto->dst_mask) | (addend & howto->dst_mask);
     1943              bfd_put_32 (input_bfd, value, contents + rel->r_offset);
     1944            }
     1945#else
     1946          relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
     1947#endif
    18141948        }
    18151949      else
     
    18351969                case R_ARM_PC24:
    18361970                case R_ARM_ABS32:
     1971                case R_ARM_THM_PC22:
    18371972                  if (info->shared
    18381973                      && (
    1839                           (!info->symbolic && h->dynindx != -1)
     1974                  (!info->symbolic && h->dynindx != -1)
    18401975                          || (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
    18411976                          )
     
    18752010                    {
    18762011                      (*_bfd_error_handler)
    1877                         (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
    1878                          bfd_get_filename (input_bfd), h->root.root.string,
     2012                        (_("%s: warning: unresolvable relocation %d against symbol `%s' from %s section"),
     2013                         bfd_archive_filename (input_bfd),
     2014                         r_type,
     2015                         h->root.root.string,
    18792016                         bfd_get_section_name (input_bfd, input_section));
    18802017                      relocation_needed = 0;
     
    19022039                     (!info->shared || info->no_undefined
    19032040                      || ELF_ST_VISIBILITY (h->other)))))
    1904                 return false;
     2041                return FALSE;
    19052042              relocation = 0;
    19062043            }
     
    19382075                        (info, name, howto->name, (bfd_vma) 0,
    19392076                         input_bfd, input_section, rel->r_offset))))
    1940                   return false;
     2077                  return FALSE;
    19412078              break;
    19422079
     
    19442081              if (!((*info->callbacks->undefined_symbol)
    19452082                    (info, name, input_bfd, input_section,
    1946                      rel->r_offset, true)))
    1947                 return false;
     2083                     rel->r_offset, TRUE)))
     2084                return FALSE;
    19482085              break;
    19492086
     
    19682105                    (info, msg, name, input_bfd, input_section,
    19692106                     rel->r_offset)))
    1970                 return false;
     2107                return FALSE;
    19712108              break;
    19722109            }
     
    19742111    }
    19752112
    1976   return true;
     2113  return TRUE;
    19772114}
    19782115
     2116/* Set the right machine number.  */
     2117
     2118static bfd_boolean
     2119elf32_arm_object_p (abfd)
     2120     bfd *abfd;
     2121{
     2122  unsigned int mach;
     2123 
     2124  mach = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
     2125
     2126  if (mach != bfd_mach_arm_unknown)
     2127    bfd_default_set_arch_mach (abfd, bfd_arch_arm, mach);
     2128
     2129  else if (elf_elfheader (abfd)->e_flags & EF_ARM_MAVERICK_FLOAT)
     2130    bfd_default_set_arch_mach (abfd, bfd_arch_arm, bfd_mach_arm_ep9312);
     2131
     2132  else
     2133    bfd_default_set_arch_mach (abfd, bfd_arch_arm, mach);
     2134
     2135  return TRUE;
     2136}
     2137
    19792138/* Function to keep ARM specific flags in the ELF header.  */
    1980 static boolean
     2139static bfd_boolean
    19812140elf32_arm_set_private_flags (abfd, flags)
    19822141     bfd *abfd;
     
    19882147      if (EF_ARM_EABI_VERSION (flags) == EF_ARM_EABI_UNKNOWN)
    19892148        {
    1990           if (flags & EF_INTERWORK)
    1991             _bfd_error_handler (_("\
    1992 Warning: Not setting interwork flag of %s since it has already been specified as non-interworking"),
    1993                                 bfd_get_filename (abfd));
     2149          if (flags & EF_ARM_INTERWORK)
     2150            (*_bfd_error_handler) (_("\
     2151Warning: Not setting interworking flag of %s since it has already been specified as non-interworking"),
     2152                                   bfd_archive_filename (abfd));
    19942153          else
    19952154            _bfd_error_handler (_("\
    1996 Warning: Clearing the interwork flag of %s due to outside request"),
    1997                                 bfd_get_filename (abfd));
     2155Warning: Clearing the interworking flag of %s due to outside request"),
     2156                                bfd_archive_filename (abfd));
    19982157        }
    19992158    }
     
    20012160    {
    20022161      elf_elfheader (abfd)->e_flags = flags;
    2003       elf_flags_init (abfd) = true;
    2004     }
    2005 
    2006   return true;
     2162      elf_flags_init (abfd) = TRUE;
     2163    }
     2164
     2165  return TRUE;
    20072166}
    20082167
    20092168/* Copy backend specific data from one object module to another.  */
    20102169
    2011 static boolean
     2170static bfd_boolean
    20122171elf32_arm_copy_private_bfd_data (ibfd, obfd)
    20132172     bfd *ibfd;
     
    20192178  if (   bfd_get_flavour (ibfd) != bfd_target_elf_flavour
    20202179      || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
    2021     return true;
     2180    return TRUE;
    20222181
    20232182  in_flags  = elf_elfheader (ibfd)->e_flags;
     
    20292188    {
    20302189      /* Cannot mix APCS26 and APCS32 code.  */
    2031       if ((in_flags & EF_APCS_26) != (out_flags & EF_APCS_26))
    2032         return false;
     2190      if ((in_flags & EF_ARM_APCS_26) != (out_flags & EF_ARM_APCS_26))
     2191        return FALSE;
    20332192
    20342193      /* Cannot mix float APCS and non-float APCS code.  */
    2035       if ((in_flags & EF_APCS_FLOAT) != (out_flags & EF_APCS_FLOAT))
    2036         return false;
     2194      if ((in_flags & EF_ARM_APCS_FLOAT) != (out_flags & EF_ARM_APCS_FLOAT))
     2195        return FALSE;
    20372196
    20382197      /* If the src and dest have different interworking flags
    20392198         then turn off the interworking bit.  */
    2040       if ((in_flags & EF_INTERWORK) != (out_flags & EF_INTERWORK))
    2041         {
    2042           if (out_flags & EF_INTERWORK)
     2199      if ((in_flags & EF_ARM_INTERWORK) != (out_flags & EF_ARM_INTERWORK))
     2200        {
     2201          if (out_flags & EF_ARM_INTERWORK)
    20432202            _bfd_error_handler (_("\
    2044 Warning: Clearing the interwork flag in %s because non-interworking code in %s has been linked with it"),
    2045                           bfd_get_filename (obfd), bfd_get_filename (ibfd));
    2046 
    2047           in_flags &= ~EF_INTERWORK;
     2203Warning: Clearing the interworking flag of %s because non-interworking code in %s has been linked with it"),
     2204                                bfd_get_filename (obfd),
     2205                                bfd_archive_filename (ibfd));
     2206
     2207          in_flags &= ~EF_ARM_INTERWORK;
    20482208        }
    20492209
    20502210      /* Likewise for PIC, though don't warn for this case.  */
    2051       if ((in_flags & EF_PIC) != (out_flags & EF_PIC))
    2052         in_flags &= ~EF_PIC;
     2211      if ((in_flags & EF_ARM_PIC) != (out_flags & EF_ARM_PIC))
     2212        in_flags &= ~EF_ARM_PIC;
    20532213    }
    20542214
    20552215  elf_elfheader (obfd)->e_flags = in_flags;
    2056   elf_flags_init (obfd) = true;
    2057 
    2058   return true;
     2216  elf_flags_init (obfd) = TRUE;
     2217
     2218  return TRUE;
    20592219}
    20602220
     
    20622222   object file when linking.  */
    20632223
    2064 static boolean
     2224static bfd_boolean
    20652225elf32_arm_merge_private_bfd_data (ibfd, obfd)
    20662226     bfd * ibfd;
     
    20692229  flagword out_flags;
    20702230  flagword in_flags;
    2071   boolean flags_compatible = true;
    2072   boolean null_input_bfd = true;
     2231  bfd_boolean flags_compatible = TRUE;
     2232  bfd_boolean null_input_bfd = TRUE;
    20732233  asection *sec;
    20742234
    20752235  /* Check if we have the same endianess.  */
    2076   if (_bfd_generic_verify_endian_match (ibfd, obfd) == false)
    2077     return false;
     2236  if (! _bfd_generic_verify_endian_match (ibfd, obfd))
     2237    return FALSE;
    20782238
    20792239  if (   bfd_get_flavour (ibfd) != bfd_target_elf_flavour
    20802240      || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
    2081     return true;
     2241    return TRUE;
    20822242
    20832243  /* The input BFD must have had its flags initialised.  */
     
    21002260      if (bfd_get_arch_info (ibfd)->the_default
    21012261          && elf_elfheader (ibfd)->e_flags == 0)
    2102         return true;
    2103 
    2104       elf_flags_init (obfd) = true;
     2262        return TRUE;
     2263
     2264      elf_flags_init (obfd) = TRUE;
    21052265      elf_elfheader (obfd)->e_flags = in_flags;
    21062266
     
    21092269        return bfd_set_arch_mach (obfd, bfd_get_arch (ibfd), bfd_get_mach (ibfd));
    21102270
    2111       return true;
    2112     }
     2271      return TRUE;
     2272    }
     2273
     2274  /* Determine what should happen if the input ARM architecture
     2275     does not match the output ARM architecture.  */
     2276  if (! bfd_arm_merge_machines (ibfd, obfd))
     2277    return FALSE;
    21132278
    21142279  /* Identical flags must be compatible.  */
    21152280  if (in_flags == out_flags)
    2116     return true;
     2281    return TRUE;
    21172282
    21182283  /* Check to see if the input BFD actually contains any sections.
     
    21252290          && strcmp (sec->name, ".glue_7t"))
    21262291        {
    2127           null_input_bfd = false;
     2292          null_input_bfd = FALSE;
    21282293          break;
    21292294        }
    21302295    }
    21312296  if (null_input_bfd)
    2132     return true;
     2297    return TRUE;
    21332298
    21342299  /* Complain about various flag mismatches.  */
     
    21362301    {
    21372302      _bfd_error_handler (_("\
    2138 Error: %s compiled for EABI version %d, whereas %s is compiled for version %d"),
    2139                          bfd_get_filename (ibfd),
    2140                          (in_flags & EF_ARM_EABIMASK) >> 24,
    2141                          bfd_get_filename (obfd),
    2142                          (out_flags & EF_ARM_EABIMASK) >> 24);
    2143       return false;
     2303ERROR: %s is compiled for EABI version %d, whereas %s is compiled for version %d"),
     2304                          bfd_archive_filename (ibfd),
     2305                          (in_flags & EF_ARM_EABIMASK) >> 24,
     2306                          bfd_get_filename (obfd),
     2307                          (out_flags & EF_ARM_EABIMASK) >> 24);
     2308      return FALSE;
    21442309    }
    21452310
     
    21472312  if (EF_ARM_EABI_VERSION (in_flags) == EF_ARM_EABI_UNKNOWN)
    21482313    {
    2149       if ((in_flags & EF_APCS_26) != (out_flags & EF_APCS_26))
     2314      if ((in_flags & EF_ARM_APCS_26) != (out_flags & EF_ARM_APCS_26))
    21502315        {
    21512316          _bfd_error_handler (_("\
    2152 Error: %s compiled for APCS-%d, whereas %s is compiled for APCS-%d"),
    2153                         bfd_get_filename (ibfd),
    2154                         in_flags & EF_APCS_26 ? 26 : 32,
    2155                         bfd_get_filename (obfd),
    2156                         out_flags & EF_APCS_26 ? 26 : 32);
    2157           flags_compatible = false;
    2158         }
    2159 
    2160       if ((in_flags & EF_APCS_FLOAT) != (out_flags & EF_APCS_FLOAT))
    2161         {
    2162           _bfd_error_handler (_("\
    2163 Error: %s passes floats in %s registers, whereas %s passes them in %s registers"),
    2164                         bfd_get_filename (ibfd),
    2165                      in_flags & EF_APCS_FLOAT ? _("float") : _("integer"),
    2166                         bfd_get_filename (obfd),
    2167                       out_flags & EF_APCS_26 ? _("float") : _("integer"));
    2168           flags_compatible = false;
    2169         }
    2170 
    2171 #ifdef EF_SOFT_FLOAT
    2172       if ((in_flags & EF_SOFT_FLOAT) != (out_flags & EF_SOFT_FLOAT))
    2173         {
    2174           _bfd_error_handler (_ ("\
    2175 Error: %s uses %s floating point, whereas %s uses %s floating point"),
    2176                               bfd_get_filename (ibfd),
    2177                               in_flags & EF_SOFT_FLOAT ? _("soft") : _("hard"),
     2317ERROR: %s is compiled for APCS-%d, whereas target %s uses APCS-%d"),
     2318                              bfd_archive_filename (ibfd),
     2319                              in_flags & EF_ARM_APCS_26 ? 26 : 32,
    21782320                              bfd_get_filename (obfd),
    2179                               out_flags & EF_SOFT_FLOAT ? _("soft") : _("hard"));
    2180           flags_compatible = false;
     2321                              out_flags & EF_ARM_APCS_26 ? 26 : 32);
     2322          flags_compatible = FALSE;
     2323        }
     2324
     2325      if ((in_flags & EF_ARM_APCS_FLOAT) != (out_flags & EF_ARM_APCS_FLOAT))
     2326        {
     2327          if (in_flags & EF_ARM_APCS_FLOAT)
     2328            _bfd_error_handler (_("\
     2329ERROR: %s passes floats in float registers, whereas %s passes them in integer registers"),
     2330                                bfd_archive_filename (ibfd),
     2331                                bfd_get_filename (obfd));
     2332          else
     2333            _bfd_error_handler (_("\
     2334ERROR: %s passes floats in integer registers, whereas %s passes them in float registers"),
     2335                                bfd_archive_filename (ibfd),
     2336                                bfd_get_filename (obfd));
     2337
     2338          flags_compatible = FALSE;
     2339        }
     2340
     2341      if ((in_flags & EF_ARM_VFP_FLOAT) != (out_flags & EF_ARM_VFP_FLOAT))
     2342        {
     2343          if (in_flags & EF_ARM_VFP_FLOAT)
     2344            _bfd_error_handler (_("\
     2345ERROR: %s uses VFP instructions, whereas %s does not"),
     2346                                bfd_archive_filename (ibfd),
     2347                                bfd_get_filename (obfd));
     2348          else
     2349            _bfd_error_handler (_("\
     2350ERROR: %s uses FPA instructions, whereas %s does not"),
     2351                                bfd_archive_filename (ibfd),
     2352                                bfd_get_filename (obfd));
     2353
     2354          flags_compatible = FALSE;
     2355        }
     2356
     2357      if ((in_flags & EF_ARM_MAVERICK_FLOAT) != (out_flags & EF_ARM_MAVERICK_FLOAT))
     2358        {
     2359          if (in_flags & EF_ARM_MAVERICK_FLOAT)
     2360            _bfd_error_handler (_("\
     2361ERROR: %s uses Maverick instructions, whereas %s does not"),
     2362                                bfd_archive_filename (ibfd),
     2363                                bfd_get_filename (obfd));
     2364          else
     2365            _bfd_error_handler (_("\
     2366ERROR: %s uses Maverick instructions, whereas %s does not"),
     2367                                bfd_archive_filename (ibfd),
     2368                                bfd_get_filename (obfd));
     2369
     2370          flags_compatible = FALSE;
     2371        }
     2372
     2373#ifdef EF_ARM_SOFT_FLOAT
     2374      if ((in_flags & EF_ARM_SOFT_FLOAT) != (out_flags & EF_ARM_SOFT_FLOAT))
     2375        {
     2376          /* We can allow interworking between code that is VFP format
     2377             layout, and uses either soft float or integer regs for
     2378             passing floating point arguments and results.  We already
     2379             know that the APCS_FLOAT flags match; similarly for VFP
     2380             flags.  */
     2381          if ((in_flags & EF_ARM_APCS_FLOAT) != 0
     2382              || (in_flags & EF_ARM_VFP_FLOAT) == 0)
     2383            {
     2384              if (in_flags & EF_ARM_SOFT_FLOAT)
     2385                _bfd_error_handler (_("\
     2386ERROR: %s uses software FP, whereas %s uses hardware FP"),
     2387                                    bfd_archive_filename (ibfd),
     2388                                    bfd_get_filename (obfd));
     2389              else
     2390                _bfd_error_handler (_("\
     2391ERROR: %s uses hardware FP, whereas %s uses software FP"),
     2392                                    bfd_archive_filename (ibfd),
     2393                                    bfd_get_filename (obfd));
     2394
     2395              flags_compatible = FALSE;
     2396            }
    21812397        }
    21822398#endif
    21832399
    21842400      /* Interworking mismatch is only a warning.  */
    2185       if ((in_flags & EF_INTERWORK) != (out_flags & EF_INTERWORK))
    2186         _bfd_error_handler (_("\
    2187 Warning: %s %s interworking, whereas %s %s"),
    2188                           bfd_get_filename (ibfd),
    2189           in_flags & EF_INTERWORK ? _("supports") : _("does not support"),
    2190                           bfd_get_filename (obfd),
    2191                     out_flags & EF_INTERWORK ? _("does not") : _("does"));
     2401      if ((in_flags & EF_ARM_INTERWORK) != (out_flags & EF_ARM_INTERWORK))
     2402        {
     2403          if (in_flags & EF_ARM_INTERWORK)
     2404            {
     2405              _bfd_error_handler (_("\
     2406Warning: %s supports interworking, whereas %s does not"),
     2407                                  bfd_archive_filename (ibfd),
     2408                                  bfd_get_filename (obfd));
     2409            }
     2410          else
     2411            {
     2412              _bfd_error_handler (_("\
     2413Warning: %s does not support interworking, whereas %s does"),
     2414                                  bfd_archive_filename (ibfd),
     2415                                  bfd_get_filename (obfd));
     2416            }
     2417        }
    21922418    }
    21932419
     
    21972423/* Display the flags field.  */
    21982424
    2199 static boolean
     2425static bfd_boolean
    22002426elf32_arm_print_private_bfd_data (abfd, ptr)
    22012427     bfd *abfd;
     
    22232449         official ARM ELF extended ABI.  Hence they are only decoded if
    22242450         the EABI version is not set.  */
    2225       if (flags & EF_INTERWORK)
     2451      if (flags & EF_ARM_INTERWORK)
    22262452        fprintf (file, _(" [interworking enabled]"));
    22272453
    2228       if (flags & EF_APCS_26)
    2229         fprintf (file, _(" [APCS-26]"));
     2454      if (flags & EF_ARM_APCS_26)
     2455        fprintf (file, " [APCS-26]");
    22302456      else
    2231         fprintf (file, _(" [APCS-32]"));
    2232 
    2233       if (flags & EF_APCS_FLOAT)
     2457        fprintf (file, " [APCS-32]");
     2458
     2459      if (flags & EF_ARM_VFP_FLOAT)
     2460        fprintf (file, _(" [VFP float format]"));
     2461      else if (flags & EF_ARM_MAVERICK_FLOAT)
     2462        fprintf (file, _(" [Maverick float format]"));
     2463      else
     2464        fprintf (file, _(" [FPA float format]"));
     2465
     2466      if (flags & EF_ARM_APCS_FLOAT)
    22342467        fprintf (file, _(" [floats passed in float registers]"));
    22352468
    2236       if (flags & EF_PIC)
     2469      if (flags & EF_ARM_PIC)
    22372470        fprintf (file, _(" [position independent]"));
    22382471
    2239       if (flags & EF_NEW_ABI)
     2472      if (flags & EF_ARM_NEW_ABI)
    22402473        fprintf (file, _(" [new ABI]"));
    22412474
    2242       if (flags & EF_OLD_ABI)
     2475      if (flags & EF_ARM_OLD_ABI)
    22432476        fprintf (file, _(" [old ABI]"));
    22442477
    2245       if (flags & EF_SOFT_FLOAT)
     2478      if (flags & EF_ARM_SOFT_FLOAT)
    22462479        fprintf (file, _(" [software FP]"));
    22472480
    2248       flags &= ~(EF_INTERWORK | EF_APCS_26 | EF_APCS_FLOAT | EF_PIC
    2249                  | EF_NEW_ABI | EF_OLD_ABI | EF_SOFT_FLOAT);
     2481      flags &= ~(EF_ARM_INTERWORK | EF_ARM_APCS_26 | EF_ARM_APCS_FLOAT
     2482                 | EF_ARM_PIC | EF_ARM_NEW_ABI | EF_ARM_OLD_ABI
     2483                 | EF_ARM_SOFT_FLOAT | EF_ARM_VFP_FLOAT
     2484                 | EF_ARM_MAVERICK_FLOAT);
    22502485      break;
    22512486
     
    22612496      break;
    22622497
     2498    case EF_ARM_EABI_VER2:
     2499      fprintf (file, _(" [Version2 EABI]"));
     2500
     2501      if (flags & EF_ARM_SYMSARESORTED)
     2502        fprintf (file, _(" [sorted symbol table]"));
     2503      else
     2504        fprintf (file, _(" [unsorted symbol table]"));
     2505
     2506      if (flags & EF_ARM_DYNSYMSUSESEGIDX)
     2507        fprintf (file, _(" [dynamic symbols use segment index]"));
     2508
     2509      if (flags & EF_ARM_MAPSYMSFIRST)
     2510        fprintf (file, _(" [mapping symbols precede others]"));
     2511
     2512      flags &= ~(EF_ARM_SYMSARESORTED | EF_ARM_DYNSYMSUSESEGIDX
     2513                 | EF_ARM_MAPSYMSFIRST);
     2514      break;
     2515
    22632516    default:
    22642517      fprintf (file, _(" <EABI version unrecognised>"));
     
    22812534  fputc ('\n', file);
    22822535
    2283   return true;
     2536  return TRUE;
    22842537}
    22852538
     
    23112564
    23122565static asection *
    2313 elf32_arm_gc_mark_hook (abfd, info, rel, h, sym)
    2314        bfd *abfd;
     2566elf32_arm_gc_mark_hook (sec, info, rel, h, sym)
     2567       asection *sec;
    23152568       struct bfd_link_info *info ATTRIBUTE_UNUSED;
    23162569       Elf_Internal_Rela *rel;
     
    23422595     }
    23432596   else
    2344      {
    2345        if (!(elf_bad_symtab (abfd)
    2346            && ELF_ST_BIND (sym->st_info) != STB_LOCAL)
    2347          && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE)
    2348                 && sym->st_shndx != SHN_COMMON))
    2349           {
    2350             return bfd_section_from_elf_index (abfd, sym->st_shndx);
    2351           }
    2352       }
     2597     return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
     2598
    23532599  return NULL;
    23542600}
     
    23562602/* Update the got entry reference counts for the section being removed.  */
    23572603
    2358 static boolean
     2604static bfd_boolean
    23592605elf32_arm_gc_sweep_hook (abfd, info, sec, relocs)
    23602606     bfd *abfd ATTRIBUTE_UNUSED;
     
    23642610{
    23652611  /* We don't support garbage collection of GOT and PLT relocs yet.  */
    2366   return true;
     2612  return TRUE;
    23672613}
    23682614
    23692615/* Look through the relocs for a section during the first phase.  */
    23702616
    2371 static boolean
     2617static bfd_boolean
    23722618elf32_arm_check_relocs (abfd, info, sec, relocs)
    2373      bfd *                      abfd;
    2374      struct bfd_link_info *     info;
    2375      asection *                 sec;
    2376      const Elf_Internal_Rela *  relocs;
     2619     bfd *abfd;
     2620     struct bfd_link_info *info;
     2621     asection *sec;
     2622     const Elf_Internal_Rela *relocs;
    23772623{
    2378   Elf_Internal_Shdr *           symtab_hdr;
    2379   struct elf_link_hash_entry ** sym_hashes;
    2380   struct elf_link_hash_entry ** sym_hashes_end;
    2381   const Elf_Internal_Rela *     rel;
    2382   const Elf_Internal_Rela *     rel_end;
    2383   bfd *                         dynobj;
    2384   asection * sgot, *srelgot, *sreloc;
    2385   bfd_vma * local_got_offsets;
     2624  Elf_Internal_Shdr *symtab_hdr;
     2625  struct elf_link_hash_entry **sym_hashes;
     2626  struct elf_link_hash_entry **sym_hashes_end;
     2627  const Elf_Internal_Rela *rel;
     2628  const Elf_Internal_Rela *rel_end;
     2629  bfd *dynobj;
     2630  asection *sgot, *srelgot, *sreloc;
     2631  bfd_vma *local_got_offsets;
    23862632
    23872633  if (info->relocateable)
    2388     return true;
     2634    return TRUE;
    23892635
    23902636  sgot = srelgot = sreloc = NULL;
     
    24232669              elf_hash_table (info)->dynobj = dynobj = abfd;
    24242670              if (! _bfd_elf_create_got_section (dynobj, info))
    2425                 return false;
     2671                return FALSE;
    24262672              break;
    24272673
     
    24532699                    if (srelgot == NULL
    24542700                        || ! bfd_set_section_flags (dynobj, srelgot,
    2455                                                     (SEC_ALLOC
     2701                                                    (SEC_ALLOC
    24562702                                                     | SEC_LOAD
    24572703                                                     | SEC_HAS_CONTENTS
     
    24602706                                                     | SEC_READONLY))
    24612707                        || ! bfd_set_section_alignment (dynobj, srelgot, 2))
    2462                       return false;
     2708                      return FALSE;
    24632709                  }
    24642710              }
     
    24752721                if (h->dynindx == -1)
    24762722                  if (! bfd_elf32_link_record_dynamic_symbol (info, h))
    2477                     return false;
     2723                    return FALSE;
    24782724
    24792725                srelgot->_raw_size += sizeof (Elf32_External_Rel);
     
    24812727            else
    24822728              {
    2483                 /* This is a global offset table entry for a local
     2729                /* This is a global offset table entry for a local
    24842730                   symbol.  */
    24852731                if (local_got_offsets == NULL)
    24862732                  {
    2487                     size_t size;
    2488                     register unsigned int i;
    2489 
    2490                     size = symtab_hdr->sh_info * sizeof (bfd_vma);
     2733                    bfd_size_type size;
     2734                    unsigned int i;
     2735
     2736                    size = symtab_hdr->sh_info;
     2737                    size *= sizeof (bfd_vma);
    24912738                    local_got_offsets = (bfd_vma *) bfd_alloc (abfd, size);
    24922739                    if (local_got_offsets == NULL)
    2493                       return false;
     2740                      return FALSE;
    24942741                    elf_local_got_offsets (abfd) = local_got_offsets;
    24952742                    for (i = 0; i < symtab_hdr->sh_info; i++)
     
    25132760            break;
    25142761
    2515           case R_ARM_PLT32:
     2762          case R_ARM_PLT32:
    25162763            /* This symbol requires a procedure linkage table entry.  We
    25172764               actually build the entry in adjust_dynamic_symbol,
     
    25632810                             elf_section_data (sec)->rel_hdr.sh_name));
    25642811                    if (name == NULL)
    2565                       return false;
     2812                      return FALSE;
    25662813
    25672814                    BFD_ASSERT (strncmp (name, ".rel", 4) == 0
    2568                                 && strcmp (bfd_get_section_name (abfd, sec),
     2815                                && strcmp (bfd_get_section_name (abfd, sec),
    25692816                                           name + 4) == 0);
    25702817
     
    25822829                            || ! bfd_set_section_flags (dynobj, sreloc, flags)
    25832830                            || ! bfd_set_section_alignment (dynobj, sreloc, 2))
    2584                           return false;
     2831                          return FALSE;
    25852832                      }
     2833                  if (sec->flags & SEC_READONLY)
     2834                    info->flags |= DF_TEXTREL;
    25862835                  }
    25872836
     
    26102859                      {
    26112860                        p = ((struct elf32_arm_pcrel_relocs_copied *)
    2612                              bfd_alloc (dynobj, sizeof * p));
    2613 
     2861                             bfd_alloc (dynobj, (bfd_size_type) sizeof * p));
    26142862                        if (p == NULL)
    2615                           return false;
     2863                          return FALSE;
    26162864                        p->next = eh->pcrel_relocs_copied;
    26172865                        eh->pcrel_relocs_copied = p;
     
    26292877        case R_ARM_GNU_VTINHERIT:
    26302878          if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
    2631             return false;
     2879            return FALSE;
    26322880          break;
    26332881
     
    26362884        case R_ARM_GNU_VTENTRY:
    26372885          if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_offset))
    2638             return false;
     2886            return FALSE;
    26392887          break;
    26402888        }
    26412889    }
    26422890
    2643   return true;
     2891  return TRUE;
    26442892}
    26452893
     
    26482896   that it also accepts STT_ARM_TFUNC as a symbol that names a function.  */
    26492897
    2650 static boolean
     2898static bfd_boolean
    26512899elf32_arm_find_nearest_line
    26522900  (abfd, section, symbols, offset, filename_ptr, functionname_ptr, line_ptr)
    2653      bfd *          abfd;
    2654      asection *     section;
    2655      asymbol **     symbols;
    2656      bfd_vma        offset;
    2657      CONST char **  filename_ptr;
    2658      CONST char **  functionname_ptr;
    2659      unsigned int * line_ptr;
     2901     bfd *abfd;
     2902     asection *section;
     2903     asymbol **symbols;
     2904     bfd_vma offset;
     2905     const char **filename_ptr;
     2906     const char **functionname_ptr;
     2907     unsigned int *line_ptr;
    26602908{
    2661   boolean      found;
    2662   const char * filename;
    2663   asymbol *    func;
    2664   bfd_vma      low_func;
    2665   asymbol **   p;
     2909  bfd_boolean found;
     2910  const char *filename;
     2911  asymbol *func;
     2912  bfd_vma low_func;
     2913  asymbol **p;
    26662914
    26672915  if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
     
    26692917                                     line_ptr, 0,
    26702918                                     &elf_tdata (abfd)->dwarf2_find_line_info))
    2671     return true;
     2919    return TRUE;
    26722920
    26732921  if (! _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset,
     
    26752923                                             functionname_ptr, line_ptr,
    26762924                                             &elf_tdata (abfd)->line_info))
    2677     return false;
     2925    return FALSE;
    26782926
    26792927  if (found)
    2680     return true;
     2928    return TRUE;
    26812929
    26822930  if (symbols == NULL)
    2683     return false;
     2931    return FALSE;
    26842932
    26852933  filename = NULL;
     
    27182966
    27192967  if (func == NULL)
    2720     return false;
     2968    return FALSE;
    27212969
    27222970  *filename_ptr = filename;
     
    27242972  *line_ptr = 0;
    27252973
    2726   return true;
     2974  return TRUE;
    27272975}
    27282976
     
    27332981   understand.  */
    27342982
    2735 static boolean
     2983static bfd_boolean
    27362984elf32_arm_adjust_dynamic_symbol (info, h)
    27372985     struct bfd_link_info * info;
     
    27613009      || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
    27623010    {
     3011      /* If we link a program (not a DSO), we'll get rid of unnecessary
     3012         PLT entries; we point to the actual symbols -- even for pic
     3013         relocs, because a program built with -fpic should have the same
     3014         result as one built without -fpic, specifically considering weak
     3015         symbols.
     3016         FIXME: m68k and i386 differ here, for unclear reasons.  */
    27633017      if (! info->shared
    2764           && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0
    2765           && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) == 0)
     3018          && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0)
    27663019        {
    27673020          /* This case can occur if we saw a PLT32 reloc in an input
    2768              file, but the symbol was never referred to by a dynamic
    2769              object.  In such a case, we don't actually need to build
    2770              a procedure linkage table, and we can just do a PC32
    2771              reloc instead.  */
     3021             file, but the symbol was not defined by a dynamic object.
     3022             In such a case, we don't actually need to build a
     3023             procedure linkage table, and we can just do a PC32 reloc
     3024            instead.  */
    27723025          BFD_ASSERT ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0);
    2773           return true;
     3026          h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
     3027          return TRUE;
    27743028        }
    27753029
     
    27783032        {
    27793033          if (! bfd_elf32_link_record_dynamic_symbol (info, h))
    2780             return false;
     3034            return FALSE;
    27813035        }
    27823036
     
    28183072      s->_raw_size += sizeof (Elf32_External_Rel);
    28193073
    2820       return true;
     3074      return TRUE;
    28213075    }
    28223076
     
    28303084      h->root.u.def.section = h->weakdef->root.u.def.section;
    28313085      h->root.u.def.value = h->weakdef->root.u.def.value;
    2832       return true;
     3086      return TRUE;
    28333087    }
    28343088
     
    28413095     be handled correctly by relocate_section.  */
    28423096  if (info->shared)
    2843     return true;
     3097    return TRUE;
    28443098
    28453099  /* We must allocate the symbol in our .dynbss section, which will
     
    28813135    {
    28823136      if (! bfd_set_section_alignment (dynobj, s, power_of_two))
    2883         return false;
     3137        return FALSE;
    28843138    }
    28853139
     
    28913145  s->_raw_size += h->size;
    28923146
    2893   return true;
     3147  return TRUE;
    28943148}
    28953149
    28963150/* Set the sizes of the dynamic sections.  */
    28973151
    2898 static boolean
     3152static bfd_boolean
    28993153elf32_arm_size_dynamic_sections (output_bfd, info)
    2900      bfd * output_bfd;
     3154     bfd * output_bfd ATTRIBUTE_UNUSED;
    29013155     struct bfd_link_info * info;
    29023156{
    29033157  bfd * dynobj;
    29043158  asection * s;
    2905   boolean plt;
    2906   boolean relocs;
    2907   boolean reltext;
     3159  bfd_boolean plt;
     3160  bfd_boolean relocs;
    29083161
    29093162  dynobj = elf_hash_table (info)->dynobj;
     
    29453198     determined the sizes of the various dynamic sections.  Allocate
    29463199     memory for them.  */
    2947   plt = false;
    2948   relocs = false;
    2949   reltext = false;
     3200  plt = FALSE;
     3201  relocs = FALSE;
    29503202  for (s = dynobj->sections; s != NULL; s = s->next)
    29513203    {
    29523204      const char * name;
    2953       boolean strip;
     3205      bfd_boolean strip;
    29543206
    29553207      if ((s->flags & SEC_LINKER_CREATED) == 0)
     
    29603212      name = bfd_get_section_name (dynobj, s);
    29613213
    2962       strip = false;
     3214      strip = FALSE;
    29633215
    29643216      if (strcmp (name, ".plt") == 0)
     
    29683220              /* Strip this section if we don't need it; see the
    29693221                 comment below.  */
    2970               strip = true;
     3222              strip = TRUE;
    29713223            }
    29723224          else
    29733225            {
    29743226              /* Remember whether there is a PLT.  */
    2975               plt = true;
     3227              plt = TRUE;
    29763228            }
    29773229        }
     
    29893241                 function which decides whether anything needs to go
    29903242                 into these sections.  */
    2991               strip = true;
     3243              strip = TRUE;
    29923244            }
    29933245          else
    29943246            {
    2995               asection * target;
    2996 
    29973247              /* Remember whether there are any reloc sections other
    29983248                 than .rel.plt.  */
    29993249              if (strcmp (name, ".rel.plt") != 0)
    3000                 {
    3001                   const char *outname;
    3002 
    3003                   relocs = true;
    3004 
    3005                   /* If this relocation section applies to a read only
    3006                      section, then we probably need a DT_TEXTREL
    3007                      entry.  The entries in the .rel.plt section
    3008                      really apply to the .got section, which we
    3009                      created ourselves and so know is not readonly.  */
    3010                   outname = bfd_get_section_name (output_bfd,
    3011                                                   s->output_section);
    3012                   target = bfd_get_section_by_name (output_bfd, outname + 4);
    3013 
    3014                   if (target != NULL
    3015                       && (target->flags & SEC_READONLY) != 0
    3016                       && (target->flags & SEC_ALLOC) != 0)
    3017                     reltext = true;
    3018                 }
     3250                relocs = TRUE;
    30193251
    30203252              /* We use the reloc_count field as a counter if we need
     
    30313263      if (strip)
    30323264        {
    3033           asection ** spp;
    3034 
    3035           for (spp = &s->output_section->owner->sections;
    3036                *spp != s->output_section;
    3037                spp = &(*spp)->next)
    3038             ;
    3039           *spp = s->output_section->next;
    3040           --s->output_section->owner->section_count;
    3041 
     3265          _bfd_strip_section_from_output (info, s);
    30423266          continue;
    30433267        }
     
    30463270      s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
    30473271      if (s->contents == NULL && s->_raw_size != 0)
    3048         return false;
     3272        return FALSE;
    30493273    }
    30503274
     
    30563280         the .dynamic section.  The DT_DEBUG entry is filled in by the
    30573281         dynamic linker and used by the debugger.  */
    3058       if (! info->shared)
    3059         {
    3060           if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
    3061             return false;
     3282#define add_dynamic_entry(TAG, VAL) \
     3283  bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
     3284
     3285      if (!info->shared)
     3286        {
     3287          if (!add_dynamic_entry (DT_DEBUG, 0))
     3288            return FALSE;
    30623289        }
    30633290
    30643291      if (plt)
    30653292        {
    3066           if (   ! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)
    3067               || ! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
    3068               || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_REL)
    3069               || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
    3070             return false;
     3293          if (   !add_dynamic_entry (DT_PLTGOT, 0)
     3294              || !add_dynamic_entry (DT_PLTRELSZ, 0)
     3295              || !add_dynamic_entry (DT_PLTREL, DT_REL)
     3296              || !add_dynamic_entry (DT_JMPREL, 0))
     3297            return FALSE;
    30713298        }
    30723299
    30733300      if (relocs)
    30743301        {
    3075           if (   ! bfd_elf32_add_dynamic_entry (info, DT_REL, 0)
    3076               || ! bfd_elf32_add_dynamic_entry (info, DT_RELSZ, 0)
    3077               || ! bfd_elf32_add_dynamic_entry (info, DT_RELENT,
    3078                                                 sizeof (Elf32_External_Rel)))
    3079             return false;
    3080         }
    3081 
    3082       if (reltext)
    3083         {
    3084           if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
    3085             return false;
     3302          if (   !add_dynamic_entry (DT_REL, 0)
     3303              || !add_dynamic_entry (DT_RELSZ, 0)
     3304              || !add_dynamic_entry (DT_RELENT, sizeof (Elf32_External_Rel)))
     3305            return FALSE;
     3306        }
     3307
     3308      if ((info->flags & DF_TEXTREL) != 0)
     3309        {
     3310          if (!add_dynamic_entry (DT_TEXTREL, 0))
     3311            return FALSE;
    30863312          info->flags |= DF_TEXTREL;
    30873313        }
    30883314    }
    3089 
    3090   return true;
     3315#undef add_synamic_entry
     3316
     3317  return TRUE;
    30913318}
    30923319
     
    30983325   relocate_section routine.  */
    30993326
    3100 static boolean
     3327static bfd_boolean
    31013328elf32_arm_discard_copies (h, ignore)
    31023329     struct elf32_arm_link_hash_entry * h;
     
    31053332  struct elf32_arm_pcrel_relocs_copied * s;
    31063333
     3334  if (h->root.root.type == bfd_link_hash_warning)
     3335    h = (struct elf32_arm_link_hash_entry *) h->root.root.u.i.link;
     3336
    31073337  /* We only discard relocs for symbols defined in a regular object.  */
    31083338  if ((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
    3109     return true;
     3339    return TRUE;
    31103340
    31113341  for (s = h->pcrel_relocs_copied; s != NULL; s = s->next)
    31123342    s->section->_raw_size -= s->count * sizeof (Elf32_External_Rel);
    31133343
    3114   return true;
     3344  return TRUE;
    31153345}
    31163346
     
    31183348   dynamic sections here.  */
    31193349
    3120 static boolean
     3350static bfd_boolean
    31213351elf32_arm_finish_dynamic_symbol (output_bfd, info, h, sym)
    31223352     bfd * output_bfd;
     
    31363366      bfd_vma plt_index;
    31373367      bfd_vma got_offset;
    3138       Elf_Internal_Rel rel;
     3368      Elf_Internal_Rela rel;
     3369      bfd_byte *loc;
    31393370
    31403371      /* This symbol has an entry in the procedure linkage table.  Set
     
    31863417                      + got_offset);
    31873418      rel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_JUMP_SLOT);
    3188       bfd_elf32_swap_reloc_out (output_bfd, &rel,
    3189                                 ((Elf32_External_Rel *) srel->contents
    3190                                  + plt_index));
     3419      loc = srel->contents + plt_index * sizeof (Elf32_External_Rel);
     3420      bfd_elf32_swap_reloc_out (output_bfd, &rel, loc);
    31913421
    31923422      if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
     
    32093439      asection * sgot;
    32103440      asection * srel;
    3211       Elf_Internal_Rel rel;
     3441      Elf_Internal_Rela rel;
     3442      bfd_byte *loc;
    32123443
    32133444      /* This symbol has an entry in the global offset table.  Set it
     
    32193450      rel.r_offset = (sgot->output_section->vma
    32203451                      + sgot->output_offset
    3221                       + (h->got.offset &~ 1));
     3452                      + (h->got.offset &~ (bfd_vma) 1));
    32223453
    32233454      /* If this is a -Bsymbolic link, and the symbol is defined
     
    32353466        }
    32363467
    3237       bfd_elf32_swap_reloc_out (output_bfd, &rel,
    3238                                 ((Elf32_External_Rel *) srel->contents
    3239                                  + srel->reloc_count));
    3240       ++srel->reloc_count;
     3468      loc = srel->contents + srel->reloc_count++ * sizeof (Elf32_External_Rel);
     3469      bfd_elf32_swap_reloc_out (output_bfd, &rel, loc);
    32413470    }
    32423471
     
    32443473    {
    32453474      asection * s;
    3246       Elf_Internal_Rel rel;
     3475      Elf_Internal_Rela rel;
     3476      bfd_byte *loc;
    32473477
    32483478      /* This symbol needs a copy reloc.  Set it up.  */
     
    32593489                      + h->root.u.def.section->output_offset);
    32603490      rel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_COPY);
    3261       bfd_elf32_swap_reloc_out (output_bfd, &rel,
    3262                                 ((Elf32_External_Rel *) s->contents
    3263                                  + s->reloc_count));
    3264       ++s->reloc_count;
     3491      loc = s->contents + s->reloc_count++ * sizeof (Elf32_External_Rel);
     3492      bfd_elf32_swap_reloc_out (output_bfd, &rel, loc);
    32653493    }
    32663494
     
    32703498    sym->st_shndx = SHN_ABS;
    32713499
    3272   return true;
     3500  return TRUE;
    32733501}
    32743502
    32753503/* Finish up the dynamic sections.  */
    32763504
    3277 static boolean
     3505static bfd_boolean
    32783506elf32_arm_finish_dynamic_sections (output_bfd, info)
    32793507     bfd * output_bfd;
     
    33563584              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
    33573585              break;
     3586
     3587              /* Set the bottom bit of DT_INIT/FINI if the
     3588                 corresponding function is Thumb.  */
     3589            case DT_INIT:
     3590              name = info->init_function;
     3591              goto get_sym;
     3592            case DT_FINI:
     3593              name = info->fini_function;
     3594            get_sym:
     3595              /* If it wasn't set by elf_bfd_final_link
     3596                 then there is nothing to ajdust.  */
     3597              if (dyn.d_un.d_val != 0)
     3598                {
     3599                  struct elf_link_hash_entry * eh;
     3600
     3601                  eh = elf_link_hash_lookup (elf_hash_table (info), name,
     3602                                             FALSE, FALSE, TRUE);
     3603                  if (eh != (struct elf_link_hash_entry *) NULL
     3604                      && ELF_ST_TYPE (eh->type) == STT_ARM_TFUNC)
     3605                    {
     3606                      dyn.d_un.d_val |= 1;
     3607                      bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
     3608                    }
     3609                }
     3610              break;
    33583611            }
    33593612        }
     
    33883641  elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
    33893642
    3390   return true;
     3643  return TRUE;
    33913644}
    33923645
     
    34043657}
    34053658
     3659static enum elf_reloc_type_class
     3660elf32_arm_reloc_type_class (rela)
     3661     const Elf_Internal_Rela *rela;
     3662{
     3663  switch ((int) ELF32_R_TYPE (rela->r_info))
     3664    {
     3665    case R_ARM_RELATIVE:
     3666      return reloc_class_relative;
     3667    case R_ARM_JUMP_SLOT:
     3668      return reloc_class_plt;
     3669    case R_ARM_COPY:
     3670      return reloc_class_copy;
     3671    default:
     3672      return reloc_class_normal;
     3673    }
     3674}
     3675
     3676static bfd_boolean elf32_arm_section_flags           PARAMS ((flagword *, Elf_Internal_Shdr *));
     3677static void        elf32_arm_final_write_processing  PARAMS ((bfd *, bfd_boolean));
     3678
     3679/* Set the right machine number for an Arm ELF file.  */
     3680
     3681static bfd_boolean
     3682elf32_arm_section_flags (flags, hdr)
     3683     flagword *flags;
     3684     Elf_Internal_Shdr *hdr;
     3685{
     3686  if (hdr->sh_type == SHT_NOTE)
     3687    *flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_SAME_CONTENTS;
     3688
     3689  return TRUE;
     3690}
     3691
     3692void
     3693elf32_arm_final_write_processing (abfd, linker)
     3694     bfd *abfd;
     3695     bfd_boolean linker ATTRIBUTE_UNUSED;
     3696{
     3697  bfd_arm_update_notes (abfd, ARM_NOTE_SECTION);
     3698}
     3699
    34063700#define ELF_ARCH                        bfd_arch_arm
    34073701#define ELF_MACHINE_CODE                EM_ARM
    34083702#define ELF_MAXPAGESIZE                 0x8000
    34093703
    3410 #define bfd_elf32_bfd_copy_private_bfd_data     elf32_arm_copy_private_bfd_data
    3411 #define bfd_elf32_bfd_merge_private_bfd_data    elf32_arm_merge_private_bfd_data
     3704#define bfd_elf32_bfd_copy_private_bfd_data     elf32_arm_copy_private_bfd_data
     3705#define bfd_elf32_bfd_merge_private_bfd_data    elf32_arm_merge_private_bfd_data
    34123706#define bfd_elf32_bfd_set_private_flags         elf32_arm_set_private_flags
    34133707#define bfd_elf32_bfd_print_private_bfd_data    elf32_arm_print_private_bfd_data
    34143708#define bfd_elf32_bfd_link_hash_table_create    elf32_arm_link_hash_table_create
    3415 #define bfd_elf32_bfd_reloc_type_lookup         elf32_arm_reloc_type_lookup
     3709#define bfd_elf32_bfd_reloc_type_lookup         elf32_arm_reloc_type_lookup
    34163710#define bfd_elf32_find_nearest_line             elf32_arm_find_nearest_line
    34173711
     
    34203714#define elf_backend_gc_sweep_hook               elf32_arm_gc_sweep_hook
    34213715#define elf_backend_check_relocs                elf32_arm_check_relocs
    3422 #define elf_backend_relocate_section            elf32_arm_relocate_section
     3716#define elf_backend_relocate_section            elf32_arm_relocate_section
    34233717#define elf_backend_adjust_dynamic_symbol       elf32_arm_adjust_dynamic_symbol
    34243718#define elf_backend_create_dynamic_sections     _bfd_elf_create_dynamic_sections
     
    34273721#define elf_backend_size_dynamic_sections       elf32_arm_size_dynamic_sections
    34283722#define elf_backend_post_process_headers        elf32_arm_post_process_headers
     3723#define elf_backend_reloc_type_class            elf32_arm_reloc_type_class
     3724#define elf_backend_object_p                    elf32_arm_object_p
     3725#define elf_backend_section_flags               elf32_arm_section_flags
     3726#define elf_backend_final_write_processing      elf32_arm_final_write_processing
    34293727
    34303728#define elf_backend_can_gc_sections 1
     
    34323730#define elf_backend_want_got_plt    1
    34333731#define elf_backend_want_plt_sym    0
     3732#if !USE_REL
     3733#define elf_backend_rela_normal     1
     3734#endif
    34343735
    34353736#define elf_backend_got_header_size     12
     
    34373738
    34383739#include "elf32-target.h"
     3740
Note: See TracChangeset for help on using the changeset viewer.