[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


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

            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

unwind.s:

.globl _Unwind_Resume
.globl __wrap__Unwind_Resume
_Unwind_Resume:
__wrap__Unwind_Resume:
        retq

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

resume.ll:

target datalayout =
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
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
lpad:
  %1 = landingpad { i8*, i32 }
          cleanup
  resume { i8*, i32 } %1
unreachable:
  unreachable
}
declare void @throw()

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

Before
https://github.com/llvm/llvm-project/commit/f96ff3c0f8ebd941b3f6b345164c3d858b781484,
__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
f96ff3c0f8eb.

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