<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - -fsanitize=cfi-icall broken with -pie"
href="https://llvm.org/bugs/show_bug.cgi?id=27345">27345</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>-fsanitize=cfi-icall broken with -pie
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Interprocedural Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>eugeni.stepanov@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>$ cat 1.c
int close(int x);
int main(int argc, char **argv) {
((int (*)(int))close)(0);
}
$ ./bin/clang 1.c -flto -fuse-ld=gold -fsanitize=cfi-icall -pie -fPIE
/usr/bin/ld.gold: error: /tmp/lto-llvm-3cf488.o: requires dynamic R_X86_64_PC32
reloc against 'close' which may overflow at runtime; recompile with -fPIC
clang-3.9: error: linker command failed with exit code 1 (use -v to see
invocation)
Plugin output:
Disassembly of section .text:
0000000000000000 <main>:
main():
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: 31 ff xor %edi,%edi
6: e8 05 00 00 00 callq 10 <main+0x10>
b: 31 c0 xor %eax,%eax
d: 5d pop %rbp
e: c3 retq
f: 90 nop
10: e9 00 00 00 00 jmpq 15 <main+0x15>
11: R_X86_64_PC32 close-0x4
15: cc int3
16: cc int3
17: cc int3
Without -pie, R_X86_64_PC32 gets converted to a PLT relocation in the linker.
This does not happen with -pie.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>