Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 185197 - sys-libs/glibc-2.6 hardened patch fails (glibc-2.5-hardened-inittls-nosysenter.patch)
Summary: sys-libs/glibc-2.6 hardened patch fails (glibc-2.5-hardened-inittls-nosysente...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: x86 Linux
: High minor (vote)
Assignee: The Gentoo Linux Hardened Team
URL:
Whiteboard:
Keywords:
: 185381 185436 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-07-13 13:03 UTC by Matt
Modified: 2007-07-15 22:27 UTC (History)
3 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt 2007-07-13 13:03:48 UTC
I'm trying to build glibc 2.6 on ~x86 hardened to test it, but the following patch fails:

 * Failed Patch: glibc-2.5-hardened-inittls-nosysenter.patch !
 *  ( /usr/local/portage/sys-libs/glibc/files/2.5/glibc-2.5-hardened-inittls-nosysenter.patch )


Reproducible: Always

Steps to Reproduce:
1. unmask glibc 2.6
2. try to install it
3. patch fails



Expected Results:  
it should patch cleanly or at least start compiling
Comment 1 SpanKY gentoo-dev 2007-07-14 17:49:33 UTC
glibc now requires TLS so a lot of #if logic has gone away

updated patch in cvs
Comment 2 Matt 2007-07-14 22:03:46 UTC
thanks for that fix :D

it still got that error despite the updated files:

I needed to change 

epatch "${FILESDIR}"/2.5/glibc-2.5-hardened-inittls-nosysenter.patch

to

epatch "${FILESDIR}"/2.6/glibc-2.6-hardened-inittls-nosysenter.patch

in the ebuild, now it's compiling ...
Comment 3 SpanKY gentoo-dev 2007-07-14 23:00:59 UTC
looks like i clobbered my changes with too many open windows ... should be fixed now though
Comment 4 Matt 2007-07-14 23:21:16 UTC
I don't know if it's my toolchain but compile fails with binutils 
[1] i686-pc-linux-gnu-2.17.50.0.15

or

[2] i686-pc-linux-gnu-2.17.50.0.17 *

cflags & cxxflags:

CFLAGS="-Os -march=pentium-m -pipe -mfpmath=sse -falign-functions=64 -fforce-addr"

LDFLAGS=" -Wl,--hash-style=both" <== could that be the reason ??

both gcc 3.4.6 and 4.1.2 produce the same output (below):
Comment 5 Matt 2007-07-14 23:21:38 UTC

i686-pc-linux-gnu-gcc vsprintf_chk.c -c -std=gnu99  -O2 -Wall -Winline -Wwrite-strings -fmerge-all-constants -fno-strict-aliasing -march=pentium-m -pipe -Wstrict-prototypes -mpreferred-stack-boundary=2  -fPIC -g0 -O99 -fomit-frame-pointer -D__USE_STRING_INLINES -D_IO_MTSAFE_IO   -I../include -I/var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug -I/var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl -I../sysdeps/i386/elf -I../nptl/sysdeps/unix/sysv/linux/i386/i686 -I../nptl/sysdeps/unix/sysv/linux/i386 -I../sysdeps/unix/sysv/linux/i386 -I../nptl/sysdeps/unix/sysv/linux -I../nptl/sysdeps/pthread -I../sysdeps/pthread -I../ports/sysdeps/unix/sysv/linux -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/common -I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../ports/sysdeps/unix/sysv/i386 -I../sysdeps/unix/sysv/i386 -I../nptl/sysdeps/unix/sysv -I../ports/sysdeps/unix/sysv -I../sysdeps/unix/sysv -I../sysdeps/unix/i386 -I../nptl/sysdeps/unix -I../ports/sysdeps/unix -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/i386/i686/fpu -I../nptl/sysdeps/i386/i686 -I../sysdeps/i386/i686 -I../sysdeps/i386/i486 -I../nptl/sysdeps/i386/i486 -I../sysdeps/i386/fpu -I../nptl/sysdeps/i386 -I../sysdeps/i386 -I../sysdeps/wordsize-32 -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../ports  -I.. -I../libio -I. -nostdinc -isystem /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include -isystem /usr/include -D_LIBC_REENTRANT -include ../include/libc-symbols.h  -DPIC -DSHARED     -DPIC -DPIC -o /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/vsprintf_chk.os -MD -MP -MF /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/vsprintf_chk.os.dt -MT /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/vsprintf_chk.os
i686-pc-linux-gnu-gcc snprintf_chk.c -c -std=gnu99  -O2 -Wall -Winline -Wwrite-strings -fmerge-all-constants -fno-strict-aliasing -march=pentium-m -pipe -Wstrict-prototypes -mpreferred-stack-boundary=2  -fPIC -g0 -O99 -fomit-frame-pointer -D__USE_STRING_INLINES -D_IO_MTSAFE_IO   -I../include -I/var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug -I/var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl -I../sysdeps/i386/elf -I../nptl/sysdeps/unix/sysv/linux/i386/i686 -I../nptl/sysdeps/unix/sysv/linux/i386 -I../sysdeps/unix/sysv/linux/i386 -I../nptl/sysdeps/unix/sysv/linux -I../nptl/sysdeps/pthread -I../sysdeps/pthread -I../ports/sysdeps/unix/sysv/linux -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/common -I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../ports/sysdeps/unix/sysv/i386 -I../sysdeps/unix/sysv/i386 -I../nptl/sysdeps/unix/sysv -I../ports/sysdeps/unix/sysv -I../sysdeps/unix/sysv -I../sysdeps/unix/i386 -I../nptl/sysdeps/unix -I../ports/sysdeps/unix -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/i386/i686/fpu -I../nptl/sysdeps/i386/i686 -I../sysdeps/i386/i686 -I../sysdeps/i386/i486 -I../nptl/sysdeps/i386/i486 -I../sysdeps/i386/fpu -I../nptl/sysdeps/i386 -I../sysdeps/i386 -I../sysdeps/wordsize-32 -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../ports  -I.. -I../libio -I. -nostdinc -isystem /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include -isystem /usr/include -D_LIBC_REENTRANT -include ../include/libc-symbols.h  -DPIC -DSHARED     -DPIC -DPIC -o /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/snprintf_chk.os -MD -MP -MF /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/snprintf_chk.os.dt -MT /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/snprintf_chk.os
stack_chk_fail.c:278:1: error: unterminated #ifdef
stack_chk_fail.c: In function '__hardened_gentoo_stack_chk_fail':
stack_chk_fail.c:276: error: expected declaration or statement at end of input
make[2]: *** [/var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/stack_chk_fail.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/var/tmp/paludis/sys-libs/glibc-2.6/work/glibc-2.6/debug'
make[1]: *** [debug/subdir_lib] Error 2
make[1]: Leaving directory `/var/tmp/paludis/sys-libs/glibc-2.6/work/glibc-2.6'
make: *** [all] Error 2

!!! ERROR in sys-libs/glibc-2.6:
!!! In toolchain-glibc_src_compile at line 4980
!!! make for default failed


(gcc 4.1.2-r1 hardened pie)
Comment 6 Matt 2007-07-14 23:21:58 UTC
i686-pc-linux-gnu-gcc vsprintf_chk.c -c -std=gnu99  -O2 -Wall -Winline -Wwrite-strings -fmerge-all-constants -fno-stack-protector -fno-strict-aliasing -march=pentium-m -pipe -Wstrict-prototypes -mpreferred-stack-boundary=2  -fPIC -g0 -O99 -fomit-frame-pointer -D__USE_STRING_INLINES -D_IO_MTSAFE_IO   -I../include -I/var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug -I/var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl -I../sysdeps/i386/elf -I../nptl/sysdeps/unix/sysv/linux/i386/i686 -I../nptl/sysdeps/unix/sysv/linux/i386 -I../sysdeps/unix/sysv/linux/i386 -I../nptl/sysdeps/unix/sysv/linux -I../nptl/sysdeps/pthread -I../sysdeps/pthread -I../ports/sysdeps/unix/sysv/linux -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/common -I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../ports/sysdeps/unix/sysv/i386 -I../sysdeps/unix/sysv/i386 -I../nptl/sysdeps/unix/sysv -I../ports/sysdeps/unix/sysv -I../sysdeps/unix/sysv -I../sysdeps/unix/i386 -I../nptl/sysdeps/unix -I../ports/sysdeps/unix -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/i386/i686/fpu -I../nptl/sysdeps/i386/i686 -I../sysdeps/i386/i686 -I../sysdeps/i386/i486 -I../nptl/sysdeps/i386/i486 -I../sysdeps/i386/fpu -I../nptl/sysdeps/i386 -I../sysdeps/i386 -I../sysdeps/wordsize-32 -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../ports  -I.. -I../libio -I. -nostdinc -isystem /usr/lib/gcc/i686-pc-linux-gnu/3.4.6/include -isystem /usr/include -D_LIBC_REENTRANT -include ../include/libc-symbols.h  -DPIC -DSHARED     -DPIC -DPIC -o /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/vsprintf_chk.os -MD -MP -MF /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/vsprintf_chk.os.dt -MT /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/vsprintf_chk.os
i686-pc-linux-gnu-gcc snprintf_chk.c -c -std=gnu99  -O2 -Wall -Winline -Wwrite-strings -fmerge-all-constants -fno-stack-protector -fno-strict-aliasing -march=pentium-m -pipe -Wstrict-prototypes -mpreferred-stack-boundary=2  -fPIC -g0 -O99 -fomit-frame-pointer -D__USE_STRING_INLINES -D_IO_MTSAFE_IO   -I../include -I/var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug -I/var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl -I../sysdeps/i386/elf -I../nptl/sysdeps/unix/sysv/linux/i386/i686 -I../nptl/sysdeps/unix/sysv/linux/i386 -I../sysdeps/unix/sysv/linux/i386 -I../nptl/sysdeps/unix/sysv/linux -I../nptl/sysdeps/pthread -I../sysdeps/pthread -I../ports/sysdeps/unix/sysv/linux -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/common -I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../ports/sysdeps/unix/sysv/i386 -I../sysdeps/unix/sysv/i386 -I../nptl/sysdeps/unix/sysv -I../ports/sysdeps/unix/sysv -I../sysdeps/unix/sysv -I../sysdeps/unix/i386 -I../nptl/sysdeps/unix -I../ports/sysdeps/unix -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/i386/i686/fpu -I../nptl/sysdeps/i386/i686 -I../sysdeps/i386/i686 -I../sysdeps/i386/i486 -I../nptl/sysdeps/i386/i486 -I../sysdeps/i386/fpu -I../nptl/sysdeps/i386 -I../sysdeps/i386 -I../sysdeps/wordsize-32 -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../ports  -I.. -I../libio -I. -nostdinc -isystem /usr/lib/gcc/i686-pc-linux-gnu/3.4.6/include -isystem /usr/include -D_LIBC_REENTRANT -include ../include/libc-symbols.h  -DPIC -DSHARED     -DPIC -DPIC -o /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/snprintf_chk.os -MD -MP -MF /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/snprintf_chk.os.dt -MT /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/snprintf_chk.os
stack_chk_fail.c:278:1: unterminated #ifdef
stack_chk_fail.c: In function `__hardened_gentoo_stack_chk_fail':
stack_chk_fail.c:276: error: syntax error at end of input
make[2]: *** [/var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/stack_chk_fail.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/var/tmp/paludis/sys-libs/glibc-2.6/work/glibc-2.6/debug'
make[1]: *** [debug/subdir_lib] Error 2
make[1]: Leaving directory `/var/tmp/paludis/sys-libs/glibc-2.6/work/glibc-2.6'
make: *** [all] Error 2

!!! ERROR in sys-libs/glibc-2.6:
!!! In toolchain-glibc_src_compile at line 4980
!!! make for default failed

(gcc-3.4.6-r2 hardened pie)
Comment 7 SpanKY gentoo-dev 2007-07-14 23:56:35 UTC
i rewrote the stack .c file a bit and broke that ;)

please update and try again
Comment 8 Matt 2007-07-15 09:51:56 UTC
ok, now comes up another error message - thanks for your work, btw:

work/build-default-i686-pc-linux-gnu-nptl/debug/sprintf_chk.os
i686-pc-linux-gnu-gcc vsprintf_chk.c -c -std=gnu99  -O2 -Wall -Winline -Wwrite-strings -fmerge-all-constants -fno-strict-aliasing -march=pentium-m -pipe -Wstrict-prototypes -mpreferred-stack-boundary=2  -fPIC -g0 -O99 -fomit-frame-pointer -D__USE_STRING_INLINES -D_IO_MTSAFE_IO   -I../include -I/var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug -I/var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl -I../sysdeps/i386/elf -I../nptl/sysdeps/unix/sysv/linux/i386/i686 -I../nptl/sysdeps/unix/sysv/linux/i386 -I../sysdeps/unix/sysv/linux/i386 -I../nptl/sysdeps/unix/sysv/linux -I../nptl/sysdeps/pthread -I../sysdeps/pthread -I../ports/sysdeps/unix/sysv/linux -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/common -I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../ports/sysdeps/unix/sysv/i386 -I../sysdeps/unix/sysv/i386 -I../nptl/sysdeps/unix/sysv -I../ports/sysdeps/unix/sysv -I../sysdeps/unix/sysv -I../sysdeps/unix/i386 -I../nptl/sysdeps/unix -I../ports/sysdeps/unix -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/i386/i686/fpu -I../nptl/sysdeps/i386/i686 -I../sysdeps/i386/i686 -I../sysdeps/i386/i486 -I../nptl/sysdeps/i386/i486 -I../sysdeps/i386/fpu -I../nptl/sysdeps/i386 -I../sysdeps/i386 -I../sysdeps/wordsize-32 -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../ports  -I.. -I../libio -I. -nostdinc -isystem /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include -isystem /usr/include -D_LIBC_REENTRANT -include ../include/libc-symbols.h  -DPIC -DSHARED     -DPIC -DPIC -o /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/vsprintf_chk.os -MD -MP -MF /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/vsprintf_chk.os.dt -MT /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/vsprintf_chk.os
i686-pc-linux-gnu-gcc snprintf_chk.c -c -std=gnu99  -O2 -Wall -Winline -Wwrite-strings -fmerge-all-constants -fno-strict-aliasing -march=pentium-m -pipe -Wstrict-prototypes -mpreferred-stack-boundary=2  -fPIC -g0 -O99 -fomit-frame-pointer -D__USE_STRING_INLINES -D_IO_MTSAFE_IO   -I../include -I/var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug -I/var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl -I../sysdeps/i386/elf -I../nptl/sysdeps/unix/sysv/linux/i386/i686 -I../nptl/sysdeps/unix/sysv/linux/i386 -I../sysdeps/unix/sysv/linux/i386 -I../nptl/sysdeps/unix/sysv/linux -I../nptl/sysdeps/pthread -I../sysdeps/pthread -I../ports/sysdeps/unix/sysv/linux -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/common -I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../ports/sysdeps/unix/sysv/i386 -I../sysdeps/unix/sysv/i386 -I../nptl/sysdeps/unix/sysv -I../ports/sysdeps/unix/sysv -I../sysdeps/unix/sysv -I../sysdeps/unix/i386 -I../nptl/sysdeps/unix -I../ports/sysdeps/unix -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/i386/i686/fpu -I../nptl/sysdeps/i386/i686 -I../sysdeps/i386/i686 -I../sysdeps/i386/i486 -I../nptl/sysdeps/i386/i486 -I../sysdeps/i386/fpu -I../nptl/sysdeps/i386 -I../sysdeps/i386 -I../sysdeps/wordsize-32 -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../ports  -I.. -I../libio -I. -nostdinc -isystem /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include -isystem /usr/include -D_LIBC_REENTRANT -include ../include/libc-symbols.h  -DPIC -DSHARED     -DPIC -DPIC -o /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/snprintf_chk.os -MD -MP -MF /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/snprintf_chk.os.dt -MT /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/snprintf_chk.os
stack_chk_fail.c: In function '__hardened_gentoo_stack_chk_fail':
stack_chk_fail.c:205: error: '__NR_socket' undeclared (first use in this function)
stack_chk_fail.c:205: error: (Each undeclared identifier is reported only once
stack_chk_fail.c:205: error: for each function it appears in.)
stack_chk_fail.c:207: error: 'domain' undeclared (first use in this function)
stack_chk_fail.c:207: error: 'type' undeclared (first use in this function)
stack_chk_fail.c:207: error: 'protocol' undeclared (first use in this function)
stack_chk_fail.c:284: error: '_SSP_NSIG' undeclared (first use in this function)
make[2]: *** [/var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/stack_chk_fail.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/var/tmp/paludis/sys-libs/glibc-2.6/work/glibc-2.6/debug'
make[1]: *** [debug/subdir_lib] Error 2
make[1]: Leaving directory `/var/tmp/paludis/sys-libs/glibc-2.6/work/glibc-2.6'
make: *** [all] Error 2

!!! ERROR in sys-libs/glibc-2.6:
!!! In toolchain-glibc_src_compile at line 4980
!!! make for default failed

(gcc 4.1.2 hardened)
Comment 9 Christian Heim (RETIRED) gentoo-dev 2007-07-15 10:14:16 UTC
*** Bug 185381 has been marked as a duplicate of this bug. ***
Comment 10 Matt 2007-07-15 10:15:16 UTC
also happens on gcc-3.4.6-r2 hardened:

i686-pc-linux-gnu-gcc snprintf_chk.c -c -std=gnu99  -O2 -Wall -Winline -Wwrite-strings -fmerge-all-constants -fno-stack-protector -fno-strict-aliasing -march=pentium-m -pipe -Wstrict-prototypes -mpreferred-stack-boundary=2  -fPIC -g0 -O99 -fomit-frame-pointer -D__USE_STRING_INLINES -D_IO_MTSAFE_IO   -I../include -I/var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug -I/var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl -I../sysdeps/i386/elf -I../nptl/sysdeps/unix/sysv/linux/i386/i686 -I../nptl/sysdeps/unix/sysv/linux/i386 -I../sysdeps/unix/sysv/linux/i386 -I../nptl/sysdeps/unix/sysv/linux -I../nptl/sysdeps/pthread -I../sysdeps/pthread -I../ports/sysdeps/unix/sysv/linux -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/common -I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../ports/sysdeps/unix/sysv/i386 -I../sysdeps/unix/sysv/i386 -I../nptl/sysdeps/unix/sysv -I../ports/sysdeps/unix/sysv -I../sysdeps/unix/sysv -I../sysdeps/unix/i386 -I../nptl/sysdeps/unix -I../ports/sysdeps/unix -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/i386/i686/fpu -I../nptl/sysdeps/i386/i686 -I../sysdeps/i386/i686 -I../sysdeps/i386/i486 -I../nptl/sysdeps/i386/i486 -I../sysdeps/i386/fpu -I../nptl/sysdeps/i386 -I../sysdeps/i386 -I../sysdeps/wordsize-32 -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../ports  -I.. -I../libio -I. -nostdinc -isystem /usr/lib/gcc/i686-pc-linux-gnu/3.4.6/include -isystem /usr/include -D_LIBC_REENTRANT -include ../include/libc-symbols.h  -DPIC -DSHARED     -DPIC -DPIC -o /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/snprintf_chk.os -MD -MP -MF /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/snprintf_chk.os.dt -MT /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/snprintf_chk.os
stack_chk_fail.c: In function `__hardened_gentoo_stack_chk_fail':
stack_chk_fail.c:205: error: `__NR_socket' undeclared (first use in this function)
stack_chk_fail.c:205: error: (Each undeclared identifier is reported only once
stack_chk_fail.c:205: error: for each function it appears in.)
stack_chk_fail.c:207: error: `domain' undeclared (first use in this function)
stack_chk_fail.c:207: error: `type' undeclared (first use in this function)
stack_chk_fail.c:207: error: `protocol' undeclared (first use in this function)
i686-pc-linux-gnu-gcc vsnprintf_chk.c -c -std=gnu99  -O2 -Wall -Winline -Wwrite-strings -fmerge-all-constants -fno-stack-protector -fno-strict-aliasing -march=pentium-m -pipe -Wstrict-prototypes -mpreferred-stack-boundary=2  -fPIC -g0 -O99 -fomit-frame-pointer -D__USE_STRING_INLINES -D_IO_MTSAFE_IO   -I../include -I/var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug -I/var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl -I../sysdeps/i386/elf -I../nptl/sysdeps/unix/sysv/linux/i386/i686 -I../nptl/sysdeps/unix/sysv/linux/i386 -I../sysdeps/unix/sysv/linux/i386 -I../nptl/sysdeps/unix/sysv/linux -I../nptl/sysdeps/pthread -I../sysdeps/pthread -I../ports/sysdeps/unix/sysv/linux -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/common -I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../ports/sysdeps/unix/sysv/i386 -I../sysdeps/unix/sysv/i386 -I../nptl/sysdeps/unix/sysv -I../ports/sysdeps/unix/sysv -I../sysdeps/unix/sysv -I../sysdeps/unix/i386 -I../nptl/sysdeps/unix -I../ports/sysdeps/unix -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/i386/i686/fpu -I../nptl/sysdeps/i386/i686 -I../sysdeps/i386/i686 -I../sysdeps/i386/i486 -I../nptl/sysdeps/i386/i486 -I../sysdeps/i386/fpu -I../nptl/sysdeps/i386 -I../sysdeps/i386 -I../sysdeps/wordsize-32 -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../ports  -I.. -I../libio -I. -nostdinc -isystem /usr/lib/gcc/i686-pc-linux-gnu/3.4.6/include -isystem /usr/include -D_LIBC_REENTRANT -include ../include/libc-symbols.h  -DPIC -DSHARED     -DPIC -DPIC -o /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/vsnprintf_chk.os -MD -MP -MF /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/vsnprintf_chk.os.dt -MT /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/vsnprintf_chk.os
stack_chk_fail.c:284: error: `_SSP_NSIG' undeclared (first use in this function)
make[2]: *** [/var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/stack_chk_fail.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/var/tmp/paludis/sys-libs/glibc-2.6/work/glibc-2.6/debug'
make[1]: *** [debug/subdir_lib] Error 2
make[1]: Leaving directory `/var/tmp/paludis/sys-libs/glibc-2.6/work/glibc-2.6'
make: *** [all] Error 2

!!! ERROR in sys-libs/glibc-2.6:
!!! In toolchain-glibc_src_compile at line 4980
!!! make for default failed
Comment 11 Christian Heim (RETIRED) gentoo-dev 2007-07-15 18:04:05 UTC
*** Bug 185436 has been marked as a duplicate of this bug. ***
Comment 12 SpanKY gentoo-dev 2007-07-15 19:16:21 UTC
ok, try again please ;)

my efforts to move to a C-only approach left out systems where not all the __NR_* were defined
Comment 13 Matt 2007-07-15 20:13:21 UTC
I have the feeling this is getting close to an solution ;) 

unfortunately it still fails:

output for gcc-4.1.2 hardened:

/usr/include -D_LIBC_REENTRANT -include ../include/libc-symbols.h  -DPIC -DSHARED
    -DPIC -DPIC -o /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-p
c-linux-gnu-nptl/debug/backtrace.os -MD -MP -MF /var/tmp/paludis/sys-libs/glibc-
2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/backtrace.os.dt -MT /var/tmp
/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/back
trace.os
stack_chk_fail.c: In function '__hardened_gentoo_stack_chk_fail':
stack_chk_fail.c:217: error: 'domain' undeclared (first use in this function)
stack_chk_fail.c:217: error: (Each undeclared identifier is reported only once
stack_chk_fail.c:217: error: for each function it appears in.)
stack_chk_fail.c:217: error: 'type' undeclared (first use in this function)
stack_chk_fail.c:217: error: 'protocol' undeclared (first use in this function)
stack_chk_fail.c:294: error: '_SSP_NSIG' undeclared (first use in this function)
make[2]: *** [/var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-lin
ux-gnu-nptl/debug/stack_chk_fail.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/var/tmp/paludis/sys-libs/glibc-2.6/work/glibc-2.6/d
ebug'
make[1]: *** [debug/subdir_lib] Error 2
make[1]: Leaving directory `/var/tmp/paludis/sys-libs/glibc-2.6/work/glibc-2.6'
make: *** [all] Error 2

!!! ERROR in sys-libs/glibc-2.6:
!!! In toolchain-glibc_src_compile at line 4982
!!! make for default failed
Comment 14 Christian Heim (RETIRED) gentoo-dev 2007-07-15 20:19:32 UTC
Yup, it still does here too.
Comment 15 Matt 2007-07-15 20:36:05 UTC
pretty the same output for gcc-3.4.6-r2 hardened:

i686-pc-linux-gnu-gcc ../sysdeps/i386/i686/memmove_chk.S -c  -I../include -I/var
/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug
-I/var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl
-I../sysdeps/i386/elf -I../nptl/sysdeps/unix/sysv/linux/i386/i686 -I../nptl/sysd
eps/unix/sysv/linux/i386 -I../sysdeps/unix/sysv/linux/i386 -I../nptl/sysdeps/uni
x/sysv/linux -I../nptl/sysdeps/pthread -I../sysdeps/pthread -I../ports/sysdeps/u
nix/sysv/linux -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/c
ommon -I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../ports/sysdeps/unix/sysv
/i386 -I../sysdeps/unix/sysv/i386 -I../nptl/sysdeps/unix/sysv -I../ports/sysdeps
/unix/sysv -I../sysdeps/unix/sysv -I../sysdeps/unix/i386 -I../nptl/sysdeps/unix
-I../ports/sysdeps/unix -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/i386/i
686/fpu -I../nptl/sysdeps/i386/i686 -I../sysdeps/i386/i686 -I../sysdeps/i386/i48
6 -I../nptl/sysdeps/i386/i486 -I../sysdeps/i386/fpu -I../nptl/sysdeps/i386 -I../
sysdeps/i386 -I../sysdeps/wordsize-32 -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/
ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754 -I../sysdeps/gen
eric/elf -I../sysdeps/generic -I../nptl -I../ports  -I.. -I../libio -I. -nostdin
c -isystem /usr/lib/gcc/i686-pc-linux-gnu/3.4.6/include -isystem /usr/include -D
_LIBC_REENTRANT -include ../include/libc-symbols.h  -DPIC -DSHARED     -DPIC -DP
IC -DASSEMBLER  -DGAS_SYNTAX  -Wa,--noexecstack  -o /var/tmp/paludis/sys-libs/gl
ibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/memmove_chk.os -MD -MP -
MF /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl
/debug/memmove_chk.os.dt -MT /var/tmp/paludis/sys-libs/glibc-2.6/work/build-defa
ult-i686-pc-linux-gnu-nptl/debug/memmove_chk.os
i686-pc-linux-gnu-gcc ../sysdeps/i386/i686/mempcpy_chk.S -c  -I../include -I/var
/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug
-I/var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl
-I../sysdeps/i386/elf -I../nptl/sysdeps/unix/sysv/linux/i386/i686 -I../nptl/sysd
eps/unix/sysv/linux/i386 -I../sysdeps/unix/sysv/linux/i386 -I../nptl/sysdeps/uni
x/sysv/linux -I../nptl/sysdeps/pthread -I../sysdeps/pthread -I../ports/sysdeps/u
nix/sysv/linux -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/c
ommon -I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../ports/sysdeps/unix/sysv
/i386 -I../sysdeps/unix/sysv/i386 -I../nptl/sysdeps/unix/sysv -I../ports/sysdeps
/unix/sysv -I../sysdeps/unix/sysv -I../sysdeps/unix/i386 -I../nptl/sysdeps/unix
-I../ports/sysdeps/unix -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/i386/i
686/fpu -I../nptl/sysdeps/i386/i686 -I../sysdeps/i386/i686 -I../sysdeps/i386/i48
6 -I../nptl/sysdeps/i386/i486 -I../sysdeps/i386/fpu -I../nptl/sysdeps/i386 -I../
sysdeps/i386 -I../sysdeps/wordsize-32 -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/
ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754 -I../sysdeps/gen
eric/elf -I../sysdeps/generic -I../nptl -I../ports  -I.. -I../libio -I. -nostdin
c -isystem /usr/lib/gcc/i686-pc-linux-gnu/3.4.6/include -isystem /usr/include -D
_LIBC_REENTRANT -include ../include/libc-symbols.h  -DPIC -DSHARED     -DPIC -DP
IC -DASSEMBLER  -DGAS_SYNTAX  -Wa,--noexecstack  -o /var/tmp/paludis/sys-libs/gl
ibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/mempcpy_chk.os -MD -MP -
MF /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl
/debug/mempcpy_chk.os.dt -MT /var/tmp/paludis/sys-libs/glibc-2.6/work/build-defa
ult-i686-pc-linux-gnu-nptl/debug/mempcpy_chk.os
stack_chk_fail.c: In function `__hardened_gentoo_stack_chk_fail':
stack_chk_fail.c:217: error: `domain' undeclared (first use in this function)
stack_chk_fail.c:217: error: (Each undeclared identifier is reported only once
stack_chk_fail.c:217: error: for each function it appears in.)
stack_chk_fail.c:217: error: `type' undeclared (first use in this function)
stack_chk_fail.c:217: error: `protocol' undeclared (first use in this function)
stack_chk_fail.c:294: error: `_SSP_NSIG' undeclared (first use in this function)
i686-pc-linux-gnu-gcc ../sysdeps/i386/i686/memset_chk.S -c  -I../include -I/var/
tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug -
I/var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl -
I../sysdeps/i386/elf -I../nptl/sysdeps/unix/sysv/linux/i386/i686 -I../nptl/sysde
ps/unix/sysv/linux/i386 -I../sysdeps/unix/sysv/linux/i386 -I../nptl/sysdeps/unix
/sysv/linux -I../nptl/sysdeps/pthread -I../sysdeps/pthread -I../ports/sysdeps/un
ix/sysv/linux -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/co
mmon -I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../ports/sysdeps/unix/sysv/
i386 -I../sysdeps/unix/sysv/i386 -I../nptl/sysdeps/unix/sysv -I../ports/sysdeps/
unix/sysv -I../sysdeps/unix/sysv -I../sysdeps/unix/i386 -I../nptl/sysdeps/unix -
I../ports/sysdeps/unix -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/i386/i6
86/fpu -I../nptl/sysdeps/i386/i686 -I../sysdeps/i386/i686 -I../sysdeps/i386/i486
 -I../nptl/sysdeps/i386/i486 -I../sysdeps/i386/fpu -I../nptl/sysdeps/i386 -I../s
ysdeps/i386 -I../sysdeps/wordsize-32 -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/i
eee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754 -I../sysdeps/gene
ric/elf -I../sysdeps/generic -I../nptl -I../ports  -I.. -I../libio -I. -nostdinc
 -isystem /usr/lib/gcc/i686-pc-linux-gnu/3.4.6/include -isystem /usr/include -D_
LIBC_REENTRANT -include ../include/libc-symbols.h  -DPIC -DSHARED     -DPIC -DPI
C -DASSEMBLER  -DGAS_SYNTAX  -Wa,--noexecstack  -o /var/tmp/paludis/sys-libs/gli
bc-2.6/work/build-default-i686-pc-linux-gnu-nptl/debug/memset_chk.os -MD -MP -MF
 /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-linux-gnu-nptl/d
ebug/memset_chk.os.dt -MT /var/tmp/paludis/sys-libs/glibc-2.6/work/build-default
-i686-pc-linux-gnu-nptl/debug/memset_chk.os
make[2]: *** [/var/tmp/paludis/sys-libs/glibc-2.6/work/build-default-i686-pc-lin
ux-gnu-nptl/debug/stack_chk_fail.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/var/tmp/paludis/sys-libs/glibc-2.6/work/glibc-2.6/d
ebug'
make[1]: *** [debug/subdir_lib] Error 2
make[1]: Leaving directory `/var/tmp/paludis/sys-libs/glibc-2.6/work/glibc-2.6'
make: *** [all] Error 2

!!! ERROR in sys-libs/glibc-2.6:
!!! In toolchain-glibc_src_compile at line 4980
!!! make for default failed
Comment 16 SpanKY gentoo-dev 2007-07-15 20:37:42 UTC
phreak: i already told you on irc i fixed that ;p
Comment 17 Matt 2007-07-15 22:02:03 UTC
I'm trying out your latest version of the stack .c file *fingers crossed* (still compiling)
Comment 18 Matt 2007-07-15 22:27:18 UTC
finally ! :D 

It compiled & also installed successfully

(tested with gcc-4.1.2 hardened)

Thanks a lot, SpanKY !