From e2a422b84ccaa359e7fcbe8142406f7eaf99e484 Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Wed, 25 Aug 1993 01:15:07 +0000 Subject: [PATCH] Merged in changes from Jeff Law and Pete Hoogenboom at Utah for PA ELF support. Compiles, not particularly well tested. See ChangeLog for details. --- bfd/ChangeLog | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++ bfd/elf32-target.h | 25 +++++++++++++ bfd/hosts/hppabsd.h | 2 +- bfd/hppa.c | 2 +- bfd/hppa_stubs.h | 35 ++++++++++++++++- bfd/libelf.h | 9 ++++- 6 files changed, 175 insertions(+), 4 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index f231446..b961cb8 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,109 @@ +Tue Aug 24 16:32:35 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + Merged changes from Jeff Law and Pete Hoogenboom at Utah: + + * elfcode.h (elf_section_from_bfd_section): Add detection of + SHT_NOTE sections. + + * elf32-hppa.c: + (hppa_elf_build_long_branch_stub,hppa_elf_long_branch_needed_p): + New functions for support of long branch stubs. + (hppa_elf_stub_check,hppa_look_for_stubs_in_section): Add + check for long branch stubs. + (hppa_look_for_stubs): Unused function. Removed. + (hppa_elf_set_section_contents): Implement a PA/ELF-specific + version of bfd_set_section_contents. + (hppa_elf_long_branch_needed_p): Only output debugging diagnostics + when BFD is configured for debugging. + + * elf32-hppa.c: (elf32_hppa_get_symextn_chain): New function + to return a list of symbols that have non-zero argument + relocation bits. + (hppa_elf_stub_finish): Make sure stub generation is done only + once. + + * elf32-hppa.c: (hppa_elf_stub_reloc): New function for + generation relocation entries within a stub. + (hppa_elf_build_arg_reloc_stub): Corrections to argument + relocation stubs. + + * elf32-hppa.c: New #define's for argument relocation types. + (mismatches, retval_mismatches): Updated to reflect new + argument relocation types. + (CURRENT_STUB_OFFSET): New macro. + + * elfcode.h (map_program_segments): Set the PF_X bit for data + segments. + + * elf32-hppa.c: (elf_hppa_howto_table): Add + R_HPPA_STUB_CALL_17 for support of linker stub generation. + (hppa_elf_reloc): Add support of R_HPPA_STUB_CALL_17 + relocation type. + + * elf32-hppa.h: (elf32_hppa_reloc_type): Add + R_HPPA_STUB_CALL_17 for support of linker stub generation. + + * hppa_stubs.h: Add new instructions that are used in linker + stub generation. + + * elf32-hppa.c (hppa_elf_relocate_unwind_table): The offsets in an + unwind descriptor were incorrect. + + * libelf.h (bfd_elf_find_section): Declare. + + * elf32-hppa.c: (elf32_hppa_backend_symbol_processing): New + function in place of global_sym field in elf_backend_data + structure. + (elf32_hppa_backend_symbol_table_processing, + elf32_hppa_backend_section_processing, + elf32_hppa_backend_fake_sections, + elf32_hppa_backend_section_from_shdr, + elf32_hppa_backend_section_from_bfd_section): New functions to + provide support of symbol extension sections and argument + relocation stubs. + (elf_info_to_howto): Remove call to abort(). + + * elf32-target.h: Support for special processing by the backend. + (struct elf_backend_data): Added elf_backend_symbol_processing, + elf_backend_symbol_table_processing, + elf_backend_section_processing, elf_backend_section_from_shdr, + elf_backend_fake_sections, and + elf_backend_section_from_bfd_section fields. + * elfcode.h: (bfd_section_from_shdr): Add a check for + processor-specific section types. + (elf_fake_sections): Add a check for processor-specific + section types. + (bfd_elf32_write_object_contents): Add a check to see if + there is any final section processing to be done by the + backend. + (elf_section_from_bfd_section): Add a check for + processor-specific section types. + (elf_slurp_symbol_table): Remove reference to global_sym in the + elf_backend_data structure. Replace it with a call to + elf_backend_symbol_processing. + * libelf.h: Remove global_sym field in the elf_backend_data + structure. Replace it with a series of backend-specific + functions. + + * elf32-hppa.c (hppa_elf_stub_branch_reloc): The formal argument + stub_sym should be called target_sym. + (hppa_elf_build_arg_reloc_stub): Refer to the stub bfd (abfd) + rather than the output bfd (output_bfd). + (hppa_elf_reloc): Get rid of references to the global_sym field in + the elf_backend_data structure. + + * elfcode.h (elf_fake_sections): Check the correct condition for + .bss. Also, detect the existence of a .note section. + + * elf32-hppa.c (hppa_elf_relocate_insn): r_format argument should + have been r_field. + + * hosts/hppabsd.h (HOST_MACHINE_ARCH): Reference to bfd_arch_m68k + should be a reference to bfd_arch_hppa. + + * hppa.c (hppa_vec): Replace bfd_false with _bfd_dummy_target in + the bfd_check_format structure to avoid a type mismatch. + Mon Aug 23 1993 Sean Fagan (sef@cygnus.com) and Jim Kingdon (kingdon@cygnus.com) diff --git a/bfd/elf32-target.h b/bfd/elf32-target.h index abc406f..27bad81 100644 --- a/bfd/elf32-target.h +++ b/bfd/elf32-target.h @@ -59,6 +59,25 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define ELF_MAXPAGESIZE 1 #endif +#ifndef elf_backend_symbol_processing +#define elf_backend_symbol_processing 0 /* elf_backend_symbol_processing */ +#endif +#ifndef elf_backend_symbol_table_processing +#define elf_backend_symbol_table_processing 0 /* elf_backend_symbol_table_processing */ +#endif +#ifndef elf_backend_section_processing +#define elf_backend_section_processing 0 /* elf_backend_section_processing */ +#endif +#ifndef elf_backend_section_from_shdr +#define elf_backend_section_from_shdr 0 /* elf_backend_section_from_shdr */ +#endif +#ifndef elf_backend_fake_sections +#define elf_backend_fake_sections 0 /* elf_backend_fake_sections */ +#endif +#ifndef elf_backend_section_from_bfd_section +#define elf_backend_section_from_bfd_section 0 /* elf_backend_section_from_bfd_section */ +#endif + static CONST struct elf_backend_data elf32_bed = { #ifdef USE_REL @@ -72,6 +91,12 @@ static CONST struct elf_backend_data elf32_bed = elf_info_to_howto_rel, /* elf_info_to_howto_rel */ ELF_MAXPAGESIZE, /* maxpagesize */ bfd_elf32__write_relocs, /* write_relocs */ + elf_backend_symbol_processing, /* elf_backend_symbol_processing */ + elf_backend_symbol_table_processing, /* elf_backend_symbol_table_processing */ + elf_backend_section_processing, /* elf_backend_section_processing */ + elf_backend_section_from_shdr, /* elf_backend_section_from_shdr */ + elf_backend_fake_sections, /* elf_backend_fake_sections */ + elf_backend_section_from_bfd_section, /* elf_backend_section_from_bfd_section */ }; #ifdef TARGET_BIG_SYM diff --git a/bfd/hosts/hppabsd.h b/bfd/hosts/hppabsd.h index db35a85..534ec4e 100644 --- a/bfd/hosts/hppabsd.h +++ b/bfd/hosts/hppabsd.h @@ -26,7 +26,7 @@ extern void free PARAMS ((PTR)); #define HOST_PAGE_SIZE NBPG #define HOST_SEGMENT_SIZE NBPG /* Data seg start addr rounds to NBPG */ -#define HOST_MACHINE_ARCH bfd_arch_m68k +#define HOST_MACHINE_ARCH bfd_arch_hppa /* #define HOST_MACHINE_MACHINE */ #define HOST_TEXT_START_ADDR UTEXTSEG diff --git a/bfd/hppa.c b/bfd/hppa.c index 2613573..eff6b66 100644 --- a/bfd/hppa.c +++ b/bfd/hppa.c @@ -940,7 +940,7 @@ bfd_target hppa_vec = {_bfd_dummy_target, hppa_object_p, /* bfd_check_format */ bfd_generic_archive_p, - bfd_false + _bfd_dummy_target }, { bfd_false, diff --git a/bfd/hppa_stubs.h b/bfd/hppa_stubs.h index dfe7068..2e4111d 100644 --- a/bfd/hppa_stubs.h +++ b/bfd/hppa_stubs.h @@ -10,20 +10,33 @@ #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_ARG0 0x0fd1109a /* ldws -8(sp),arg0 */ #define LDWS_M8SP_ARG1 0x0fd11099 /* ldws -8(sp),arg1 */ #define LDWS_M8SP_ARG2 0x0fd11098 /* ldws -8(sp),arg2 */ #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_FARG0 0x2fd11004 /* fldds -8(sp),farg0 */ +#define FLDDS_M8SP_FARG1 0x2fd11005 /* fldds -8(sp),farg1 */ +#define FLDDS_M8SP_FARG2 0x2fd11006 /* fldds -8(sp),farg2 */ +#define FLDDS_M8SP_FARG3 0x2fd11007 /* fldds -8(sp),farg3 */ +#define LDWS_M4SP_RET0 0x0fd9109c /* ldws -4(sp),ret0 */ #define LDWS_M8SP_RET0 0x0fd1109c /* ldws -8(sp),ret0 */ #define FLDWS_M8SP_FRET0 0x27d11004 /* fldws -8(sp),fret0 */ #define STWS_MA_ARG0_8SP 0x0fda12b0 /* stws,ma arg0,8(sp) */ @@ -44,6 +57,26 @@ #define FLDWS_MB_M8SP_FARG3 0x27d13027 /* fldws,mb -8(sp),farg3 */ #define BL_XXX_RP 0xe8400000 /* bl 0,rp */ #define NOP 0x08000240 /* nop */ -#define SUBI_8_SP 0x97de0010 /* subi 8,sp,sp */ +#define STW_31_M24SP 0x6bdf3fd1 /* stw r31,-24(sr0,sp) */ +#define LDW_M24SP_RP 0x4bc23fd1 /* ldw -24(sr0,sp),rp */ +#define BE_XXX_0_0 0xe0000000 /* be 0(sr0,0) */ +#define BE_N_XXX_0_0 0xe0000002 /* be,n 0(sr0,0) */ +#define BLE_XXX_0_0 0xe4000000 /* ble 0(sr0,0) */ +#define BLE_N_XXX_0_0 0xe4000002 /* ble,n 0(sr0,0) */ +#define BLE_N_XXX_0_31 0xe7e00002 /* ble,n 0(sr0,r31) */ +#define BLE_XXX_0_31 0xe7e00000 /* ble 0(sr0,r31) */ +#define BE_N_XXX_0_31 0xe3e00002 /* be,n 0(sr0,r31) */ +#define BE_N_XXX_0_RP 0xe0400002 /* be,n 0(sr0,rp) */ +#define BE_XXX_0_RP 0xe0400000 /* be 0(sr0,rp) */ +#define BLE_XXX_0_RP 0xe4400000 /* ble 0(sr0,rp) */ +#define COPY_31_2 0x081f0242 /* copy r31,r2 */ +#define LDIL_XXX_31 0x23e00000 /* ldil 0,r31 */ +#define LDIL_XXX_RP 0x20400000 /* ldil 0,rp */ +#define LDO_0_26_26 0x375a0000 /* ldo 0(r26),r26 */ +#define LDSID_31_RP 0x03e010a2 /* ldsid (r31),rp */ +#define MTSP_RP_SR0 0x00021820 /* mtsp rp,sr0 */ +#define LDO_0_26_26 0x375a0000 /* ldo 0(r26),r26 */ +#define ADDI_M8_SP 0xb7de07f1 /* addi -8,sp,sp */ #define LDW_M8SP_RP 0x4bc23ff1 /* ldw -8(sp),rp */ #define BV_N_0RP 0xe840c002 /* bv,n 0(rp) */ +#define BV_N_0_26 0xeb40c002 /* bv,n 0(r26) */ diff --git a/bfd/libelf.h b/bfd/libelf.h index f5bc2c8..2dca4a4 100644 --- a/bfd/libelf.h +++ b/bfd/libelf.h @@ -95,7 +95,12 @@ struct elf_backend_data the output BFD. If not, put a comment here explaining why. */ /* @@ Was pointer to elfNAME(symbol_type). This makes it size- independent. */ - PTR global_sym; + void (*elf_backend_symbol_processing) PARAMS ((bfd *, asymbol *)); + boolean (*elf_backend_symbol_table_processing) PARAMS ((bfd *, elf32_symbol_type *, int)); + boolean (*elf_backend_section_processing) PARAMS ((bfd *, Elf32_Internal_Shdr *)); + boolean (*elf_backend_section_from_shdr) PARAMS ((bfd *, Elf32_Internal_Shdr *, char *)); + boolean (*elf_backend_fake_sections) PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *)); + boolean (*elf_backend_section_from_bfd_section) PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *)); }; struct elf_sym_extra @@ -193,6 +198,8 @@ extern bfd_reloc_status_type bfd_elf_generic_reloc PARAMS ((bfd *, asection *, bfd *)); extern boolean bfd_elf_mkobject PARAMS ((bfd *)); +extern Elf_Internal_Shdr *bfd_elf_find_section PARAMS ((bfd *, char *)); + extern boolean bfd_elf32_write_object_contents PARAMS ((bfd *)); extern boolean bfd_elf64_write_object_contents PARAMS ((bfd *)); -- 2.7.4