[llvm-bugs] [Bug 38932] New: x32: segfault with -fpic when initializing vtable ptr

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 13 06:02:58 PDT 2018


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

            Bug ID: 38932
           Summary: x32: segfault with -fpic when initializing vtable ptr
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: theonetruecamper at gmx.de
                CC: llvm-bugs at lists.llvm.org

This may be a duplicate for https://bugs.llvm.org/show_bug.cgi?id=22676 ?

The following test code immediately segfaults when compiled with -fpic -mx32:

==> test.cpp <==
struct A {
  virtual ~A() {}
};
int main() {
  A a;
}

looking at the assembler output shows why:
# clang++ test.cpp -fpic -mx32 -S && cat test.s | c++filt | grep "A::A():" -A 8
A::A():                              # @A::A()
        .cfi_startproc
# %bb.0:
        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset %rbp, -16
        movl    %esp, %ebp
        .cfi_def_cfa_register %rbp
        movl    vtable for A at GOTPCREL, %ea   # <== segfault here, (%rip) is
missing

compared to
# clang++ test.cpp -fpic -m64 -S && cat test.s | c++filt | grep "A::A():" -A 8
A::A():                              # @A::A()
        .cfi_startproc
# %bb.0:
        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset %rbp, -16
        movq    %rsp, %rbp
        .cfi_def_cfa_register %rbp
        movq    vtable for A at GOTPCREL(%rip), %rax

-- 
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/20180913/d83ac38f/attachment-0001.html>


More information about the llvm-bugs mailing list