Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Tue, 11 Sep 2018 15:07:50 +0200
From: Szabolcs Nagy <>
Subject: Re: undefined reference to __stack_chk_fail_local (x86)

* Matias Fonzo <> [2018-09-11 09:27:45 -0300]:
> Bootstrapping Dragora (distro) reflects an error trying to build the
> kernel headers using musl 1.1.20:
> Running build() ...
>   UPD     include/generated/uapi/linux/version.h
>   HOSTCC  scripts/basic/fixdep
> /tmp/ccONBchp.o: In function `read_file':
> fixdep.c:(.text+0x12a): undefined reference to `__stack_chk_fail_local'
> /tmp/ccONBchp.o: In function `main':
> fixdep.c:(.text.startup+0x6e2): undefined reference to
> `__stack_chk_fail_local' /tools/lib32/gcc/i586-linux-musl/8.2.1/../../../../i586-linux-musl/bin/ld:
> scripts/basic/fixdep: hidden symbol `__stack_chk_fail_local' isn't
> defined /tools/lib32/gcc/i586-linux-musl/8.2.1/../../../../i586-linux-musl/bin/ld:
> final link failed: Bad value collect2: error: ld returned 1 exit status
> make[1]: *** [scripts/ scripts/basic/fixdep] Error 1
> make: *** [Makefile:464: scripts_basic] Error 2 Return status = 2

this happens because on i386 and powerpc gcc emits _local_ calls
to __stack_chk_fail_local which means it has to be defined within
the same module that you are linking (not in
(that symbol should either call the extern __stack_chk_fail in or just crash)

this should have been done by libgcc.a having a definition for
this symbol (since the compiler is using it), but instead it got
added to glibc libc_nonshared.a which is added to the link command
by using a linker script in place of

musl does not want to copy that hack, so the usual workaround is
to make gcc pass -lssp_nonshared to the linker when stack-protector
is in use and then have a libssp_nonshared.a with the appropriate
definition. (this is what alpine linux does)

you can also do this manually or disable ssp with -fno-stack-protector,
it may also work if a preincluded header declared it as weak
so undefined weak reference would just become 0 (and crash at runtime
which is the intended behaviour), but i havent tested that.

> In this case, the build procedure occurs inside of a temporary system,
> where the pieces are replaced one-by-one.  I haven't touch the build
> procedure in long time, under x86_64 works fine.  I haven't see this
> error before...
> The current toolchain is: binutils-2.30, GCC-8, musl 1.1.20+ (from
> commit ("fix namespace violation for c11 mutex functions", patched using
> the patches for the kernel UAPI 4.18).
> Anyone else have tried to compile the kernel headers for x86?. (for
> i586, in this case).

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.