Bk6.6Ch6.9 glibc `__stack_chk_guard' work around.

Szabolcs Gyalókay gyalokay at gmail.com
Wed Mar 31 13:06:05 PDT 2010


Hi All,



> The reason libssp is not found is simply because it's not *supposed* to
> be. GCC has not yet been installed in Chapter 6, into /usr, so the only
> libssp present at the time Glibc is being built is in /tools. However,
> since Glibc is supposed to go into /usr, it will not link to anything in
> /tools, including libssp. Again, this is exactly how it is supposed to
> be. The problem is simply that Glibc is not *supposed* to be looking for
> libssp at all, so you should not attempt to "fix" it by forcing it to
> link to libssp. You need to find the root of the problem by determining
> why Glibc is even trying to find libssp in the first place.
>
> Arguably, you could also just symlink /usr/lib/libssp.so -> /tools, but
> this is simply another workaround, not an actual fix.
>

OK, then libssp is not supposed to be linked, then why isn't somebody asking
the obvious question?

In the original post Pete wrote:

It seems that libssp is suppose to be pulled in by
> the gcc option '-fstack-protector' so that '-lssp'
> shouldn't be necessary on the link line.
>

So libssp is included because of '-fstack-protector'. I assume
'-fstack-protector' is also not supposed to be there. Then why is it here:

gcc res_hconf.c -c -std=gnu99 -fgnu89-inline -O2 -Wall -Winline
-Wwrite-strings -fmerge-all-constants -g -Wstrict-prototypes
-DIS_IN_nscd=1 -D_FORTIFY_SOURCE=2 -fpie -fstack-protector   -I../include
-I/sources/glibc-build/nscd -I/sources/glibc-build -I../sysdeps/x86_64/elf
-I../nptl/sysdeps/unix/sysv/linux/x86_64 -I../sysdeps/unix/sysv/linux/x86_64
-I../sysdeps/unix/sysv/linux/wordsize-64 -I../nptl/sysdeps/unix/sysv/linux
-I../nptl/sysdeps/pthread -I../sysdeps/pthread -I../sysdeps/unix/sysv/linux
-I../sysdeps/gnu -I../sysdeps/unix/common -I../sysdeps/unix/mman
-I../sysdeps/unix/inet -I../nptl/sysdeps/unix/sysv -I../sysdeps/unix/sysv
-I../sysdeps/unix/x86_64 -I../nptl/sysdeps/unix -I../sysdeps/unix
-I../sysdeps/posix -I../sysdeps/x86_64/fpu -I../nptl/sysdeps/x86_64
-I../sysdeps/x86_64 -I../sysdeps/wordsize-64 -I../sysdeps/ieee754/ldbl-96
-I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754
-I../sysdeps/generic/elf -I../sysdeps/generic -I../nptl  -I.. -I../libio
-I.  -D_LIBC_REENTRANT -include ../include/libc-symbols.h
-DNOT_IN_libc=1    -o /sources/glibc-build/nscd/res_hconf.o -MD -MP -MF
/sources/glibc-build/nscd/res_hconf.o.dt -MT
/sources/glibc-build/nscd/res_hconf.o
gcc -pie -Wl,-O1 -nostdlib -nostartfiles -o /sources/glibc-build/nscd/nscd
-Wl,-dynamic-linker=/lib64/ld-linux-x86-64.so.2   -Wl,-z,combreloc
-Wl,-z,relro -Wl,-z,now -Wl,--hash-style=both
/sources/glibc-build/csu/Scrt1.o /sources/glibc-build/csu/crti.o `gcc
--print-file-name=crtbeginS.o` /sources/glibc-build/nscd/nscd.o
/sources/glibc-build/nscd/connections.o /sources/glibc-build/nscd/pwdcache.o
/sources/glibc-build/nscd/getpwnam_r.o
/sources/glibc-build/nscd/getpwuid_r.o /sources/glibc-build/nscd/grpcache.o
/sources/glibc-build/nscd/getgrnam_r.o
/sources/glibc-build/nscd/getgrgid_r.o /sources/glibc-build/nscd/hstcache.o
/sources/glibc-build/nscd/gethstbyad_r.o
/sources/glibc-build/nscd/gethstbynm3_r.o
/sources/glibc-build/nscd/getsrvbynm_r.o
/sources/glibc-build/nscd/getsrvbypt_r.o
/sources/glibc-build/nscd/servicescache.o
/sources/glibc-build/nscd/dbg_log.o /sources/glibc-build/nscd/nscd_conf.o
/sources/glibc-build/nscd/nscd_stat.o /sources/glibc-build/nscd/cache.o
/sources/glibc-build/nscd/mem.o
/sources/glibc-build/nscd/nscd_setup_thread.o
/sources/glibc-build/nscd/xmalloc.o /sources/glibc-build/nscd/xstrdup.o
/sources/glibc-build/nscd/aicache.o /sources/glibc-build/nscd/initgrcache.o
/sources/glibc-build/nscd/gai.o /sources/glibc-build/nscd/res_hconf.o
/sources/glibc-build/rt/librt.so
/sources/glibc-build/nptl/libpthread_nonshared.a
/sources/glibc-build/nptl/libpthread.so /sources/glibc-build/nis/libnsl.so
-Wl,-rpath-link=/sources/glibc-build:/sources/glibc-build/math:/sources/glibc-build/elf:/sources/glibc-build/dlfcn:/sources/glibc-build/nss:/sources/glibc-build/nis:/sources/glibc-build/rt:/sources/glibc-build/resolv:/sources/glibc-build/crypt:/sources/glibc-build/nptl
/sources/glibc-build/libc.so.6 /sources/glibc-build/libc_nonshared.a -lgcc
-Wl,--as-needed -lgcc_s  -Wl,--no-as-needed `gcc
--print-file-name=crtendS.o` /sources/glibc-build/csu/crtn.o
/sources/glibc-build/nscd/nscd.o: In function `nscd_open_socket':
/sources/glibc-2.11.1/nscd/nscd.c:442: undefined reference to
`__stack_chk_guard'
/sources/glibc-build/nscd/nscd.o: In function `parse_opt':
/sources/glibc-2.11.1/nscd/nscd.c:291: undefined reference to
`__stack_chk_guard'
/sources/glibc-build/nscd/connections.o: In function `restart':
/sources/glibc-2.11.1/nscd/connections.c:1305: undefined reference to
`__stack_chk_guard'
/sources/glibc-2.11.1/nscd/connections.c:1461: undefined reference to
`__stack_chk_guard'
/sources/glibc-build/nscd/connections.o: In function `main_loop_epoll':
/sources/glibc-2.11.1/nscd/connections.c:2005: undefined reference to
`__stack_chk_guard'
/sources/glibc-build/nscd/connections.o:/sources/glibc-2.11.1/nscd/connections.c:1795:
more undefined references to `__stack_chk_guard' follow
collect2: ld returned 1 exit status
make[2]: *** [/sources/glibc-build/nscd/nscd] Error 1
make[2]: Leaving directory `/sources/glibc-2.11.1/nscd'
make[1]: *** [nscd/others] Error 2
make[1]: Leaving directory `/sources/glibc-2.11.1'
make: *** [all] Error 2

I can only say for sure: I'm pasting instructions from the book, and I did
not put it there.

I think you have to start entertaining the possibility that something is
wrong with the book.

As an addition, the output of glibc's configure:

 ../glibc-2.11.1/configure --prefix=/usr \
>     --disable-profile --enable-add-ons \
>     --enable-kernel=2.6.18 --libexecdir=/usr/lib/glibc
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for gcc... gcc
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
configure: running configure fragment for add-on libidn
configure: running configure fragment for add-on nptl
checking sysdep dirs... sysdeps/x86_64/elf
nptl/sysdeps/unix/sysv/linux/x86_64 sysdeps/unix/sysv/linux/x86_64
sysdeps/unix/sysv/linux/wordsize-64 nptl/sysdeps/unix/sysv/linux
nptl/sysdeps/pthread sysdeps/pthread sysdeps/unix/sysv/linux sysdeps/gnu
sysdeps/unix/common sysdeps/unix/mman sysdeps/unix/inet
nptl/sysdeps/unix/sysv sysdeps/unix/sysv sysdeps/unix/x86_64
nptl/sysdeps/unix sysdeps/unix sysdeps/posix sysdeps/x86_64/fpu
nptl/sysdeps/x86_64 sysdeps/x86_64 sysdeps/wordsize-64
sysdeps/ieee754/ldbl-96 sysdeps/ieee754/dbl-64 sysdeps/ieee754/flt-32
sysdeps/ieee754 sysdeps/generic/elf sysdeps/generic
checking for a BSD-compatible install... /tools/bin/install -c
checking whether ln -s works... yes
checking whether
/tools/lib/gcc/x86_64-unknown-linux-gnu/4.4.3/../../../../x86_64-unknown-linux-gnu/bin/as
is GNU as... yes
checking whether
/tools/lib/gcc/x86_64-unknown-linux-gnu/4.4.3/../../../../x86_64-unknown-linux-gnu/bin/ld
is GNU ld... yes
checking for
/tools/lib/gcc/x86_64-unknown-linux-gnu/4.4.3/../../../../x86_64-unknown-linux-gnu/bin/as...
/tools/lib/gcc/x86_64-unknown-linux-gnu/4.4.3/../../../../x86_64-unknown-linux-gnu/bin/as
checking version of
/tools/lib/gcc/x86_64-unknown-linux-gnu/4.4.3/../../../../x86_64-unknown-linux-gnu/bin/as...
2.20, ok
checking for
/tools/lib/gcc/x86_64-unknown-linux-gnu/4.4.3/../../../../x86_64-unknown-linux-gnu/bin/ld...
/tools/lib/gcc/x86_64-unknown-linux-gnu/4.4.3/../../../../x86_64-unknown-linux-gnu/bin/ld
checking version of
/tools/lib/gcc/x86_64-unknown-linux-gnu/4.4.3/../../../../x86_64-unknown-linux-gnu/bin/ld...
2.20, ok
checking for pwd... /bin/pwd
checking for gcc... gcc
checking version of gcc... 4.4.3, ok
checking for gnumake... no
checking for gmake... no
checking for make... make
checking version of make... 3.81, ok
checking for gnumsgfmt... no
checking for gmsgfmt... no
checking for msgfmt... msgfmt
checking version of msgfmt... 0.17, ok
checking for makeinfo... makeinfo
checking version of makeinfo... 4.13, ok
checking for sed... sed
checking version of sed... 4.2.1, ok
checking for autoconf... no
configure: WARNING:
*** These auxiliary programs are missing or incompatible versions: autoconf
*** some features will be disabled.
*** Check the INSTALL file for required versions.
checking whether ranlib is necessary... no
checking LD_LIBRARY_PATH variable... ok
checking whether GCC supports -static-libgcc... -static-libgcc
checking for bash... /bin/bash
checking for gawk... gawk
checking for perl... /usr/bin/perl
checking for install-info... /tools/bin/install-info
checking for bison... no
checking for signed size_t type... no
checking for libc-friendly stddef.h... yes
checking whether we need to use -P to assemble .S files... no
checking whether .text pseudo-op must be used... yes
checking for assembler global-symbol directive... .globl
checking for .set assembler directive... yes
checking for assembler .type directive prefix... @
checking for assembler gnu_unique_object symbol type... yes
checking for .symver assembler directive... yes
checking for ld --version-script... yes
checking for .previous assembler directive... yes
checking for .protected and .hidden assembler directive... yes
checking whether __attribute__((visibility())) is supported... yes
checking for broken __attribute__((visibility()))... no
checking for broken __attribute__((alias()))... no
checking whether to put _rtld_local into .sdata section... no
checking for .preinit_array/.init_array/.fini_array support... yes
checking for libunwind-support in compiler... no
checking for -z nodelete option... yes
checking for -z nodlopen option... yes
checking for -z initfirst option... yes
checking for -z relro option... yes
checking for -Bgroup option... yes
checking for libgcc_s suffix...
checking for --as-needed option... yes
checking whether --noexecstack is desirable for .S files... yes
checking for -z combreloc... yes
checking for -z execstack... yes
checking for -fpie... yes
checking for --hash-style option... yes
checking for -fno-toplevel-reorder -fno-section-anchors... yes
checking for -fstack-protector... yes
checking for -fgnu89-inline... yes
checking whether cc puts quotes around section names... no
checking for assembler .weak directive... yes
checking whether CFI directives are supported... yes
checking for ld --no-whole-archive... yes
checking for gcc -fexceptions... yes
checking for __builtin_expect... yes
checking for __builtin_memset... yes
checking for redirection of built-in functions... yes
checking for __thread... yes
checking for tls_model attribute... yes
checking for libgd... no
checking for is_selinux_enabled in -lselinux... no
checking for grep that handles long lines and -e... /tools/bin/grep
checking for egrep... /tools/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking size of long double... 16
running configure fragment for sysdeps/x86_64/elf
checking for x86-64 TLS support... yes
checking for AVX support... yes
running configure fragment for nptl/sysdeps/pthread
checking for forced unwind support... yes
checking for C cleanup handling... yes
running configure fragment for sysdeps/pthread
running configure fragment for sysdeps/unix/sysv/linux
checking for grep that handles long lines and -e... (cached) /tools/bin/grep
checking for egrep... (cached) /tools/bin/grep -E
checking installed Linux kernel header files... 2.0.10 or later
checking for kernel header at least 2.6.18... ok
checking for symlinks in /usr/include... ok
running configure fragment for nptl/sysdeps/x86_64
checking for .cfi_personality and .cfi_lsda pseudo-ops... yes
running configure fragment for sysdeps/x86_64
checking for grep that handles long lines and -e... (cached) /tools/bin/grep
checking for egrep... (cached) /tools/bin/grep -E
checking for ANSI C header files... (cached) yes
checking for sys/types.h... (cached) yes
checking for sys/stat.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for memory.h... (cached) yes
checking for strings.h... (cached) yes
checking for inttypes.h... (cached) yes
checking for stdint.h... (cached) yes
checking for unistd.h... (cached) yes
checking cpuid.h usability... yes
checking cpuid.h presence... yes
checking for cpuid.h... yes
checking if -g produces usable source locations for assembler-with-cpp...
yes
checking for SSE4 support... yes
checking for old glibc 2.0.x headers... no
checking whether -fPIC is default... no
configure: creating ./config.status
config.status: creating config.make
config.status: creating Makefile
config.status: creating config.h
config.status: executing default commands

Bye,

Szabolcs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxfromscratch.org/pipermail/lfs-support/attachments/20100331/d6b6211a/attachment.html>


More information about the lfs-support mailing list