[llvm-bugs] [Bug 27345] New: -fsanitize=cfi-icall broken with -pie

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Apr 13 15:43:44 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=27345

            Bug ID: 27345
           Summary: -fsanitize=cfi-icall broken with -pie
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Interprocedural Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: eugeni.stepanov at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

$ 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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160413/1c3d4781/attachment.html>


More information about the llvm-bugs mailing list