]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2006-05-24 Paul Brook <paul@codesourcery.com>
authorPaul Brook <paul@codesourcery.com>
Wed, 24 May 2006 17:14:53 +0000 (17:14 +0000)
committerPaul Brook <paul@codesourcery.com>
Wed, 24 May 2006 17:14:53 +0000 (17:14 +0000)
Backport from mainline.
* bfd/elf-bfd.h (elf_backend_data): Add
elf_backend_output_arch_local_syms
* bfd/elf32-arm.c (output_arch_syminfo): Define.
(elf32_arm_ouput_plt_map_sym, elf32_arm_output_plt_map,
elf32_arm_output_arch_local_syms): New functions.
(elf_backend_output_arch_local_syms): Define.
* bfd/elflink.c (bfd_elf_final_link): Call
elf_backend_output_arch_local_syms.
* bfd/elfxx-target.h (elf_backend_output_arch_local_syms): Provide
default definition.
(elfNN_bed): Add elf_backend_output_arch_local_syms.
* ld/testsuite/ld-arm/arm-app-abs32.d: Update expected output.
* ld/testsuite/ld-arm/arm-app.d: Ditto.
* ld/testsuite/ld-arm/arm-lib-plt32.d: Ditto.
* ld/testsuite/ld-arm/arm-lib.d: Ditto.
* ld/testsuite/ld-arm/mixed-app-v5.d: Ditto.
* ld/testsuite/ld-arm/mixed-app.d: Ditto.
* ld/testsuite/ld-arm/mixed-lib.d: Ditto.

12 files changed:
ChangeLog.csl
bfd/elf-bfd.h
bfd/elf32-arm.c
bfd/elflink.c
bfd/elfxx-target.h
ld/testsuite/ld-arm/arm-app-abs32.d
ld/testsuite/ld-arm/arm-app.d
ld/testsuite/ld-arm/arm-lib-plt32.d
ld/testsuite/ld-arm/arm-lib.d
ld/testsuite/ld-arm/mixed-app-v5.d
ld/testsuite/ld-arm/mixed-app.d
ld/testsuite/ld-arm/mixed-lib.d

index fe83c0aed99b2d234c695990564dc7fe621e5a43..048a016caeef98c7792cf64ab0993ce246694c0b 100644 (file)
@@ -1,6 +1,28 @@
 2006-05-24  Paul Brook  <paul@codesourcery.com>
 
-       Backport form mainline.
+       Backport from mainline.
+       * bfd/elf-bfd.h (elf_backend_data): Add
+       elf_backend_output_arch_local_syms
+       * bfd/elf32-arm.c (output_arch_syminfo): Define.
+       (elf32_arm_ouput_plt_map_sym, elf32_arm_output_plt_map,
+       elf32_arm_output_arch_local_syms): New functions.
+       (elf_backend_output_arch_local_syms): Define.
+       * bfd/elflink.c (bfd_elf_final_link): Call
+       elf_backend_output_arch_local_syms.
+       * bfd/elfxx-target.h (elf_backend_output_arch_local_syms): Provide
+       default definition.
+       (elfNN_bed): Add elf_backend_output_arch_local_syms.
+       * ld/testsuite/ld-arm/arm-app-abs32.d: Update expected output.
+       * ld/testsuite/ld-arm/arm-app.d: Ditto.
+       * ld/testsuite/ld-arm/arm-lib-plt32.d: Ditto.
+       * ld/testsuite/ld-arm/arm-lib.d: Ditto.
+       * ld/testsuite/ld-arm/mixed-app-v5.d: Ditto.
+       * ld/testsuite/ld-arm/mixed-app.d: Ditto.
+       * ld/testsuite/ld-arm/mixed-lib.d: Ditto.
+
+2006-05-24  Paul Brook  <paul@codesourcery.com>
+
+       Backport from mainline.
        * bfd/elf32-arm.c (put_arm_insn, put_thumb_insn): New functions.
        (elf32_thumb_to_arm_stub, elf32_arm_to_thumb_stub,
        elf32_arm_finish_dynamic_symbol): Use them.
index 3fba1c228f0a9d57e3cf98727b969b167503b396..3a32fc447d00db9e09ce5d8093c6c4c5cb5bd682 100644 (file)
@@ -865,8 +865,16 @@ struct elf_backend_data
 
   /* This function, if defined, is called after all local symbols and
      global symbols converted to locals are emitted into the symtab
-     section.  It allows the backend to emit special global symbols
+     section.  It allows the backend to emit special local symbols
      not handled in the hash table.  */
+  bfd_boolean (*elf_backend_output_arch_local_syms)
+    (bfd *, struct bfd_link_info *, void *,
+     bfd_boolean (*) (void *, const char *, Elf_Internal_Sym *, asection *,
+                     struct elf_link_hash_entry *));
+
+  /* This function, if defined, is called after all symbols are emitted
+     into the symtab section.  It allows the backend to emit special
+     global symbols not handled in the hash table.  */
   bfd_boolean (*elf_backend_output_arch_syms)
     (bfd *, struct bfd_link_info *, void *,
      bfd_boolean (*) (void *, const char *, Elf_Internal_Sym *, asection *,
index 774be9c11074c19a6e7d13f8ad851bd85ff2467b..3a1b13912c677f2d8fb94063a7fcfd7b39c354b8 100644 (file)
@@ -7950,6 +7950,174 @@ elf32_arm_output_symbol_hook (struct bfd_link_info *info,
   return TRUE;
 }
 
+typedef struct
+{
+  void *finfo;
+  struct bfd_link_info *info;
+  int plt_shndx;
+  bfd_vma plt_offset;
+  bfd_boolean (*func) (void *, const char *, Elf_Internal_Sym *,
+                      asection *, struct elf_link_hash_entry *);
+} output_arch_syminfo;
+
+enum map_symbol_type
+{
+  ARM_MAP_ARM,
+  ARM_MAP_THUMB,
+  ARM_MAP_DATA
+};
+
+
+/* Output a single PLT mapping symbol.  */
+
+static bfd_boolean
+elf32_arm_ouput_plt_map_sym (output_arch_syminfo *osi,
+                            enum map_symbol_type type,
+                            bfd_vma offset)
+{
+  static const char *names[3] = {"$a", "$t", "$d"};
+  struct elf32_arm_link_hash_table *htab;
+  Elf_Internal_Sym sym;
+
+  htab = elf32_arm_hash_table (osi->info);
+  sym.st_value = osi->plt_offset + offset;
+  sym.st_size = 0;
+  sym.st_other = 0;
+  sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_NOTYPE);
+  sym.st_shndx = osi->plt_shndx;
+  if (!osi->func (osi->finfo, names[type], &sym, htab->splt, NULL))
+    return FALSE;
+  return TRUE;
+}
+
+
+/* Output mapping symbols for PLT entries associated with H.  */
+
+static bfd_boolean
+elf32_arm_output_plt_map (struct elf_link_hash_entry *h, void *inf)
+{
+  output_arch_syminfo *osi = (output_arch_syminfo *) inf;
+  struct elf32_arm_link_hash_table *htab;
+  struct elf32_arm_link_hash_entry *eh;
+  bfd_vma addr;
+
+  htab = elf32_arm_hash_table (osi->info);
+
+  if (h->root.type == bfd_link_hash_indirect)
+    return TRUE;
+
+  if (h->root.type == bfd_link_hash_warning)
+    /* When warning symbols are created, they **replace** the "real"
+       entry in the hash table, thus we never get to see the real
+       symbol in a hash traversal.  So look at it now.  */
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
+  if (h->plt.offset == (bfd_vma) -1)
+    return TRUE;
+
+  eh = (struct elf32_arm_link_hash_entry *) h;
+  addr = h->plt.offset;
+  if (htab->symbian_p)
+    {
+      if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_ARM, addr))
+       return FALSE;
+      if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_DATA, addr + 4))
+       return FALSE;
+    }
+  else if (htab->vxworks_p)
+    {
+      if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_ARM, addr))
+       return FALSE;
+      if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_DATA, addr + 8))
+       return FALSE;
+      if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_ARM, addr + 12))
+       return FALSE;
+      if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_DATA, addr + 20))
+       return FALSE;
+    }
+  else
+    {
+      bfd_boolean thumb_stub;
+
+      thumb_stub = eh->plt_thumb_refcount > 0 && !htab->use_blx;
+      if (thumb_stub)
+       {
+         if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_THUMB, addr - 4))
+           return FALSE;
+       }
+#ifdef FOUR_WORD_PLT
+      if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_ARM, addr))
+       return FALSE;
+      if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_DATA, addr + 12))
+       return FALSE;
+#else
+      /* A three-word PLT with no Thumb thunk contains only Arm code, 
+        so only need to output a mapping symbol for the first PLT entry and
+        entries with thumb thunks.  */
+      if (thumb_stub || addr == 20)
+       {
+         if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_ARM, addr))
+           return FALSE;
+       }
+#endif
+    }
+
+  return TRUE;
+}
+
+
+/* Output mapping symbols for the PLT.  */
+
+static bfd_boolean
+elf32_arm_output_arch_local_syms (bfd *output_bfd,
+    struct bfd_link_info *info,
+    void *finfo, bfd_boolean (*func) (void *, const char *,
+                                   Elf_Internal_Sym *,
+                                   asection *,
+                                   struct elf_link_hash_entry *))
+{
+  output_arch_syminfo osi;
+  struct elf32_arm_link_hash_table *htab;
+
+  htab = elf32_arm_hash_table (info);
+  if (!htab->splt || htab->splt->size == 0)
+    return TRUE;
+
+  check_use_blx(htab);
+  osi.finfo = finfo;
+  osi.info = info;
+  osi.func = func;
+  osi.plt_shndx = _bfd_elf_section_from_bfd_section (output_bfd,
+      htab->splt->output_section);
+  osi.plt_offset = htab->splt->output_section->vma;
+
+  /* Output mapping symbols for the plt header.  SymbianOS does not have a
+     plt header.  */
+  if (htab->vxworks_p)
+    {
+      /* VxWorks shared libraries have no PLT header.  */
+      if (!info->shared)
+       {
+         if (!elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_ARM, 0))
+           return FALSE;
+         if (!elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_DATA, 12))
+           return FALSE;
+       }
+    }
+  else if (!htab->symbian_p)
+    {
+      if (!elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_ARM, 0))
+       return FALSE;
+#ifndef FOUR_WORD_PLT
+      if (!elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_DATA, 16))
+       return FALSE;
+#endif
+    }
+
+  elf_link_hash_traverse (&htab->root, elf32_arm_output_plt_map, (void *) &osi);
+  return TRUE;
+}
+
 /* Allocate target specific section data.  */
 
 static bfd_boolean
@@ -8262,6 +8430,8 @@ const struct elf_size_info elf32_arm_size_info = {
 #define elf_backend_modify_segment_map         elf32_arm_modify_segment_map
 #define elf_backend_additional_program_headers \
   elf32_arm_additional_program_headers
+#define elf_backend_output_arch_local_syms \
+  elf32_arm_output_arch_local_syms
 
 #define elf_backend_can_refcount    1
 #define elf_backend_can_gc_sections 1
index f0a0e83cadad6753210500f179cc54608757f78f..8c1c3c14328fc29fbadd07d1d6897db0ab7f6595 100644 (file)
@@ -8255,6 +8255,19 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
   if (eoinfo.failed)
     return FALSE;
 
+  /* If backend needs to output some local symbols not present in the hash
+     table, do it now.  */
+  if (bed->elf_backend_output_arch_local_syms)
+    {
+      typedef bfd_boolean (*out_sym_func)
+       (void *, const char *, Elf_Internal_Sym *, asection *,
+        struct elf_link_hash_entry *);
+
+      if (! ((*bed->elf_backend_output_arch_local_syms)
+            (abfd, info, &finfo, (out_sym_func) elf_link_output_sym)))
+       return FALSE;
+    }
+
   /* That wrote out all the local symbols.  Finish up the symbol table
      with the global symbols. Even if we want to strip everything we
      can, we still need to deal with those global symbols that got
index 503726d2b8664fc61a348f452cf7e6c604cb2c88..10d055482e6bbfc929a31e05c6f9df7d255cc799 100644 (file)
 #ifndef elf_backend_print_symbol_all
 #define elf_backend_print_symbol_all           NULL
 #endif
+#ifndef elf_backend_output_arch_local_syms
+#define elf_backend_output_arch_local_syms     NULL
+#endif
 #ifndef elf_backend_output_arch_syms
 #define elf_backend_output_arch_syms           NULL
 #endif
@@ -598,6 +601,7 @@ static const struct elf_backend_data elfNN_bed =
   elf_backend_gc_sweep_hook,
   elf_backend_post_process_headers,
   elf_backend_print_symbol_all,
+  elf_backend_output_arch_local_syms,
   elf_backend_output_arch_syms,
   elf_backend_copy_indirect_symbol,
   elf_backend_hide_symbol,
index 9a4da22b33f786fc282d5897ccb20b955fe40ce6..c39816985416ceec2da0208f839fcc16ccbc8423 100644 (file)
@@ -8,7 +8,7 @@ Disassembly of section .plt:
 
 .* <.plt>:
     .*:        e52de004        str     lr, \[sp, #-4\]!
-    .*:        e59fe004        ldr     lr, \[pc, #4\]  ; .* <_start-0x10>
+    .*:        e59fe004        ldr     lr, \[pc, #4\]  ; .* <\.plt\+0x10>
     .*:        e08fe00e        add     lr, pc, lr
     .*:        e5bef008        ldr     pc, \[lr, #8\]!
     .*:        .*      .*
index 207961ea0fa318fcfeb354b0808f786c7f2f5b15..0cb52a955b5b59a9ad2bfa43d4231de3f4fd4be9 100644 (file)
@@ -8,7 +8,7 @@ Disassembly of section .plt:
 
 .* <.plt>:
  .*:   e52de004        str     lr, \[sp, #-4\]!
- .*:   e59fe004        ldr     lr, \[pc, #4\]  ; .* <_start-0x10>
+ .*:   e59fe004        ldr     lr, \[pc, #4\]  ; .* <\.plt\+0x10>
  .*:   e08fe00e        add     lr, pc, lr
  .*:   e5bef008        ldr     pc, \[lr, #8\]!
  .*:   .*
@@ -27,7 +27,7 @@ Disassembly of section .text:
 .* <app_func>:
  .*:   e1a0c00d        mov     ip, sp
  .*:   e92dd800        stmdb   sp!, {fp, ip, lr, pc}
- .*:   ebfffff4        bl      .* <_start-0xc>
+ .*:   ebfffff4        bl      .* <.text-0xc>
  .*:   e89d6800        ldmia   sp, {fp, sp, lr}
  .*:   e12fff1e        bx      lr
 
index 58206f43796cf38f365fe1401ba691dd1ea69471..96beabc8a5dd52482a1ac23c3823bc86a0dbc842 100644 (file)
@@ -8,7 +8,7 @@ Disassembly of section .plt:
 
 .* <.plt>:
  .*:   e52de004        str     lr, \[sp, #-4\]!
- .*:   e59fe004        ldr     lr, \[pc, #4\]  ; .* <lib_func1-0x10>
+ .*:   e59fe004        ldr     lr, \[pc, #4\]  ; .* <\.plt\+0x10>
  .*:   e08fe00e        add     lr, pc, lr
  .*:   e5bef008        ldr     pc, \[lr, #8\]!
  .*:   .*
@@ -20,7 +20,7 @@ Disassembly of section .text:
 .* <lib_func1>:
  .*:   e1a0c00d        mov     ip, sp
  .*:   e92dd800        stmdb   sp!, {fp, ip, lr, pc}
- .*:   ebfffff9        bl      .* <lib_func1-0xc>
+ .*:   ebfffff9        bl      .* <.text-0xc>
  .*:   e89d6800        ldmia   sp, {fp, sp, lr}
  .*:   e12fff1e        bx      lr
 
index e3257c955149610b6283952c147156c553195700..706a657241c4c41f8580ef0b0206fec4342a319d 100644 (file)
@@ -8,7 +8,7 @@ Disassembly of section .plt:
 
 .* <.plt>:
  .*:   e52de004        str     lr, \[sp, #-4\]!
- .*:   e59fe004        ldr     lr, \[pc, #4\]  ; .* <lib_func1-0x10>
+ .*:   e59fe004        ldr     lr, \[pc, #4\]  ; .* <\.plt\+0x10>
  .*:   e08fe00e        add     lr, pc, lr
  .*:   e5bef008        ldr     pc, \[lr, #8\]!
  .*:   .*
@@ -20,7 +20,7 @@ Disassembly of section .text:
 .* <lib_func1>:
  .*:   e1a0c00d        mov     ip, sp
  .*:   e92dd800        stmdb   sp!, {fp, ip, lr, pc}
- .*:   ebfffff9        bl      .* <lib_func1-0xc>
+ .*:   ebfffff9        bl      .* <.text-0xc>
  .*:   e89d6800        ldmia   sp, {fp, sp, lr}
  .*:   e12fff1e        bx      lr
 
index 9e8d4dd194bf5cac28c8988ab23801b2d6ec07cf..73fa9ec83b4f8772255d84130161845fdcd6a2a4 100644 (file)
@@ -8,7 +8,7 @@ Disassembly of section .plt:
 
 .* <.plt>:
  .*:   e52de004        str     lr, \[sp, #-4\]!
- .*:   e59fe004        ldr     lr, \[pc, #4\]  ; .* <_start-0x20>
+ .*:   e59fe004        ldr     lr, \[pc, #4\]  ; .* <\.plt\+0x10>
  .*:   e08fe00e        add     lr, pc, lr
  .*:   e5bef008        ldr     pc, \[lr, #8\]!
  .*:   .*
@@ -48,7 +48,7 @@ Disassembly of section .text:
 
 .* <app_tfunc>:
  .*:   b500            push    {lr}
- .*:   f7ff efc.       blx     .* <_start-0x..>
+ .*:   f7ff efc.       blx     .* <.text-0x..>
  .*:   bd00            pop     {pc}
  .*:   4770            bx      lr
  .*:   46c0            nop                     \(mov r8, r8\)
index 381222727e692f4c25163d83228c855f2f4c17b3..7893a33d3da165baed443ba371ecc284b4b3b74e 100644 (file)
@@ -8,7 +8,7 @@ Disassembly of section .plt:
 
 .* <.plt>:
  .*:   e52de004        str     lr, \[sp, #-4\]!
- .*:   e59fe004        ldr     lr, \[pc, #4\]  ; .* <_start-0x20>
+ .*:   e59fe004        ldr     lr, \[pc, #4\]  ; .* <\.plt\+0x10>
  .*:   e08fe00e        add     lr, pc, lr
  .*:   e5bef008        ldr     pc, \[lr, #8\]!
  .*:   .*
@@ -49,7 +49,7 @@ Disassembly of section .text:
 
 .* <app_tfunc>:
  .*:   b500            push    {lr}
- .*:   f7ff ffc.       bl      .* <_start-0x..>
+ .*:   f7ff ffc.       bl      .* <.text-0x..>
  .*:   bd00            pop     {pc}
  .*:   4770            bx      lr
  .*:   46c0            nop                     \(mov r8, r8\)
index b261c67fae28353086aef3df60baffd070c49214..0c426f36c72c22465271952746bf08ac28c8d337 100644 (file)
@@ -8,7 +8,7 @@ Disassembly of section .plt:
 
 .* <.plt>:
  .*:   e52de004        str     lr, \[sp, #-4\]!
- .*:   e59fe004        ldr     lr, \[pc, #4\]  ; .* <lib_func1-0x1.>
+ .*:   e59fe004        ldr     lr, \[pc, #4\]  ; .* <\.plt\+0x10>
  .*:   e08fe00e        add     lr, pc, lr
  .*:   e5bef008        ldr     pc, \[lr, #8\]!
  .*:   .*
@@ -20,7 +20,7 @@ Disassembly of section .text:
 .* <lib_func1>:
  .*:   e1a0c00d        mov     ip, sp
  .*:   e92dd800        stmdb   sp!, {fp, ip, lr, pc}
- .*:   ebfffff.        bl      .* <lib_func1-0x..>
+ .*:   ebfffff.        bl      .* <.text-0x..>
  .*:   e89d6800        ldmia   sp, {fp, sp, lr}
  .*:   e12fff1e        bx      lr
  .*:   e1a00000        nop                     \(mov r0,r0\)