[llvm-bugs] [Bug 51333] New: Wrapping broken for symbols generated by LTO

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Aug 3 19:34:42 PDT 2021


            Bug ID: 51333
           Summary: Wrapping broken for symbols generated by LTO
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: smeenai at fb.com
                CC: i at maskray.me, llvm-bugs at lists.llvm.org,
                    nathan at lanza.io, smithp352 at googlemail.com


.globl _Unwind_Resume
.globl __wrap__Unwind_Resume

$ llvm-mc -triple x86_64-linux-gnu -filetype=obj -o unwind.o unwind.s
$ ld.lld -shared -o libunwind.so unwind.o


target datalayout =
target triple = "x86_64-unknown-linux-gnu"
define dso_local void @_Z1fv() optnone noinline personality i8* bitcast (void
()* @throw to i8*) {
  invoke void @throw()
          to label %unreachable unwind label %lpad
  %1 = landingpad { i8*, i32 }
  resume { i8*, i32 } %1
declare void @throw()

$ llvm-as -o resume.bc resume.ll
$ ld.lld -shared -o libresume.so resume.bc libunwind.so --gc-sections --wrap

__wrap__Unwind_Resume is present in the dynamic symbol table for libunwind.so
(as shown by running `nm -D libunwind.so`), as expected. After that commit,
it's no longer present in the dynamic symbol table, and we have an invalid PLT
entry instead.

`_Unwind_Resume` isn't present in the bitcode file's symbol table, since the
reference to it is only synthesized during LTO codegen, so I imagine the symbol
is considered unreferenced and the wrapper is incorrectly dead-stripped.

Linking against the DSO defining both `_Unwind_Resume` and
`__wrap__Unwind_Resume` was necessary for the wrapping to work correctly even
before that change, so there's possibly deeper underlying issues. We always
happen to link against such a DSO though, so this was working for us prior to

Adding `-u _Unwind_Resume` works around the issue but is inelegant.

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/20210804/20199255/attachment.html>

More information about the llvm-bugs mailing list