[patch] Adjusting the value of _SDA[2]_BASE_ (was: Re: Patch for ppc _SDA_BASE_ value)
Momchil Velikov
velco@fadata.bg
Sat Apr 1 08:55:00 GMT 2000
Geoff Keating wrote:
> Anyway, there are a few corner cases I'd like you to check:
>
> - What happens if there are no .sdata or .sbss items at all, but the
> _SDA_BASE_ symbol is still referenced? Does it still have an
> address corresponding to where .sdata sections would go if there
> were any?
> - What happens when building a shared object? Does the _SDA_BASE_
> symbol still get created with the right value?
This patch adjusts the values of _SDA_BASE_ and _SDA_BASE_
before doing final link.
The symbols are created as before in ppc_elf_create_linker_section.
Their values are adjusted later in ppc_elf_adjust_sda_base.
In shared objects the value of _SDA_BASE_ is set the the same
value as _GLOBAL_OFFSET_TABLE_. So is the value of _SDA2_BASE_
(which is somewhat questionable as the EABI says nothing about it).
If there are no small data sections or only empty ones
_SDA_BASE_ and _SDA2_BASE_ are set to zero.
Otherwise, the small data section with the lowest vma is searched
and _SDA[2]_BASE_ value is set to the section's vma + 32768.
Ian Lance Taylor wrote:
> You are changing the way that ELF linker sections work, and I never
> understood those in the first place. I don't have time to learn.
>
> But you changed elf_finish_pointer_linker_section, in a way which
> appeared to be significant.
elflink.h is no longer changed. The code there appears to work
(although I don't know why :-/)
> > I'm troubled by the call to generic_link_add_one_symbol. It feels
> > wrong to call that after sections have been sized, allocated, and
> > relaxed, although it will probably work.
> But adding a symbol does not affect any section's size, except the
> symbol table section, but anyway its size a computed afterwards.
>
> The size of the dynamic symbol table section, on the other hand, is
> computed in size_dynamic_sections.
Now the symbols are created just as before, only their
values are adjusted later.
Regards,
-velco
2000-04-01 Momchil Velikov <velco@fadata.bg>
(ppc_elf_adjust_sda_base): New function. Adjusts the value
for a small data section base symbols.
(ppc_elf_final_link): New function. Makes sure the values of
_SDA_BASE_ and _SDA2_BASE_ are adjusted before the final link.
(bfd_elf32_bfd_final_link): Define it to `ppc_elf_final_link'.
More information about the Binutils
mailing list