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.



  1. it solves my issue describe (in french) with

    Comment by jj — July 8, 2007 @ 9:25 pm

  2. Wow, that was difficult to track.

    I was compiling under Ubuntu 7.10 and then using it under CentOs 4.4.
    It worked fine until I include something like:

    ifstream a(“a.txt”);
    while( !a.eof())

    when it started failing saying
    “/lib/tls/ version `GLIBC_2.4′ not found”

    it turns out that using -fno-stack-protector, I’m able to run again my executable under CentOS.


    Comment by hlp — May 29, 2008 @ 3:19 pm

  3. Glad I could help!

    Comment by Chris — May 29, 2008 @ 6:38 pm

  4. thanks!..i am working with jaunty (ubuntu 9.04..and was trying to compile a library (written and tested.. for quite an older system) and setting CFLAGS=-fno-stack-protector and compiling removes the error “/usr/bin/ld: final link failed: Nonrepresentable section on output
    collect2: ld returned 1 exit status:

    Comment by sanchit — March 3, 2010 @ 5:34 am

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Create a free website or blog at

%d bloggers like this: