<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - x32: segfault with -fpic when initializing vtable ptr"
   href="https://bugs.llvm.org/show_bug.cgi?id=38932">38932</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>x32: segfault with -fpic when initializing vtable ptr
          </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>Backend: X86
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>theonetruecamper@gmx.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This may be a duplicate for <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - PC-relative address isn't used for x32"
   href="show_bug.cgi?id=22676">https://bugs.llvm.org/show_bug.cgi?id=22676</a> ?

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@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@GOTPCREL(%rip), %rax</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>