Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 828141 - sys-libs/libunwind-1.5.0-r1 - ld: .libs/os-linux.o: in function `_Ux86_get_elf_image': os-linux.c:(.text+0x55a): undefined reference to `__stack_chk_fail_local' (on musl)
Summary: sys-libs/libunwind-1.5.0-r1 - ld: .libs/os-linux.o: in function `_Ux86_get_el...
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: x86 Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: musl-porting
  Show dependency tree
 
Reported: 2021-12-04 20:16 UTC by ernsteiswuerfel
Modified: 2024-03-11 08:04 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (libunwind-1.5.0-r1:20211204-174747.log,97.85 KB, text/plain)
2021-12-04 20:16 UTC, ernsteiswuerfel
Details
emerge --info (file_828141.txt,6.50 KB, text/plain)
2021-12-04 20:16 UTC, ernsteiswuerfel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ernsteiswuerfel archtester 2021-12-04 20:16:35 UTC
Created attachment 757434 [details]
build.log

[...]
libtool: link: i686-gentoo-linux-musl-gcc -shared  -fPIC -DPIC  .libs/os-linux.o mi/.libs/init.o mi/.li
bs/flush_cache.o mi/.libs/mempool.o mi/.libs/strerror.o x86/.libs/is_fpreg.o x86/.libs/regname.o x86/.l
ibs/Los-linux.o mi/.libs/_ReadULEB.o mi/.libs/_ReadSLEB.o mi/.libs/backtrace.o mi/.libs/dyn-cancel.o mi
/.libs/dyn-info-list.o mi/.libs/dyn-register.o mi/.libs/Ldyn-extract.o mi/.libs/Lfind_dynamic_proc_info
.o mi/.libs/Lget_accessors.o mi/.libs/Lget_proc_info_by_ip.o mi/.libs/Lget_proc_name.o mi/.libs/Lput_dy
namic_unwind_info.o mi/.libs/Ldestroy_addr_space.o mi/.libs/Lget_reg.o mi/.libs/Lset_reg.o mi/.libs/Lge
t_fpreg.o mi/.libs/Lset_fpreg.o mi/.libs/Lset_caching_policy.o mi/.libs/Lset_cache_size.o unwind/.libs/Backtrace.o unwind/.libs/DeleteException.o unwind/.libs/FindEnclosingFunction.o unwind/.libs/ForcedUnwind.o unwind/.libs/GetBSP.o unwind/.libs/GetCFA.o unwind/.libs/GetDataRelBase.o unwind/.libs/GetGR.o unwind/.libs/GetIP.o unwind/.libs/GetLanguageSpecificData.o unwind/.libs/GetRegionStart.o unwind/.libs/GetTextRelBase.o unwind/.libs/RaiseException.o unwind/.libs/Resume.o unwind/.libs/Resume_or_Rethrow.o unwind/.libs/SetGR.o unwind/.libs/SetIP.o unwind/.libs/GetIPInfo.o x86/.libs/Lapply_reg_state.o x86/.libs/Lreg_states_iterate.o x86/.libs/Lcreate_addr_space.o x86/.libs/Lget_save_loc.o x86/.libs/Lglobal.o x86/.libs/Linit.o x86/.libs/Linit_local.o x86/.libs/Linit_remote.o x86/.libs/Lget_proc_info.o x86/.libs/Lregs.o x86/.libs/Lresume.o x86/.libs/Lstep.o x86/.libs/getcontext-linux.o  -Wl,--whole-archive ./.libs/libunwind-dwarf-local.a ./.libs/libunwind-elf32.a -Wl,--no-whole-archive  -Wl,--as-needed -lc -lgcc_s -lz  -Os -march=pentium4 -mtune=pentium4 -nostartfiles -nostdlib -Wl,-O1   -Wl,-soname -Wl,libunwind.so.8 -o .libs/libunwind.so.8.0.1
/usr/lib/gcc/i686-gentoo-linux-musl/11.2.0/../../../../i686-gentoo-linux-musl/bin/ld: .libs/os-linux.o: in function `_Ux86_get_elf_image':
os-linux.c:(.text+0x55a): undefined reference to `__stack_chk_fail_local'
/usr/lib/gcc/i686-gentoo-linux-musl/11.2.0/../../../../i686-gentoo-linux-musl/bin/ld: mi/.libs/mempool.o: in function `_UIx86__mempool_alloc':
mempool.c:(.text+0x209): undefined reference to `__stack_chk_fail_local'
/usr/lib/gcc/i686-gentoo-linux-musl/11.2.0/../../../../i686-gentoo-linux-musl/bin/ld: mi/.libs/mempool.o: in function `_UIx86__mempool_free':
mempool.c:(.text+0x2b5): undefined reference to `__stack_chk_fail_local'
/usr/lib/gcc/i686-gentoo-linux-musl/11.2.0/../../../../i686-gentoo-linux-musl/bin/ld: x86/.libs/Los-linux.o: in function `_ULx86_is_signal_frame':
Los-linux.c:(.text+0xd0): undefined reference to `__stack_chk_fail_local'
/usr/lib/gcc/i686-gentoo-linux-musl/11.2.0/../../../../i686-gentoo-linux-musl/bin/ld: x86/.libs/Los-linux.o: in function `_ULx86_handle_signal_frame':
Los-linux.c:(.text+0x1d6): undefined reference to `__stack_chk_fail_local'
/usr/lib/gcc/i686-gentoo-linux-musl/11.2.0/../../../../i686-gentoo-linux-musl/bin/ld: x86/.libs/Los-linux.o:Los-linux.c:(.text+0x3ca): more undefined references to `__stack_chk_fail_local' follow
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:3278: libunwind.la] Error 1
make[2]: Leaving directory '/var/tmp/portage/sys-libs/libunwind-1.5.0-r1/work/libunwind-1.5.0-abi_x86_32.x86/src'
make[1]: *** [Makefile:2185: all] Error 2
make[1]: Leaving directory '/var/tmp/portage/sys-libs/libunwind-1.5.0-r1/work/libunwind-1.5.0-abi_x86_32.x86/src'
make: *** [Makefile:606: all-recursive] Error 1
 * ERROR: sys-libs/libunwind-1.5.0-r1::gentoo failed (compile phase):
 *   emake failed
Comment 1 ernsteiswuerfel archtester 2021-12-04 20:16:58 UTC
Created attachment 757435 [details]
emerge --info
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-12-04 20:22:05 UTC
For 1.6.2, LDFLAGS="-lssp_nonshared" emerge -v1 libunwind is sufficient.

I don't yet see why this is needed though. If I build a program by itself, I get SSP working fine (no need to manually link against ssp_nonshared).

Our GCC should already add this, so..
Comment 3 Jory A. Pratt gentoo-dev 2021-12-14 01:12:43 UTC
(In reply to ernsteiswuerfel from comment #1)
> Created attachment 757435 [details]
> emerge --info

You sure this wasn't gcc-11.2.0 before it was patched in ::gentoo, that would explain the build failure.
Comment 4 ernsteiswuerfel archtester 2021-12-15 10:53:35 UTC
(In reply to Jory A. Pratt from comment #3)
> You sure this wasn't gcc-11.2.0 before it was patched in ::gentoo, that
> would explain the build failure.
Just to be sure I rebuilt gcc and tried again now but the error stays the same.
Comment 5 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-12-20 00:18:43 UTC
We discussed this a bit in -hardened a few weeks ago. I think it got confusing because it uses freestanding/nostdlib.

The plot thickens given Alpine have to pass -fno-stack-protector just for this too (they use the same GCC patch we do for musl): https://git.alpinelinux.org/aports/tree/main/libunwind/APKBUILD#n27
Comment 6 jonys 2024-03-11 08:04:07 UTC
This bug is present on ppc and ppc64 musl too, so it is probably arch-independent. Searching shows that OpenEmbedded hit the same issue and have the same solutions: https://lists.openembedded.org/g/openembedded-core/message/79961