https://bugs.llvm.org/show_bug.cgi?id=38676
Bug ID: 38676
Summary: LTO ignores -fPIC/-fPIE when building a non PIE
executable
Product: new-bugs
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedb...@nondot.org
Reporter: mh+l...@glandium.org
CC: llvm-bugs@lists.llvm.org
$ cat hello.c
#include <stdio.h>
int main() {
printf("Hello, world\n");
return 0;
}
$ clang-7 -o hello hello.c -O3 -fPIC -flto=thin # same result with -flto
$ objdump -d hello
(...)
0000000000401130 <main>:
401130: 50 push %rax
401131: bf 04 20 40 00 mov $0x402004,%edi
401136: e8 f5 fe ff ff callq 401030 <puts@plt>
40113b: 31 c0 xor %eax,%eax
40113d: 59 pop %rcx
40113e: c3 retq
40113f: 90 nop
(...)
Note how the string is loaded with an absolute address, compared to:
$ clang-7 -o hello hello.c -O3 -fPIC
$ objdump -d hello
(...)
0000000000401130 <main>:
401130: 50 push %rax
401131: 48 8d 3d cc 0e 00 00 lea 0xecc(%rip),%rdi # 402004
<_IO_stdin_used+0x4>
401138: e8 f3 fe ff ff callq 401030 <puts@plt>
40113d: 31 c0 xor %eax,%eax
40113f: 59 pop %rcx
401140: c3 retq
401141: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
401148: 00 00 00
40114b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1)
(...)
FWIW, GCC does respect -fPIC/-fPIE on LTOed non-PIE executables.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs