Page MenuHomePhabricator

[MC] Implement support for R_X86_64_SIZE64
ClosedPublic

Authored by davide on Mar 1 2015, 9:18 PM.

Details

Summary

Whilst looking at ELF X86_64 relocations in LLD, I noticed that MC lacks support for R_X86_64_SIZE{64,32}.
This is an attempt to implement the first one.
I blatantly copied the binutils syntax here, adding the '@SIZE' suffix. I hope it's fine, if there are concerns I'll be happy to discuss.
A patch for R_X86_64_SIZE32 will follow.

Diff Detail

Event Timeline

davide updated this revision to Diff 20975.Mar 1 2015, 9:18 PM
davide retitled this revision from to [MC] Implement support for R_X86_64_SIZE64.
davide updated this object.
davide edited the test plan for this revision. (Show Details)
davide added a reviewer: rafael.
davide set the repository for this revision to rL LLVM.
davide added subscribers: Unknown Object (MLST), emaste.

Seems a little over specific, it would be nice if we could handle R_386_SIZE32 and R_X86_64_SIZE32 as well.

Seems a little over specific, it would be nice if we could handle R_386_SIZE32 and R_X86_64_SIZE32 as well.

Arg, this feedback isn't very helpful. Sorry about that. I guess what I tried to communicate was that we should have a VK_SIZE instead of VK_X86_64_SIZE and let the fixup's kind govern whether we get `R_X86_64_SIZE32 or `R_X86_64_SIZE64.

Seems a little over specific, it would be nice if we could handle R_386_SIZE32 and R_X86_64_SIZE32 as well.

Arg, this feedback isn't very helpful. Sorry about that. I guess what I tried to communicate was that we should have a VK_SIZE instead of VK_X86_64_SIZE and let the fixup's kind govern whether we get `R_X86_64_SIZE32 or `R_X86_64_SIZE64.

Thank for the review. This was my intention actually, and I think your comment is a sign that I chose the wording poorly.
Let me rephrase. It seems to me the format for VK is VK_<$arch | $format >_<$identifier>.
A couple of examples of this are, e.g. VK_Mips_HIGHEST and VK_COFF_IMGREL32
In other words, X86_64 doesn't refer to the size but the target architecture. We can use something else if you have a better proposition.

rafael edited edge metadata.Mar 3 2015, 9:57 AM

I am with David. The point is that there are both arch specific and arch independent VK_*. Since there is also R_386_SIZE32 for the x86 arch, this should probably be just VK_SIZE.

davide updated this revision to Diff 21142.Mar 3 2015, 2:34 PM
davide edited edge metadata.
davide removed rL LLVM as the repository for this revision.

Addressed your comment. Are you fine with the rest of the patch?

davide updated this revision to Diff 21146.Mar 3 2015, 2:39 PM

Patch with context.

majnemer added inline comments.Mar 3 2015, 2:49 PM
lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
151

I would think this should be R_X86_64_SIZE32.

Can you add a testcase for R_X86_64_SIZE32?

davide updated this revision to Diff 21159.Mar 3 2015, 4:51 PM

Added support (and test) for SIZE32, fixed thinko spotted by David.

rafael accepted this revision.Mar 3 2015, 4:52 PM
rafael edited edge metadata.

LGTM

This revision is now accepted and ready to land.Mar 3 2015, 4:52 PM
davide closed this revision.Mar 3 2015, 10:53 PM