Incompatibility of PIC and non-PIC

Alan Modra alan@linuxcare.com.au
Sat, 19 Aug 2000 00:29:01 +1000 (EST)


On Fri, 18 Aug 2000, Alan Modra wrote:

> One way to keep out current ABI is to generate a .plt and import stubs
> when statically linking PIC code.  That should be relatively easy to do in
> the linker.

A bit of head-scratching, a couple of added functions, and the linker now
detects PIC functions and handles them appropriately.

bfd/ChangeLog
	* elf32-hppa.c (elf32_hppa_link_hash_entry): Add pic_call.
	(hppa_link_hash_newfunc): Init it.
	(elf32_hppa_link_hash_table): Add pic_call_detected.
	(elf32_hppa_link_hash_table_create): Init it.  multi_subspace too.
	(hppa_type_of_stub): Use an import stub if pic_call.
	(elf32_hppa_check_relocs): Set SEC_HAS_GOT_REF appropriately.
	Don't just create the .got on GOT references, create a .plt too.
	(hppa_handle_PIC_calls): New function.
	(elf32_hppa_size_dynamic_sections): Call it.
	(hppa_setup_plt_PIC_call): New function.
	(elf32_hppa_build_stubs): Call it.
	* section.c (SEC_HAS_GOT_REF): Define new flag for asection.
	* bfd_in2.: Regenerate.


The linker detects PIC functions by noting DLTIND relocations within a
section.  If there aren't any, it's either not PIC, or it's PIC that
doesn't use the .got  Without .got references, we won't need to set
up r19.  Ta DA!

Alan Modra
-- 
Linuxcare.  Support for the Revolution.