* Support code for enabling the new style linker for PA ELF.
authorJeff Law <law@redhat.com>
Fri, 1 Jul 1994 19:00:17 +0000 (19:00 +0000)
committerJeff Law <law@redhat.com>
Fri, 1 Jul 1994 19:00:17 +0000 (19:00 +0000)
* elfcode.h (swap_symbol_in, swap_symbol_out): Externalize.
(elf_compute_section_file_positions): Pass link_info to
the begin_write_processing hook.
(bfd_elf_write_object_contents): Pass NULL for new link_info
argument to final_write_processing hook.
(elf_link_output_sym): Accept new "input_section" argument for
the symbols's input section.  All callers changed.  Call the
link_output_symbol_hook if it's defined.
(elf_bfd_final_link): Call the final_write_processing hook if
it's defined.
* libelf.h (elf_backend_link_output_symbol_hook): Declare.
(elf_backend_begin_write_processing): Add new "info" argument.
(elf_backend_final_write_processing): Likewise.
* elf32-target.h (elf_backend_link_output_symbol_hook): Provide
a default definition.
(elf32_bed): Add elf_backend_link_output_symbol_hook.
* elf64-target.h: Likewise.

* Major rework of the PA ELF code.  Uses the new style BFD
linker, major cleanups.
* hppa_stubs.h: Rewrite from scratch.  Much smaller and simpler.
* elf32-hppa.h: Delete all symbol extension related code.
(hppa_look_for_stubs_in_section): Delete decl.
(elf32_hppa_size_stubs, elf32_hppa_build_stubs): New decls.
* elf32-hppa.c: Symbol extension stuff moved form elf32-hppa.h
into elf32-hppa.c.  Do not include aout64.h.
(typdef hppa_stub_type): Delete.
(elf32_hppa_stub_name_list_struct): Delete.
(elf32_hppa_stub_description_struct): Delete.
(arg_reloc_type): Use simpler enumerations.  All references changed.
(arg_location, arg_reloc_relocation): Likewise.
(elf32_hppa_symextn_map_struct): Delete.
(get_symbol_value): Delete.
(elf32_hppa_get_sym_extn): Delete.
(find_stubs, new_stubs, type_of_mismatch): Delete.
(find_stub_by_name, add_stub_by_name): Delete.
(hppa_elf_stub_finish, hppa_elf_stub_reloc): Delete.
(hppa_elf_arg_reloc_needed): Renamed.  Simplify.
(hppa_elf_build_linker_stub, hppa_elf_create_stub_sec): Delete.
(hppa_elf_long_branch_needed_p): Delete.
(hppa_look_for_stubs_in_section): Delete.
(hppa_elf_get_section_contents): Delete.
(elf32_hppa_backend_symbol_processing): Delete.
(elf32_hppa_backend_section_processing): Delete.
(elf32_hppa_backend_section_from_shdr): Delete.
(elf32_hppa_backend_fake_sections): Delete.
(elf32_hppa_backend_section_from_bfd_section): Delete.
(NEW_INSTRUCTION): Delete.
(CURRENT_STUB_OFFSET): Delete.
(elf32_hppa_relocate_section): New function.
(elf32_hppa_bfd_final_link_relocate): New function.
(elf32_hppa_size_symext): New function.
(elf32_hppa_link_output_symbol_hook): New function.
(elf32_hppa_read_symext_info): New function.
(elf32_hppa_add_symbol_hook): New function.
(elf32_hppa_name_of_stub): New function.
(elf32_hppa_size_of_stub): New function.
(elf32_hppa_build_one_sub): New function.
(elf32_hppa_build_stubs): New function.
(elf32_hppa_size_stubs): New function.
(linker, stub and argument hash tables): Add appropriate
structures, definitions and functions to implement all three
hash tables.
(hppa_elf_relocate_insn): Don't need argument location information
in this function.
(add_entry_to_symext_chain): Accept a symbol's argument location
information rather than the symbol itself.  All callers changed.
(hppa_elf_gen_reloc_type): Simplify.
(hppa_elf_set_section_contents): Stub section is no longer special.
(hppa_elf_reloc): Greatly simplify.
(elf32_hppa_begin_write_processing): Accept link_info argument.
Handle being called from the BFD backend linker.
(elf32_hppa_final_write_processing): Likewise.
(elf_hppa_tc_make_sections): No longer call stub_finish.

bfd/elf32-target.h
bfd/elf64-target.h
bfd/hppa_stubs.h
bfd/libelf.h

index 707b00740dc09114adc3d4894cae8ae5c6698577..67dabecc71fe9b73e1bb708355a11829fc0dd942 100644 (file)
@@ -115,6 +115,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #ifndef elf_backend_add_symbol_hook
 #define elf_backend_add_symbol_hook    0
 #endif
+#ifndef elf_backend_link_output_symbol_hook
+#define elf_backend_link_output_symbol_hook 0
+#endif
 #ifndef elf_backend_create_dynamic_sections
 #define elf_backend_create_dynamic_sections 0
 #endif
@@ -166,6 +169,7 @@ static CONST struct elf_backend_data elf32_bed =
   elf_backend_fake_sections,
   elf_backend_section_from_bfd_section,
   elf_backend_add_symbol_hook,
+  elf_backend_link_output_symbol_hook,
   elf_backend_create_dynamic_sections,
   elf_backend_adjust_dynamic_symbol,
   elf_backend_size_dynamic_sections,
index 0a87080997ee345aea88463c767228b96e4428a3..a85b5d0d3a70eb3f37dec4c9f91024cd23fd0f4d 100644 (file)
@@ -118,6 +118,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #ifndef elf_backend_add_symbol_hook
 #define elf_backend_add_symbol_hook    0
 #endif
+#ifndef elf_backend_link_output_symbol_hook
+#define elf_backend_link_output_symbol_hook 0
+#endif
 #ifndef elf_backend_create_dynamic_sections
 #define elf_backend_create_dynamic_sections 0
 #endif
@@ -169,6 +172,7 @@ static CONST struct elf_backend_data elf64_bed =
   elf_backend_fake_sections,
   elf_backend_section_from_bfd_section,
   elf_backend_add_symbol_hook,
+  elf_backend_link_output_symbol_hook,
   elf_backend_create_dynamic_sections,
   elf_backend_adjust_dynamic_symbol,
   elf_backend_size_dynamic_sections,
index 3c68db76ffc42d6cc06f2ed92fedae8adbcd154e..ee893e8a57bb56692668b5961c5c5d216e613362 100644 (file)
@@ -1,61 +1,23 @@
 /* HPPA linker stub instructions  */
 
-/* Maximum size of a single stub routine in bytes.  */
-#define STUB_MAX_SIZE  (sizeof(int) * 20)
-
-/* When realloc'ing, use this size ?!? FIXME, what are these?  */
-#define STUB_BUFFER_INCR       (STUB_MAX_SIZE * 20)
-#define STUB_RELOC_INCR        20
-
 /* These are the instructions which the linker may insert into the
    code stream when building final executables to handle out-of-range
    calls and argument relocations.  */
 
-#define ADDI_8_SP              0xb7de0010      /* addi        8,sp,sp */
-#define STW_RP_M8SP            0x6bc23ff1      /* stw         rp,-8(sp) */
-#define STWS_ARG0_M8SP         0x0fda1291      /* stws        arg0,-8(sp) */
-#define STWS_ARG1_M8SP         0x0fd91291      /* stws        arg1,-8(sp) */
-#define STWS_ARG2_M8SP         0x0fd81291      /* stws        arg2,-8(sp) */
-#define STWS_ARG3_M8SP         0x0fd71291      /* stws        arg3,-8(sp) */
-#define STWS_ARG0_M4SP         0x0fda1299      /* stws        arg0,-4(sp) */
-#define STWS_ARG2_M4SP         0x0fd81299      /* stws        arg2,-4(sp) */
-#define FSTWS_FARG0_M8SP       0x27d11204      /* fstws       farg0,-8(sp) */
-#define FSTWS_FARG1_M8SP       0x27d11205      /* fstws       farg1,-8(sp) */
-#define FSTWS_FARG2_M8SP       0x27d11206      /* fstws       farg2,-8(sp) */
-#define FSTWS_FARG3_M8SP       0x27d11207      /* fstws       farg3,-8(sp) */
-#define FSTDS_FARG1_M8SP       0x2fd11205      /* fstds       farg1,-8(sp) */
-#define FSTDS_FARG3_M8SP       0x2fd11207      /* fstds       farg3,-8(sp) */
-#define STWS_RET0_M8SP         0x0fda1291      /* stws        arg0,-8(sp) */
-#define FSTWS_FRET0_M8SP       0x27d11204      /* fstws       fret0,-8(sp) */
-#define LDWS_M8SP_ARG1         0x0fd11099      /* ldws        -8(sp),arg1 */
-#define LDWS_M8SP_ARG3         0x0fd11097      /* ldws        -8(sp),arg3 */
-#define LDWS_M4SP_ARG0         0x0fd9109a      /* ldws        -4(sp),arg0 */
-#define LDWS_M4SP_ARG1         0x0fd91099      /* ldws        -4(sp),arg1 */
-#define LDWS_M4SP_ARG2         0x0fd91098      /* ldws        -4(sp),arg2 */
-#define LDWS_M4SP_ARG3         0x0fd91097      /* ldws        -4(sp),arg3 */
-#define FLDWS_M8SP_FARG0       0x27d11004      /* fldws       -8(sp),farg0 */
-#define FLDWS_M8SP_FARG1       0x27d11005      /* fldws       -8(sp),farg1 */
-#define FLDWS_M8SP_FARG2       0x27d11006      /* fldws       -8(sp),farg2 */
-#define FLDWS_M8SP_FARG3       0x27d11007      /* fldws       -8(sp),farg3 */
-#define FLDDS_M8SP_FARG1       0x2fd11005      /* fldds       -8(sp),farg1 */
-#define FLDDS_M8SP_FARG3       0x2fd11007      /* fldds       -8(sp),farg3 */
-#define LDWS_M4SP_RET0         0x0fd9109c      /* ldws        -4(sp),ret0 */
-#define FLDWS_M8SP_FRET0       0x27d11004      /* fldws       -8(sp),fret0 */
-#define BLE_XXX_0_0            0xe4000000      /* ble         0(sr0,0) */
-#define BLE_N_XXX_0_0          0xe4000002      /* ble,n       0(sr0,0) */
-#define BLE_XXX_0_31           0xe7e00000      /* ble         0(sr0,r31) */
-#define BLE_N_XXX_0_31         0xe7e00002      /* ble,n       0(sr0,r31) */
-#define BE_N_XXX_0_31          0xe3e00002      /* be,n        0(sr0,r31) */
-#define BE_XXX_0_31            0xe3e00000      /* be          0(sr0,r31) */
-#define COPY_31_2              0x081f0242      /* copy        r31,r2 */
-#define COPY_31_1              0x081f0241      /* copy        r31,r1 */
-#define COPY_1_31              0x0801025f      /* copy        r1,r31 */
-#define COPY_2_31              0x0802025f      /* copy        r2,r31 */
-#define LDIL_XXX_31            0x23e00000      /* ldil        0,r31 */
-#define LDSID_31_1             0x03e010a1      /* ldsid       (r31),r1 */
-#define MTSP_1_SR0             0x00011820      /* mtsp        r1,sr0 */
-#define ADDI_M4_31_RP          0xb7e207f9      /* addi        -4,r31,rp */
-#define ADDI_M4_31_1           0xb7e107f9      /* addi        -4,r31,r1 */
-#define ADDI_M8_SP_SP          0xb7de07f1      /* addi        -8,sp,sp */
-#define LDW_M8SP_RP            0x4bc23ff1      /* ldw         -8(sp),rp */
-#define BV_N_0_RP              0xe840c002      /* bv,n        0(rp) */
+#define LDO_M4_R31_R31         0x37ff3ff9      /* ldo -4(%r31),%r31      */
+#define LDIL_R1                        0x20200000      /* ldil XXX,%r1           */
+#define BE_SR4_R1              0xe0202000      /* be XXX(%sr4,%r1)       */
+#define COPY_R31_R2            0x081f0242      /* copy %r31,%r2          */
+#define BLE_SR4_R0             0xe4002000      /* ble XXX(%sr4,%r0)      */
+#define BLE_SR4_R1             0xe4202000      /* ble XXX(%sr4,%r1)      */
+#define BV_N_0_R31             0xebe0c002      /* bv,n 0(%r31)           */
+#define STW_R31_M8R30          0x6bdf3ff1      /* stw %r31,-8(%r30)      */
+#define LDW_M8R30_R31          0x4bdf3ff1      /* ldw -8(%r30),%r31      */
+#define STW_ARG_M16R30         0x6bc03fe1      /* stw %argX,-16(%r30)    */
+#define LDW_M16R30_ARG         0x4bc03fe1      /* ldw -12(%r30),%argX    */
+#define STW_ARG_M12R30         0x6bc03fe9      /* stw %argX,-16(%r30)    */
+#define LDW_M12R30_ARG         0x4bc03fe9      /* ldw -12(%r30),%argX    */
+#define FSTW_FARG_M16R30       0x27c11200      /* fstws %fargX,-16(%r30) */
+#define FLDW_M16R30_FARG       0x27c11000      /* fldws -16(%r30),%fargX */
+#define FSTD_FARG_M16R30       0x2fc11200      /* fstds %fargX,-16(%r30) */
+#define FLDD_M16R30_FARG       0x2fc11000      /* fldds -16(%r30),%fargX */
index 05226272b072eb13508935a9d383c191bb29e121..14211814a687b36c96db4572460c9758945460e7 100644 (file)
@@ -257,6 +257,12 @@ struct elf_backend_data
             const Elf_Internal_Sym *, const char **name,
             flagword *flags, asection **sec, bfd_vma *value));
 
+  /* If this field is not NULL, it is called by the elf_link_output_sym
+     phase of a link for each symbol which will appear in the object file.  */
+  boolean (*elf_backend_link_output_symbol_hook)
+    PARAMS ((bfd *, struct bfd_link_info *info, const char *,
+            Elf_Internal_Sym *, asection *));
+
   /* The CREATE_DYNAMIC_SECTIONS function is called by the ELF backend
      linker the first time it encounters a dynamic object in the link.
      This function must create any sections required for dynamic
@@ -349,11 +355,13 @@ struct elf_backend_data
 
   /* A function to do any beginning processing needed for the ELF file
      before building the ELF headers and computing file positions.  */
-  void (*elf_backend_begin_write_processing) PARAMS ((bfd *));
+  void (*elf_backend_begin_write_processing)
+    PARAMS ((bfd *, struct bfd_link_info *));
 
   /* A function to do any final processing needed for the ELF file
      before writing it out.  */
-  void (*elf_backend_final_write_processing) PARAMS ((bfd *));
+  void (*elf_backend_final_write_processing)
+    PARAMS ((bfd *, struct bfd_link_info *));
 
   /* The swapping table to use when dealing with ECOFF information.
      Used for the MIPS ELF .mdebug section.  */