With FORTIFY glibc alters the behaviour of asprintf, and this has changed in glibc-2.8 in a way leading to asprintf not being declared properly.
This results with for example things like libiberty (and things shipping with it, i.e. gcc-4.2.4, gcc-4.3.1, binutils-2.18, gdb-6.8) which should declare asprintf on its own if not already declared does not compile (since asprintf being declared two times).
AVE_DECL_ASPRINTF is computed with _GNU_SOURCE unset,
libiberty/floatformat.c sets _GNU_SOURCE and uses libiberty.h,
so asprintf is redeclared (/usr/include/stdio.h + libiberty.h)
Steps to Reproduce:
1.install hardened gcc 4 toolchain from git git://github.com/Xake/toolchain-overlay.git
2.emerge glibc 2.8
sys-devel/binutils-2.18-r3 with gcc 4.2.4 and glibc 2.8-p20080602 In file included from /var/tmp/portage/sys-devel/binutils-2.18-r3/work/binutils-2.18/libiberty/floatformat.c:40: /var/tmp/portage/sys-devel/binutils-2.18-r3/work/binutils-2.18/libiberty/../include/libiberty.h:589: error: expected declaration specifiers or '...' before numeric constant /var/tmp/portage/sys-devel/binutils-2.18-r3/work/binutils-2.18/libiberty/../include/libiberty.h:589: error: conflicting types for 'asprintf_chk' /usr/include/bits/stdio2.h:135: error: previous declaration of 'asprintf_chk' was here make: *** [floatformat.o] Error 1 make: *** Waiting for unfinished jobs....
gcc and gdb have the same bug.
emerge buinutils okey
irc log fron #gcc at irc.oftc.net
<Zorry> iant_work, ping
* ryanarn har avslutat (Read error: Connection reset by peer)
<iant_work> Zorry: pong
<andreast> DannyB: fyi, 36766 works on tuples
<Zorry> iant_work, the ifndef asprintf patch is working on two system now :)
* apinski (firstname.lastname@example.org) gick in i #gcc
<Zorry> iant_work, upstream later ?
<iant_work> Zorry: the comment needs to go on the preceding line, needs to look like other comments, and should be shorter
<Zorry> iant_work, np
<Zorry> iant_work, https://hardened.gentooexperimental.org/secure/attachment/ticket/33/libiberty.h-asprintf-glibc-2.8.patch
<iant_work> Just write /* asprintf may be declared as a macro by glibc with __USE_FORTIFY_LEVEL. */
<iant_work> put the comment before the #ifndef
* ryanarn (~email@example.com) gick in i #gcc
<iant_work> that patch is approved
<DannyB> that's what she said
<DannyB> richi: i had tracked down the gfortran issue on darwin and geoff keating confirmed my diagnosis
<Zorry> iant_work, okey :) thanx
gcc version 4.2.4 (Gentoo Hardened 4.2.4-r1 p1.0, builtin ssp,fortify, pie-9.0.11)
Portage 18.104.22.168 (hardened/linux/amd64/2008.0, gcc-4.2.4, glibc-2.8_p20080602-r0, 2.6.25-gentoo-r6 x86_64)
System uname: 2.6.25-gentoo-r6 x86_64 Intel(R) Core(TM)2 Duo CPU T7700 @ 2.40GHz
Timestamp of tree: Wed, 23 Jul 2008 09:45:03 +0000
dev-lang/python: 2.4.4-r13, 2.5.2-r5
Created attachment 161379 [details, diff]
Fix for glibc 2.8 and asprintf in libiberty.h
It will fix the error: previous declaration of 'asprintf_chk' was here
in >gcc-4.2 and >gdb-6.8 to
Thanks for the patch
sys-devel/binutils-22.214.171.124.8 fix the problem on binutils but it don't have any keywords. Can some one add ~x86 ~amd64 ~ppc ~ppc64 ?
GCC 4.3 and GDB 6.8 still need the patch.
Fixed in piepatch 10.1.2 for gcc-4.3-2
binutils-2.19 and gcc-4.3.2 are fixed. does gdb-6.8-r1 need the patch still ?
(In reply to comment #6)
> binutils-2.19 and gcc-4.3.2 are fixed. does gdb-6.8-r1 need the patch still ?
If you put the fortify spec in gcc.c cpp_unique_options then gcc, binutils and gdb don't need the asprintf patch.
vapier, which version of binutils needs to go stable for Glibc 2.8?
there is no glibc issue here