This is an archive of the discontinued LLVM Phabricator instance.

Relax GOTPCREL relocations for tail jmp instructions
ClosedPublic

Authored by tmsriram on May 30 2018, 4:03 PM.

Details

Summary

R_X86_64_GOTPCREL is not relaxed if opcode is a 64-bit tail jmp.

foo.c
extern int foo();

int main() {

return foo();

}

$ clang -O2 -fno-plt -mrelax-relocations=yes foo.cc -c
$ objdump -dr foo.o
0000000000000000 <main>:

   0:	ff 25 00 00 00 00    	jmpq   *0x0(%rip)        # 6 <main+0x6>
			2: R_X86_64_GOTPCREL	foo-0x4

Adding --save-temps to the above command-line will generate R_X86_64_GOTPCRELX

This is because in the former case, opcode is JMP64m but in the latter case it is a TAILJMPm64.

Diff Detail

Repository
rL LLVM

Event Timeline

tmsriram created this revision.May 30 2018, 4:03 PM
rnk accepted this revision.May 31 2018, 10:10 AM

lgtm

This revision is now accepted and ready to land.May 31 2018, 10:10 AM
This revision was automatically updated to reflect the committed changes.