[RFA:] elflink.c: Hide _GLOBAL_OFFSET_TABLE_

Eric Botcazou ebotcazou@libertysurf.fr
Thu Jan 6 21:59:00 GMT 2005


> Actually, I think it would be better if it was hidden on all arches,
> but SPARC (and other backends that need it) would either unconditionally
> or only when needed emitted the STB_LOCAL _GLOBAL_OFFSET_TABLE_ into
> .dynsym even when it is not exported.  Another alternative would be
> to special case dynamic relocations against _GLOBAL_OFFSET_TABLE_,
> so that they would be against symbol 0 instead of .got or
> _GLOBAL_OFFSET_TABLE_ symbol.

It turned out that it's not a little breakage: you basically cannot create 
shared libraries with global data anymore!  This was exacerbated by HP's 
patch, but the problem had actually been introduced by your May 2004 patch 
that hides the .got section: it can be reproduced with

 local:
  *;

in the linker script prior to HP's patch.


I've attached a patch that unhides .got on the SPARC (bfd_sparc_got-4.diff).  
Tested on sparc64-sun-solaris2.9 and sparc-sun-solaris2.8, it is sufficient 
to cure the problem.


	* elf32-sparc.c (elf32_sparc_omit_section_dynsym): New function.
	(elf_backend_omit_section_dynsym): Define to it.
	* elf64-sparc.c (sparc64_elf_omit_section_dynsym): New function.
	(elf_backend_omit_section_dynsym): Define to it.	


I've also tried to implement your first suggestion, that is to emit _G_O_T_ 
as a local symbol in .dynsym unconditionally (bfd_sparc_got-5.diff).  Seems 
to work too, tested on sparc64-sun-solaris2.9 and sparc-sun-solaris2.8, but 
far more invasive.


	* elf-bfd.h (struct elf_link_local_dynamic_entry): New 'input_section' field.
	(bfd_elf_link_create_local_dynamic_entry): Declare.
	* elflink.c (bfd_elf_link_create_local_dynamic_entry): New function
	extracted from...
	(bfd_elf_link_record_local_dynamic_symbol): ...here.  Invoke it to
	create the local dynamic symbol and set input_section to NULL.
	(bfd_elf_final_link): For a local dynamic symbol, piggyback on input_section
	if the ELF section is undefined.
	* elf32-sparc.c (elf32_sparc_link_hash_table_create): Use bfd_zmalloc to
	zero the structure.
	(create_got_section): Use BFD_ASSERT instead of abort.  Create a local
	dynamic symbol for _GLOBAL_OFFSET_TABLE_.
	(elf32_sparc_relocate_section): In a shared object, use the index of the
	local dynamic symbol for relocations against _GLOBAL_OFFSET_TABLE_.
	* elf64-sparc.c (struct sparc64_elf_link_hash_table): New 'sgot' and
	'srelgot' fields.
	(create_got_section): New function.
	(sparc64_elf_create_dynamic_sections): Likewise.
	(sparc64_elf_check_relocs): Invoke create_got_section instead of
	_bfd_elf_create_got_section.  Use the sgot and srelgot shortcuts.
	(sparc64_elf_size_dynamic_sections): Use the srelgot shortcut.
	(sparc64_elf_relocate_section): In a shared object, use the index of the
	local dynamic symbol for relocations against _GLOBAL_OFFSET_TABLE_.
	Use the sgot and srelgot shortcuts.
	(sparc64_elf_finish_dynamic_symbol): Use the sgot and srelgot shortcuts.
	(sparc64_elf_finish_dynamic_sections): Use the sgot shortcut.
	(elf_backend_create_dynamic_sections): Define to
	sparc64_elf_create_dynamic_sections.


-- 
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bfd_sparc_got-4.diff
Type: text/x-diff
Size: 3730 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20050106/e643c7ae/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bfd_sparc_got-5.diff
Type: text/x-diff
Size: 20978 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20050106/e643c7ae/attachment-0001.bin>


More information about the Binutils mailing list