<div dir="ltr">Hi Artem,<div><br></div><div>Can you please try LLVM trunk (or the upcoming 4.0 release)? I believe that your bug was fixed by r286611.</div><div><br></div><div>Peter</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 3, 2017 at 11:02 PM, Artem Dinaburg via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I am encountering a linking failure when using Control Flow Integrity while building a shared library. It looks like the wrong relocation type is being emitted for functions referenced via the PLT. I am using clang 3.9.<br>
<br>
The error message I get is:<br>
<br>
/usr/bin/ld.gold: error: /tmp/lto-llvm-df723d.o: requires dynamic R_X86_64_PC32 reloc against 'free' which may overflow at runtime; recompile with -fPIC<br>
<br>
Recompiling with -fPIC does not actually help. I've managed to create a minimal reproducible testcase. Full command line and code to reproduce are below.<br>
<br>
--- hello.c ---<br>
#include <stdio.h><br>
#include <stdlib.h><br>
<br>
typedef void(*freeptr)(void*);<br>
<br>
int getval(freeptr fp) {<br>
void *m = malloc(sizeof(int));<br>
if(m) {<br>
fp(m);<br>
}<br>
return 42;<br>
}<br>
<br>
int export() {<br>
printf("Test: %d\n", getval(free));<br>
return 0;<br>
}<br>
---<br>
<br>
--- command line ---<br>
clang-3.9 -shared -fuse-ld=gold -flto -fsanitize=cfi-icall -fPIC -o libhello.so hello.c<br>
---<br>
<br>
<br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">-- <div>Peter</div></div></div>
</div>