Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

[LTO] Build of FreeBSD rtld(1) fails with undefined symbols #28177

Closed Quuxplusone closed 8 years ago

Quuxplusone commented 8 years ago
Bugzilla Link PR28179
Status RESOLVED FIXED
Importance P normal
Reported by Davide Italiano (ditaliano@apple.com)
Reported on 2016-06-17 14:00:34 -0700
Last modified on 2016-06-22 16:55:49 -0700
Version unspecified
Hardware PC All
CC compnerd@compnerd.org, llvm-bugs@lists.llvm.org, rafael@espindo.la
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
$ sh blah.sh
undefined symbol: __stack_chk_fail
undefined symbol: __libc_sigaction in
./home/buildbot/obj/usr/home/buildbot/freebsd/tmp/usr/lib/libc_pic.a(abort.So)

$ ~/work/llvm/build-release/bin/llvm-nm -print-armap libc_pic.a  |grep
__stack_chk_fail
__stack_chk_fail in stack_protector.So
---------------- T __stack_chk_fail

$ ~/work/llvm/build-release/bin/llvm-nm -print-armap libc_pic.a  |grep
__libc_sigaction
                 U __libc_sigaction
                 U __libc_sigaction
                 U __libc_sigaction
                 U __libc_sigaction
                 U __libc_sigaction
---------------- T __libc_sigaction
                 U __libc_sigaction
                 U __libc_sigaction

Notably, __libc_sigaction doesn't show up in the armap.
It is defined in sigaction.So
sigaction.So:
                 U __libc_interposing
---------------- T __libc_sigaction
---------------- T __sigaction
Quuxplusone commented 8 years ago
https://drive.google.com/open?id=0BypHPYysMK9ieDN3STZKSEFCZE0
Repro uploaded to drive as bugzilla doesn't like large attachments.
Quuxplusone commented 8 years ago

The armap problem looks to be just that that the library was created with an old version of llvm-ar.

Just extracting the members and recreating the library I get

__libc_sigaction in sigaction.So

With that the error goes down to

undefined symbol: __stack_chk_fail

The problem here is that this is a codegen introduced reference. lld has to learn to not internalize it, which probably means having TargetLibraryInfo expose a nice list of library names and plug that in lld's -u option.

Quuxplusone commented 8 years ago

Fixed, r273451.