Patch for ppc _SDA_BASE_ value

Momchil Velikov velco@fadata.bg
Sat Mar 25 19:20:00 GMT 2000


Ian Lance Taylor wrote:
> Oh yeah.  Might as well do it in a callback from final_link, then, as
> you suggested.  Or elf32-ppc.c could simply override final_link, and
> call the default one after setting the symbol values.

Overriding final_link looks better. So, here's the patch.
In short: 
  If _SDA_BASE_(_SDA2_BASE_) is already created by a linker
  script, we don't touch it.
  Otherwise it is created and its value is set to the address
  of the first .sdata(.sdata2) section plus 32768.
  ("first" means with lowest vma).
  Removed are output section errors for R_PPC_SDAREL16 and
  R_PPC_EMB_SDA2REL relocations.
  Linker sections are always created with SEC_LINKER_CREATED
  flag. Otherwise their contents is not allocated in
  ppc_elf_size_dynamic_sections() and the linker gets
  a fatal signal in bfd_elf32_finish_pointer_linker_section().
  Fixed the computation of the relocation value in 
  bfd_elf32_finish_pointer_linker_section() as the linker
  allocated entry and _SDA_BASE_(_SDA2_BASE_) can be
  in different sections. (In fact, now they are *always*
  in different sections, because of the SEC_LINKER_CREATED flag.

Regards,
-velco
2000-03-25  Momchil Velikov  <velco@fadata.bg>

	* elflink.h (elf_finish_pointer_linker_section): Fix the
	computation of `relocation'. The base symbol can be in another
	section.

	* elf32-ppc.c (ppc_elf_create_linker_section): Create the linker
	sections with `SEC_LINKER_CREATE' flag set, so their contents
	is allocated in `ppc_elf_size_dynamic_sections'. Do not
	create _SDA_BASE_ and _SDA2_BASE_ here ...
	(ppc_elf_create_sda_base): ... but here. New function. Finds a proper value
	for a small data section base symbol and creates it (the symbol),
	if not already created.  
	(ppc_elf_gc_final_link): New function. Makes sure _SDA_BASE_
	and _SDA2_BASE_ are created before the final link.  
	(ppc_elf_relocate_section): Do not fail with an error if
	the target of R_PPC_SDAREL16 and R_PPC_EMB_SDA2REL relocations
	is not in .sdata and .sbss, or not in .sdata2 and .sbss2, respectively.
	(bfd_elf32_bfd_final_link): Define it to `ppc_elf_gc_final_link'.




More information about the Binutils mailing list