diff options
author | Cl?ment Chigot <clement.chigot@atos.net> | 2022-04-20 15:11:47 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2022-04-20 15:11:47 +0100 |
commit | 2d23f9656c3fd92335683188d26db198fe2ed3ec (patch) | |
tree | d3c564dca842f9bbd216e2e05c3f03ac86eadf95 /bfd/libxcoff.h | |
parent | 1876a542175ef438d6aaafeccb479024994b938d (diff) | |
download | gdb-2d23f9656c3fd92335683188d26db198fe2ed3ec.zip gdb-2d23f9656c3fd92335683188d26db198fe2ed3ec.tar.gz gdb-2d23f9656c3fd92335683188d26db198fe2ed3ec.tar.bz2 |
xcoff: implement linker relaxation
bfd/ChangeLog:
* coff-rs6000.c (xcoff_reloc_type_noop): Add info argument.
(xcoff_reloc_type_fail): Likewise.
(xcoff_reloc_type_pos): Likewise.
(xcoff_reloc_type_neg): Likewise.
(xcoff_reloc_type_rel): Likewise.
(xcoff_reloc_type_toc): Likewise.
(xcoff_reloc_type_ba): Likewise.
(xcoff_reloc_type_crel): Likewise.
(xcoff_reloc_type_tls): Likewise.
(xcoff_reloc_type_br): Add stub handler.
(xcoff_ppc_relocate_section): Add info to
xcoff_calculate_relocation.
(xcoff_stub_indirect_call_code): New constant.
(xcoff_stub_shared_call_code): Likewise.
(bfd_xcoff_backend_data): Add stub code fields.
(bfd_pmac_xcoff_backend_data): Likewise.
* coff64-rs6000.c (xcoff64_reloc_type_br): Add stub handler.
(xcoff64_ppc_relocate_section): Add info to
xcoff64_calculate_relocation.
(xcoff64_stub_indirect_call_code): New constant.
(xcoff64_stub_shared_call_code): Likewise.
(bfd_xcoff_backend_data): Add stub code fields.
(bfd_xcoff_aix5_backend_data): Likewise.
* libxcoff.h (struct xcoff_backend_data_rec): Add stub fields.
(bfd_xcoff_stub_indirect_call_code): New define.
(bfd_xcoff_stub_indirect_call_size): New define.
(bfd_xcoff_stub_shared_call_code): New define.
(bfd_xcoff_stub_shared_call_size): New define.
(xcoff_reloc_function): Add info argument.
(enum xcoff_stub_type): New enum.
(struct xcoff_stub_hash_entry): New structure.
* xcofflink.c (struct xcoff_link_hash_table): Add stub hash
table and params fields.
(xcoff_stub_hash_entry): New define.
(xcoff_stub_hash_lookup): New define.
(stub_hash_newfunc): New function.
(_bfd_xcoff_bfd_link_hash_table_free): Free the new stub hash
table.
(_bfd_xcoff_bfd_link_hash_table_create): Create the new stub
hash table.
(xcoff_link_add_symbols): Save rawsize for XTY_SD.
(bfd_xcoff_link_init): New function.
(xcoff_stub_csect_name): New function.
(xcoff_stub_get_csect_in_range): New function.
(xcoff_stub_name): New function.
(bfd_xcoff_get_stub_entry): New function.
(bfd_xcoff_type_of_stub): New function.
(xcoff_add_stub): New function.
(xcoff_build_one_stub): New function.
(bfd_xcoff_size_stubs): New function.
(bfd_xcoff_build_stubs): New function.
(xcoff_stub_create_relocations): New function.
(xcoff_link_input_bfd): Adapt relocations to stub.
(xcoff_write_global_symbol): Adapt to new TOC entries generated
for stubs.
(_bfd_xcoff_bfd_final_link): Handle stub file.
* xcofflink.h (struct bfd_xcoff_link_params): New structure.
ld/ChangeLog:
* emultempl/aix.em (params): New variable.
(stub_file): New variable.
(xcoff_add_stub_section): New function.
(xcoff_layout_sections_again): New function
(hook_in_stub): New function.
(_after_allocation): Add stub creation.
(_create_output_section_statements): Allocate stub file and
pass params to backend.
Diffstat (limited to 'bfd/libxcoff.h')
-rw-r--r-- | bfd/libxcoff.h | 63 |
1 files changed, 58 insertions, 5 deletions
diff --git a/bfd/libxcoff.h b/bfd/libxcoff.h index 2a71ee5..c6ad6dc 100644 --- a/bfd/libxcoff.h +++ b/bfd/libxcoff.h @@ -99,6 +99,15 @@ struct xcoff_backend_data_rec unsigned int _xcoff_rtinit_size; bool (*_xcoff_generate_rtinit) (bfd *, const char *, const char *, bool); + + /* Stubs code generation. + The code part is an array which might need to be modified by + some relocations. + The size is in bytes. */ + const unsigned long *_xcoff_stub_indirect_call_code; + unsigned long _xcoff_stub_indirect_call_size; + const unsigned long *_xcoff_stub_shared_call_code; + unsigned long _xcoff_stub_shared_call_size; }; /* Look up an entry in an XCOFF link hash table. */ @@ -185,6 +194,11 @@ struct xcoff_backend_data_rec #define bfd_xcoff_glink_code(a, b) ((xcoff_backend (a)->_xcoff_glink_code[(b)])) #define bfd_xcoff_glink_code_size(a) ((xcoff_backend (a)->_xcoff_glink_size)) +#define bfd_xcoff_stub_indirect_call_code(a, b) ((xcoff_backend (a)->_xcoff_stub_indirect_call_code[(b)])) +#define bfd_xcoff_stub_indirect_call_size(a) ((xcoff_backend (a)->_xcoff_stub_indirect_call_size)) +#define bfd_xcoff_stub_shared_call_code(a, b) ((xcoff_backend (a)->_xcoff_stub_shared_call_code[(b)])) +#define bfd_xcoff_stub_shared_call_size(a) ((xcoff_backend (a)->_xcoff_stub_shared_call_size)) + /* Check for the magic number U803XTOCMAGIC or U64_TOCMAGIC for 64 bit targets. */ #define bfd_xcoff_is_xcoff64(a) \ @@ -211,11 +225,12 @@ struct xcoff_backend_data_rec #define N_ONES(n) (((((bfd_vma) 1 << ((n) - 1)) - 1) << 1) | 1) typedef bool xcoff_reloc_function (bfd *, asection *, bfd *, - struct internal_reloc *, - struct internal_syment *, - struct reloc_howto_struct *, - bfd_vma, bfd_vma, - bfd_vma *, bfd_byte *); + struct internal_reloc *, + struct internal_syment *, + struct reloc_howto_struct *, + bfd_vma, bfd_vma, + bfd_vma *, bfd_byte *, + struct bfd_link_info *); typedef bool xcoff_complain_function (bfd *, bfd_vma, bfd_vma, struct reloc_howto_struct *); @@ -261,4 +276,42 @@ struct xcoff_dwsect_name { extern const struct xcoff_dwsect_name xcoff_dwsect_names[XCOFF_DWSECT_NBR_NAMES]; +/* Structure and functions needed by backend in order to handle + stubs created in xcofflink.c. */ + +enum xcoff_stub_type + { + xcoff_stub_none, + xcoff_stub_indirect_call, + xcoff_stub_shared_call + }; + +struct xcoff_stub_hash_entry +{ + /* Base hash table entry structure. */ + struct bfd_hash_entry root; + + enum xcoff_stub_type stub_type; + + /* The hash table entry of the stub's csect. */ + struct xcoff_link_hash_entry *hcsect; + + /* Offset in the stub's csect. */ + bfd_vma stub_offset; + + /* The target's section. */ + asection *target_section; + + /* The target's hash table entry. */ + struct xcoff_link_hash_entry *htarget; +}; + + +extern enum xcoff_stub_type bfd_xcoff_type_of_stub + (asection *, const struct internal_reloc *, bfd_vma, + struct xcoff_link_hash_entry *); + +extern struct xcoff_stub_hash_entry *bfd_xcoff_get_stub_entry + (asection *, struct xcoff_link_hash_entry *, struct bfd_link_info *); + #endif /* LIBXCOFF_H */ |