Bug 1007528 - devtoolset-1.1: __stack_chk_fail referenced despite of -fno-stack-protector
devtoolset-1.1: __stack_chk_fail referenced despite of -fno-stack-protector
Product: Red Hat Developer Toolset
Classification: Red Hat
Component: gcc (Show other bugs)
DTS 1.1 RHEL 5
All Linux
unspecified Severity low
: ---
: 2.4
Assigned To: Jakub Jelinek
Martin Cermak
Depends On:
  Show dependency treegraph
Reported: 2013-09-12 12:56 EDT by Marcin Wojdyr
Modified: 2013-09-12 14:17 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2013-09-12 14:00:41 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Marcin Wojdyr 2013-09-12 12:56:47 EDT
(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@GLIBC_2.4.
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@GLIBC_2.4 (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 14:00:41 EDT
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 14:17:30 EDT
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.