This is an archive of the discontinued LLVM Phabricator instance.

[mips][ias] R_MIPS_(GOT|HI|LO|PC)16 and R_MIPS_GPREL32 do not need symbols.
ClosedPublic

Authored by dsanders on Apr 12 2016, 9:01 AM.

Details

Summary

In theory, care must be taken to ensure that pairs of R_MIPS_(GOT|HI|LO)16
make the same decision on both relocs in the reloc pair but in practice
this isn't as hard as it sounds and only limits the complexity of the
predicate used. We handle all three with the same code to ensure their
decisions always agree with each other.

Also, the address of the symbol was previously incorrectly stated to be
irrelevant to VK_Mips_GOT, thereby preventing the replacement of the symbol
with a section and offset for this VariantKind. This is not correct since
VK_Mips_GOT refers to the GOT entry for the symbol and therefore the symbol
itself.

Diff Detail

Repository
rL LLVM

Event Timeline

dsanders updated this revision to Diff 53413.Apr 12 2016, 9:01 AM
dsanders retitled this revision from to [mips][ias] R_MIPS_(GOT|HI|LO|PC)16 and R_MIPS_GPREL32 do not need symbols..
dsanders updated this object.
dsanders added a subscriber: llvm-commits.
rafael added inline comments.
lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
29 ↗(On Diff #53413)

Please don't add this.

dsanders added inline comments.Apr 20 2016, 3:36 AM
lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
29 ↗(On Diff #53413)

I originally added this to preserve the intent of sort-relocation-table.s's tests but having dug further I now think that this patch exposes a bug in MipsELFObjectWriter::sortRelocs(). I don't see any mention of the relocation addend even though this is important to the HI/LO matching.

I'll look into fixing sortRelocs().

dsanders updated this revision to Diff 55563.Apr 29 2016, 3:41 AM

Remove the internal option. It's no longer needed and was hiding a bug.

sdardis accepted this revision.May 6 2016, 2:36 AM
sdardis edited edge metadata.

LGTM with one nit. Your commit message's second paragraph is redundant due to a previous patch.

This revision is now accepted and ready to land.May 6 2016, 2:36 AM
dsanders closed this revision.May 9 2016, 3:27 AM
This revision was automatically updated to reflect the committed changes.