Procrastiblog

February 8, 2007

Ubuntu’s GCC 4.1 and -fstack-protector

Filed under: Linux, Tech — Chris @ 1:54 am

Ubuntu quietly made -fstack-protector (i.e., ProPolice support) the default in their GCC 4.1 binary. (I think it’s also the default in OpenBSD.) Unfortunately, this breaks some builds, especially (I think) if you’re trying to build a kernel module. If you get an error that mentions the symbol __stack_chk_fail_local, like the one below, you got bit by this bug.


/usr/bin/ld: .libs/cr_checkpoint: hidden symbol `__stack_chk_fail_local' in /usr/lib/libc_nonshared.a(stack_chk_fail_local.oS) is referenced by DSO
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status

Either re-build your libraries with -fstack-protector or add -fno-stack-protector to CFLAGS. If this doesn’t work, you can try gcc-4.0, which predates the introduction of ProPolice, but this probably won’t work if you’re compiling a kernel module, because they have to be compiled with the same compiler as the kernel.

Advertisements

Blog at WordPress.com.