Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 114552 - Linking to libgcc, but not glibc leads to unresolved symbols __guard and __stack_smash_handler
Summary: Linking to libgcc, but not glibc leads to unresolved symbols __guard and __st...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: High major (vote)
Assignee: The Gentoo Linux Hardened Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-05 10:27 UTC by Maurice van der Pot (RETIRED)
Modified: 2005-12-09 14:18 UTC (History)
2 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 Maurice van der Pot (RETIRED) gentoo-dev 2005-12-05 10:27:15 UTC
Valgrind links to libgcc, but not to glibc. If valgrind is built with a 
compiler that was itself built with SSP, then the build will fail because 
libgcc imports __guard and __stack_smash_handler while these symbols are 
exported by glibc.

One way to solve this is to make sure that libgcc is not built with SSP.
I've talked to solar and psm about this, and psm suggested the following changes
to the toolchain.eclass in function do_gcc_SSP_patches():

 	# we apply only the needed parts of protectonly.dif
-	sed -e 's|^CRTSTUFF_CFLAGS = |CRTSTUFF_CFLAGS = -fno-stack-protector-all |'\
+	sed -e 's|^CRTSTUFF_CFLAGS = |CRTSTUFF_CFLAGS = -fno-stack-protector |'\
 		-i gcc/Makefile.in || die "Failed to update crtstuff!"
 
+	sed -e 's|^\(LIBGCC2_CFLAGS.*\)$|\1 -fno-stack-protector|' \
+		-i ${S}/gcc/Makefile.in || die "Failed to update gcc!"

I am now looking for someone who can review these changes. For instance, I'm
not sure if we should care if CRTSTUFF is also built without SSP, but I know
that for valgrind it is not a requirement; the second part of the patch alone
will solve my problem with valgrind.
Comment 1 solar (RETIRED) gentoo-dev 2005-12-05 10:57:41 UTC
the changes look fine/logical to me. Can you commit the changes Maurice?
Comment 2 Kevin F. Quinn (RETIRED) gentoo-dev 2005-12-08 03:17:36 UTC
Tried this on gcc-3.4.4-r1 so far; does what it says on the tin.

/usr/lib/gcc/i686-pc-linux-gnu/3.4.4/crt*.o
/usr/lib/gcc/i686-pc-linux-gnu/3.4.4/libgcc.a
/usr/lib/gcc/i686-pc-linux-gnu/3.4.4/libgcc_s.so.1

are all built without SSP, other stuff is unaffected (i.e. you still get SSP
built into libffi, libg2c, libgcj and friends, libstdc++, which all need libc.so
 so they're fine as they are).

With regards crt*.o, I think it makes good sense to avoid building SSP into
those objects.  One of the library switching options, "-nodefaultlibs" gets you
crtbegin and crtend but no libc, so as with '-nostdlib' it would be up to the
app to provide ssp support if it wanted it.
Comment 3 Maurice van der Pot (RETIRED) gentoo-dev 2005-12-09 14:18:21 UTC
Kevin committed the changes to toolchain.eclass.
Thanks guys!