This is an archive of the discontinued LLVM Phabricator instance.

[ELF][MIPS] Put local GOT entries accessed via a 16-bit index first
ClosedPublic

Authored by atanasyan on Oct 20 2016, 11:03 AM.

Details

Summary

Some MIPS relocations used to access GOT entries are able to manipulate 16-bit index. The other ones like R_MIPS_CALL_HI16/LO16 can handle 32-bit indexes. 16-bit relocations are generated by default. The 32-bit relocations are generated by -mxgot flag passed to compiler. Usually these relocation are not mixed in the same code but files like crt*.o contain 16-bit relocations so even if all "user's" code compiled with -mxgot flag a few 16-bit relocations might come to the linking phase.

Now LLD does not differentiate local GOT entries accessed via a 16-bit and 32-bit indexes. That might lead to relocation's overflow if 16-bit entries are allocated to far from the beginning of the GOT.

The patch introduces new "part" of MIPS GOT dedicated to the local GOT entries accessed by 32-bit relocations. That allows to put local GOT entries accessed via a 16-bit index first and escape relocation's overflow.

Diff Detail

Repository
rL LLVM

Event Timeline

atanasyan updated this revision to Diff 75319.Oct 20 2016, 11:03 AM
atanasyan retitled this revision from to [ELF][MIPS] Put local GOT entries accessed via a 16-bit index first.
atanasyan updated this object.
atanasyan added a reviewer: ruiu.
atanasyan set the repository for this revision to rL LLVM.
atanasyan added a project: lld.
atanasyan added a subscriber: llvm-commits.
mgrang added a subscriber: mgrang.Oct 20 2016, 11:28 AM
mgrang added inline comments.
ELF/OutputSections.cpp
205 ↗(On Diff #75319)

Fix indentation. It would be great if you could fix indentation of the next "else" too :)

atanasyan added inline comments.Oct 20 2016, 11:49 AM
ELF/OutputSections.cpp
205 ↗(On Diff #75319)

Fix indentation. It would be great if you could fix indentation of the next "else" too

I'm sorry, but what is wrong with the current indentation? Brackets are on the same line with the else if statement, the code block is indented by two spaces.

mgrang added inline comments.Oct 20 2016, 1:13 PM
ELF/OutputSections.cpp
205 ↗(On Diff #75319)

I thought the statements must be indented two spaces under the else-if too. But now that I see, it seems fine having the statements align with those under the preceding "if".

ruiu accepted this revision.Oct 20 2016, 1:41 PM
ruiu edited edge metadata.

LGTM, but could you add a comment about why we are putting got entries referred by 16-bit relocations before entries referred by 32-bit relocations?

This revision is now accepted and ready to land.Oct 20 2016, 1:41 PM
This revision was automatically updated to reflect the committed changes.