Bug 822312 - -fstack-protector-all results in dynamic dependency on libssp-0.dll
-fstack-protector-all results in dynamic dependency on libssp-0.dll
Status: CLOSED WONTFIX
Product: Fedora
Classification: Fedora
Component: mingw-gcc (Show other bugs)
17
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Erik van Pienbroek
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-05-16 23:19 EDT by Gregory Maxwell
Modified: 2013-08-01 13:03 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-08-01 13:03:21 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Gregory Maxwell 2012-05-16 23:19:15 EDT
When building a package which specifies -fstack-protector-all in CFLAGS/LDFLAGs the resulting mingw32 binary needs libssp-0.dll.  No amount of -static / -Wl,-static -lssp makes it statically link it.

The extra dependency is a bit of a nuance especially when building DLLs, and native -fstack-protector-all binaries don't have this behavior.

To reproduce, take a package that turns on stack protector as part of its autoconf setup (http://opus-codec.org/ for example) and mingw32-configure it.
Comment 1 Erik van Pienbroek 2012-05-17 10:00:03 EDT
I just tried to reproduce this here, but it seems to work as expected with mingw32-gcc-4.7.0-2.fc17.x86_64:

$ cat test.c
#include <stdio.h>

int main(int argc, char **argv)
{
	printf("Hello world\n");
	return 0;
}

$ i686-w64-mingw32-gcc test.c -o test.exe -fstack-protector-all
$ i686-w64-mingw32-objdump -p test.exe | grep "DLL Name"
	DLL Name: KERNEL32.dll
	DLL Name: msvcrt.dll
	DLL Name: libssp-0.dll

$ i686-w64-mingw32-gcc -static test.c -o test.exe -fstack-protector-all
$ i686-w64-mingw32-objdump -p test.exe | grep "DLL Name"
	DLL Name: KERNEL32.dll
	DLL Name: msvcrt.dll
	DLL Name: msvcrt.dll
Comment 2 Gregory Maxwell 2012-05-17 10:06:32 EDT
Hm. I'll see what distinguishes our test cases and report back… since being able to manually make it static would be a big improvement.

But I don't believe that libssp-0 being static with -static is the expected behavior in any case. That would be like dynamically linking libgcc.   On the native Linux binaries you never see libssp dynamically linked.
Comment 3 Kai Tietz 2012-05-18 10:03:05 EDT
hmm, by using '-static' option on gcc's frontend, it is absolutely to be expected that only the static-libraries are linked.  This is true as long as there is a .dll.a and a .a library of same name present.
Comment 4 Gregory Maxwell 2012-05-18 10:41:29 EDT
To clarify: I mean I expect ssp to be static no matter if -static is set or not.
Comment 5 Kai Tietz 2012-05-18 12:30:13 EDT
This expectation is not correct.  By default gcc uses shared (means on Windoze DLL) libraries.  As libssp is built as DLL version and as static version, of course it uses by default the shared one.
If you want to force static version of a library, then you need to add it explicit to the linker.  Also be aware that in combination with libtool things might get weird about static/shared, too.
Comment 6 Gregory Maxwell 2012-05-18 12:40:43 EDT
If you say so— though this simply isn't the behavior it has on native binaries:

[gmaxwell@helmholtz tmp]$ gcc test.c -o test -fstack-protector-all
[gmaxwell@helmholtz tmp]$ ldd test
        linux-vdso.so.1 =>  (0x00007fffc618e000)
        libc.so.6 => /lib64/libc.so.6 (0x00000038ef600000)
        /lib64/ld-linux-x86-64.so.2 (0x00000038ef200000)

Though yes indeed, it confuses the heck out of libtool which actually was my problem in getting it to produce a static binary— intermediate libraries were introducing the dynamic dependency when -static was only set at the final linking stage.
Comment 7 Fedora End Of Life 2013-07-04 01:48:49 EDT
This message is a reminder that Fedora 17 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 17. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '17'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 17's end of life.

Bug Reporter:  Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 17 is end of life. If you 
would still like  to see this bug fixed and are able to reproduce it 
against a later version  of Fedora, you are encouraged  change the 
'version' to a later Fedora version prior to Fedora 17's end of life.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.
Comment 8 Fedora End Of Life 2013-08-01 13:03:26 EDT
Fedora 17 changed to end-of-life (EOL) status on 2013-07-30. Fedora 17 is 
no longer maintained, which means that it will not receive any further 
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
Fedora please feel free to reopen this bug against that version.

Thank you for reporting this bug and we are sorry it could not be fixed.

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