<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Peter,<div class=""><br class=""></div><div class="">Thanks for the help! I can confirm its fixed in the 4.0 release (tested with clang version 4.0.0-svn293947-1~exp1).</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Artem</div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On Feb 4, 2017, at 5:04 PM, Peter Collingbourne <<a href="mailto:peter@pcc.me.uk" class="">peter@pcc.me.uk</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi Artem,<div class=""><br class=""></div><div class="">Can you please try LLVM trunk (or the upcoming 4.0 release)? I believe that your bug was fixed by r286611.</div><div class=""><br class=""></div><div class="">Peter</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, Feb 3, 2017 at 11:02 PM, Artem Dinaburg via llvm-dev <span dir="ltr" class=""><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br class="">
<br class="">
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 class="">
<br class="">
The error message I get is:<br class="">
<br class="">
/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 class="">
<br class="">
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 class="">
<br class="">
--- hello.c ---<br class="">
#include <stdio.h><br class="">
#include <stdlib.h><br class="">
<br class="">
typedef void(*freeptr)(void*);<br class="">
<br class="">
int getval(freeptr fp) {<br class="">
    void *m = malloc(sizeof(int));<br class="">
    if(m) {<br class="">
        fp(m);<br class="">
    }<br class="">
    return 42;<br class="">
}<br class="">
<br class="">
int export() {<br class="">
    printf("Test: %d\n", getval(free));<br class="">
    return 0;<br class="">
}<br class="">
---<br class="">
<br class="">
--- command line ---<br class="">
clang-3.9 -shared -fuse-ld=gold -flto -fsanitize=cfi-icall -fPIC -o libhello.so hello.c<br class="">
---<br class="">
<br class="">
<br class="">______________________________<wbr class="">_________________<br class="">
LLVM Developers mailing list<br class="">
<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/llvm-dev</a><br class="">
<br class=""></blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr" class="">-- <div class="">Peter</div></div></div>
</div>
</div></blockquote></div><br class=""></div></body></html>