-gc-sections for elf32-dlx and possible buglette in elf32-target.h
Ian Lance Taylor
Thu Jan 29 18:56:00 GMT 2004
"Dave Korn" <firstname.lastname@example.org> writes:
> 1) I want to use ELF-specific features; therefore I don't want to use the
> generic linker but the elf linker. Currently the elf32-dlx backend is a
> somewhat minimal implementation that doesn't actually use ELF hash tables or
> the ELF linker: it uses the generic equivalents.
That won't work. To use ELF features, you must use an ELF backend
> 2) Unfortunately, there's that bit of code I quoted from elf32-target.h
> that forces the generic link routines on me if I don't define
> elf_backend_relocate_section. It also causes an inconsistent set of
> routines to be used; it's basically wrong in the case where there isn't a
> backend relocate section routine defined but there is a derived hash table
> in use. I don't know if that would ever be a valid case.
It's not valid.
> 3) There's no documentation anywhere that I can find on what
> inter-dependencies there are among the backend overrideables. I guess I'm
> going to have to write a backend_relocate_section routine in order to get
> the ELF linker used. Does that also mean I have to supply routines for
> bfd_elf32_bfd_link_add_symbols and bfd_elf32_bfd_final_link ? Are there any
> generic-elf versions of these routines that I can call into play, or are
> they vastly different for different target architectures ?
The hash_table_create(), add_symbols(), and final_link() routines must
all work together. If you want to use the ELF hash_table_create()
routine, you must use the ELF add_symbols() and final_link() routines.
Generic versions of those routines exist in elflink.h, and most ELF
targets use them. In order to use them, you must write several ELF
backend routines, at least check_relocs(), adjust_dynamic_symbol(),
always_size_sections(), size_dynamic_sections(), relocate_section(),
finish_dynamic_symbol(), finish_dynamic_section(). See
elf_backend_data in elf-bfd.h.
If you don't need to support shared objects, most of these backend
routines can be pretty simple. The most interesting one would be
relocate_section() which must handle all your relocations.
More information about the Binutils