mailing list of musl libc
 help / color / mirror / code / Atom feed
* undefined reference to __stack_chk_fail_local (x86)
@ 2018-09-11 12:27 Matias Fonzo
  2018-09-11 13:07 ` Szabolcs Nagy
  0 siblings, 1 reply; 2+ messages in thread
From: Matias Fonzo @ 2018-09-11 12:27 UTC (permalink / raw)
  To: musl

Hi there,

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/Makefile.host:90: scripts/basic/fixdep] Error 1
make: *** [Makefile:464: scripts_basic] Error 2 Return status = 2

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).



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: undefined reference to __stack_chk_fail_local (x86)
  2018-09-11 12:27 undefined reference to __stack_chk_fail_local (x86) Matias Fonzo
@ 2018-09-11 13:07 ` Szabolcs Nagy
  0 siblings, 0 replies; 2+ messages in thread
From: Szabolcs Nagy @ 2018-09-11 13:07 UTC (permalink / raw)
  To: musl

* Matias Fonzo <selk@dragora.org> [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/Makefile.host:90: 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 libc.so).
(that symbol should either call the extern __stack_chk_fail in
libc.so 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 libc.so.

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).


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-09-11 13:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-11 12:27 undefined reference to __stack_chk_fail_local (x86) Matias Fonzo
2018-09-11 13:07 ` Szabolcs Nagy

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).