[PATCH][m68k] Support generation of multiple GOTs

Maxim Kuvyrkov maxim@codesourcery.com
Thu Mar 27 16:21:00 GMT 2008


Hello,

This patch adds support for generation of multiple GOTs for m68k/ColdFire.

On ColdFire, GOT entries are typically accessed through an
R_68K_GOT16O relocation applied to a sign-extended 16-bit displacement
field.  If the offset of the GOT entry from the GOT pointer falls
outside the range of such a field, the link fails.

I'd like to thank Joseph S. Myers, Nathan Sidwell and Daniel Jacobowitz 
of CodeSourcery for helping me with this project.

OK for mainline?


Thank you,

Maxim Kuvyrkov,
CodeSourcery, Inc.


Design notes
------------

Multi-GOT starts in check_relocs () hook. There we scan all
relocations of a BFD and build a local GOT (struct elf_m68k_got)
for it. If a single BFD appears to require too many GOT slots with
R_68K_GOT8O or R_68K_GOT16O relocations, we fail with notification
to user.
After check_relocs () has been invoked for each input BFD, we have
constructed a GOT for each input BFD.

To minimize total number of GOTs required for a particular output BFD
(as some environments support only 1 GOT per output object) we try
to merge some of the GOTs to share an offset space. Ideally [and in most
cases] we end up with a single GOT. In cases when there are too many
restricted relocations (e.g., R_68K_GOT16O relocations) we end up with
several GOTs, assuming the environment can handle them.

Partitioning is done in elf_m68k_partition_multi_got (). We start with
an empty GOT and traverse bfd2got hashtable putting got_entries from
local GOTs to the new 'big' one. We do that by constructing an
intermediate GOT holding all the entries the local GOT has and the big
GOT lacks. Then we check if there is room in the big GOT to accommodate
all the entries from diff. On success we add those entries to the big
GOT; on failure we start the new 'big' GOT and retry the adding of
entries from the local GOT. Note that this retry will always succeed as
each local GOT doesn't overflow the limits. After partitioning we
end up with each bfd assigned one of the big GOTs. GOT entries in the
big GOTs are initialized with GOT offsets. Note that big GOTs are
positioned consequently in program space and represent a single huge GOT
to the outside world.

After that we get to elf_m68k_relocate_section (). There we
adjust relocations of GOT pointer (_GLOBAL_OFFSET_TABLE_) and symbol
relocations to refer to appropriate [assigned to current input_bfd]
big GOT.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: fsf-multigot.ChangeLog
URL: <https://sourceware.org/pipermail/binutils/attachments/20080327/5fd504c8/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: fsf-multigot.patch
URL: <https://sourceware.org/pipermail/binutils/attachments/20080327/5fd504c8/attachment-0001.ksh>


More information about the Binutils mailing list