[PATCH]: Merge bfd HC11/HC12 code together and add trampoline generation support

Stephane Carrez stcarrez@nerim.fr
Sat Apr 19 09:15:00 GMT 2003


Hi!

This (big) patch:

   - merges several HC11/HC12 functions from elf32-m68hc11.c and elf32-m68hc12.c
     in a new file elf32-m68hc1x.c.  These functions were identical and were duplicated.
     What remains in elf32-m68hc11.c and elf32-m68hc12.c are the specific stuff like
     reloc tables, linker relaxation, and stub generation.

   - adds support for trampoline generation following the hppa model.
     In elf32_m68hc11_size_stubs() we gather all the symbols for analysis and
     we look at each reloc for a 16-bit reloc against a symbol marked STO_M68HC12_FAR.
     Such relocs must be made against a trampoline code.  We remember the trampoline
     and its jump address to a hash table (more or less like what hppa did).

     size_stubs() is called at least twice: first to obtain the list of trampolines
     and know their size; second after linker GC and linker relaxation to obtain/update
     the address of the trampoline jump point.

     When applying relocation, we change the 16-bit relocs to a STO_M68HC12_FAR symbol
     to the trampoline entry point (instead of the function itself).  Other relocs need
     not be changed.

This patch only contains the HC11/HC12 bfd specific part.  A next patch necessary to
it updates the configure.in and Makefile.am.

I plan to commit this on Monday.

	Stephane

2003-04-18  Stephane Carrez  <stcarrez@nerim.fr>

	* elf32-m68hc1x.c: New file (from elf32-m68hc11.c and elf32-m68hc12.c)
	(m68hc11_elf_hash_table_create): New function.
	(elf32_m68hc11_link_hash_table_free): New function.
	(stub_hash_newfunc): New function.
	(m68hc11_add_stub): New function.
	(elf32_m68hc11_add_symbol_hook): New function.
	(elf32_m68hc11_setup_section_lists): New function.
	(elf32_m68hc11_next_input_section): New function.
	(elf32_m68hc11_size_stubs): New function.
	(elf32_m68hc11_build_stubs): New function.
	(m68hc11_get_relocation_value): New function.
	(elf32_m68hc11_relocate_section): Call the above to redirect
	some relocations to the trampoline code.
	(m68hc11_elf_export_one_stub): New function.
	(m68hc11_elf_set_symbol): New function.
	(elf32_m68hc11_build_stubs): Call it via bfd_hash_traverse.
	(m68hc11_elf_get_bank_parameters): Get parameters only when the info
	is not yet initialized.

	* elf32-m68hc1x.h: New file (from elf32-m68hc11.c and elf32-m68hc12.c)
	(elf32_m68hc11_stub_hash_entry): New struct.
	(m68hc11_page_info): Add trampoline handler address.
	(m68hc11_elf_link_hash_table): Add stubs generation members.
	(elf32_m68hc11_add_symbol_hook): Declare.
	(elf32_m68hc11_setup_section_lists): Declare.
	(elf32_m68hc11_size_stubs): Declare.
	(elf32_m68hc11_build_stubs): Declare.
	
	* elf32-m68hc11.c (m68hc11_elf_ignore_reloc): Move to elf32-m68hc1x.c.
	(elf32_m68hc11_gc_mark_hook, elf32_m68hc11_gc_sweep_hook): Likewise.
	(elf32_m68hc11_check_relocs, elf32_m68hc11_relocate_section): Ditto.
	(_bfd_m68hc11_elf_set_private_flags): Ditto.
	(_bfd_m68hc11_elf_merge_private_bfd_data): Ditto.
	(_bfd_m68hc11_elf_print_private_bfd_data): Ditto.
	(bfd_elf32_bfd_link_hash_table_create): Define.
	(elf_backend_add_symbol_hook): Define.
	(m68hc11_elf_bfd_link_hash_table_create): New function.
	(m68hc11_elf_build_one_stub): New function.
	(m68hc11_elf_size_one_stub): New function.
	(m68hc11_elf_bfd_link_hash_table_create): Install the above.
	(bfd_elf32_bfd_link_hash_table_create): Define.

	* elf32-m68hc12.c (m68hc11_elf_ignore_reloc): Remove.
	(m68hc12_addr_is_banked): Remove, use m68hc11_addr_is_banked.
	(m68hc12_phys_addr): Ditto.
	(m68hc12_phys_page): Ditto.
	(m68hc12_elf_special_reloc): Move to elf32-m68hc1x.c.
	(elf32_m68hc11_gc_mark_hook): Likewise.
	(elf32_m68hc11_gc_sweep_hook): Likewise.
	(elf32_m68hc11_check_relocs): Likewise.
	(elf32_m68hc11_relocate_section): Likewise.
	(_bfd_m68hc12_elf_set_private_flags): Likewise.
	(_bfd_m68hc12_elf_merge_private_bfd_data): Likewise.
	(_bfd_m68hc12_elf_print_private_bfd_data): Likewise.
	(m68hc12_elf_build_one_stub): New function.
	(m68hc12_elf_size_one_stub): New function.
	(m68hc12_elf_bfd_link_hash_table_create): New function, use the above.
	(elf_backend_add_symbol_hook): Define.
	(elf_m68hc11_howto_table): Use TRUE for pcrel relocs; fix masks.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: elf32-m68hc1x.diffs
URL: <https://sourceware.org/pipermail/binutils/attachments/20030419/c9500cd2/attachment.ksh>


More information about the Binutils mailing list