Bug 1007528 - devtoolset-1.1: __stack_chk_fail referenced despite of -fno-stack-protector
Summary: devtoolset-1.1: __stack_chk_fail referenced despite of -fno-stack-protector
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Developer Toolset
Classification: Red Hat
Component: gcc
Version: DTS 1.1 RHEL 5
Hardware: All
OS: Linux
unspecified
low
Target Milestone: ---
: 2.4
Assignee: Jakub Jelinek
QA Contact: Martin Cermak
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-09-12 16:56 UTC by Marcin Wojdyr
Modified: 2013-09-12 18:17 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-09-12 18:00:41 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Marcin Wojdyr 2013-09-12 16:56:47 UTC
(Maybe that's not a bug, I have no idea).

I'm trying to produce binaries that would work also on RHEL4. One symbol gets in the way: __stack_chk_fail.
Adding -fno-stack-protector doesn't change anything.
This is devtoolset specific, the system compiler doesn't reference this symbol.
It happens only with -O[1-3] and with <iostream> included.


How reproducible:
always on i386 and x86 RHEL5 clones (sorry, I don't have access to RHEL5 atm)


Steps to Reproduce:

$ cat foo.cc

#include <iostream>
int main(int argc, char *argv[]) {
    for(int i=0; i < argc; i++)
        std::cout << " " << argv[i];
    return 0;
}

$ g++ -fno-stack-protector -O2 foo.cc
$ readelf -s a.out | grep chk
    15: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __stack_chk_fail (5)
   105: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __stack_chk_fail@@GLIBC_2

Do you know why this happens (and why only with -O)?

Comment 2 Jakub Jelinek 2013-09-12 18:00:41 UTC
This is indeend not a bug, libstdc++_nonshared.a (and other libraries) are intentionally built with -fstack-protector for security reasons.
Developer Toolset is not the product to use if you want to build on newer RHEL and deploy on older RHEL, after all the system libstdc++.so.6 on RHEL4 doesn't have many of the symbols you might need and DTS on RHEL5 depends on.
To build (limited amount of) programs on RHEL5 that can run on RHEL4 you need to use compat-gcc-34 and compat-glibc packages and gcc34 or g++34.

Comment 3 Marcin Wojdyr 2013-09-12 18:17:30 UTC
aha, I just didn't know that *_nonshared.a archives are linked, I thought that everything is in shared libraries. Thanks for explanation.


Note You need to log in before you can comment on or make changes to this bug.