Bug 788107 - latest binutils seems to introduce problems with -Wl,--gc-sections
Summary: latest binutils seems to introduce problems with -Wl,--gc-sections
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: binutils
Version: rawhide
Hardware: All
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Nick Clifton
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 788300 788304 789137 (view as bug list)
Depends On:
Blocks: F17Alpha, F17AlphaBlocker
TreeView+ depends on / blocked
 
Reported: 2012-02-07 13:45 UTC by Kay Sievers
Modified: 2012-02-11 06:23 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-02-09 12:20:49 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
old (6.59 KB, application/octet-stream)
2012-02-07 14:20 UTC, Kay Sievers
no flags Details
new (6.46 KB, application/octet-stream)
2012-02-07 14:20 UTC, Kay Sievers
no flags Details

Description Kay Sievers 2012-02-07 13:45:17 UTC
We encounter failures in binaries using program_invocation_short_name, which
seems to be NULL now for some reason.

Here is a test log of the recent and the older gcc:

# cat argv.c
#define _GNU_SOURCE
#include <errno.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
	printf("%s\n", argv[0]);
	printf("%s\n", program_invocation_name);
	printf("%s\n", program_invocation_short_name);
	return 0;
}


# gcc --version
gcc (GCC) 4.7.0 20120206 (Red Hat 4.7.0-0.11)
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@mop stuff]# gcc -Wall -Wl,--gc-sections -O2 -o argv argv.c
[root@mop stuff]# ./argv
./argv
Segmentation fault (core dumped)


# gcc --version
gcc (GCC) 4.7.0 20120123 (Red Hat 4.7.0-0.9)
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@mop stuff]# gcc -Wall -Wl,--gc-sections -O2 -o argv argv.c
[root@mop stuff]# ./argv
./argv
./argv
argv

Comment 1 Jakub Jelinek 2012-02-07 13:53:38 UTC
Is that with the same version of glibc?  I certainly don't see any differences in compiled code.

Comment 2 Kay Sievers 2012-02-07 14:20:23 UTC
Created attachment 559966 [details]
old

The new gcc compile fails running on the new glibc.
The new gcc compile fails running on the old glibc.

The old gcc compile is fine running on the new glibc.
The old gcc compile is fine running on the old glibc.

Attaching the two binaries.

Also note:
The new gcc is on a system, where /lib, /bin, ... are symlinks to /usr.
Maybe that causes some trouble ...

Comment 3 Kay Sievers 2012-02-07 14:20:52 UTC
Created attachment 559967 [details]
new

Comment 4 Jakub Jelinek 2012-02-07 14:32:36 UTC
That doesn't look like a gcc bug, the generated code is still the same, just the linker behaved differently (didn't apparently create copy relocs).
You can link with -Wl,-M to see what exactly has been linked into it in each case.
The UsrMove is a huge mess and mistake IMHO.

Comment 5 Michal Schmidt 2012-02-07 16:38:16 UTC
The testcase works fine when built with binutils-2.22-4.fc17.
It is broken when built with binutils-2.22.52.0.1-2.fc17.
I'm changing nothing else in the system.

Comment 6 Kay Sievers 2012-02-07 16:58:07 UTC
This is a test on the same file system, just with the old and the new
binutils installed. The generated binary works only with the old version
of binutils. I can reliably reproduce the behaviour just by switching
between the two binutil versions.

[root@mop stuff]# ld --version
GNU ld version 2.22
Copyright 2011 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
[root@mop stuff]# 
[root@mop stuff]# 
[root@mop stuff]# gcc -Wall -Wl,--gc-sections -O2 -o argv argv.c
[root@mop stuff]# ./argv
./argv
./argv
argv


[root@mop stuff]# ld --version
GNU ld version 2.22.52.0.1-2.fc17 20120131
Copyright 2012 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
[root@mop stuff]# 
[root@mop stuff]# gcc -Wall -Wl,--gc-sections -O2 -o argv argv.c
[root@mop stuff]# ./argv
./argv
Segmentation fault (core dumped)

Comment 7 Michal Schmidt 2012-02-07 17:06:09 UTC
systemd is affected and we don't know what else is miscompiled.
Proposing as F17 Alpha blocker.

Comment 8 Michal Schmidt 2012-02-07 17:30:13 UTC
The specific Alpha release criterion that this breaks is this one:

  21. It must be possible to trigger a system shutdown using standard console
      commands, [...]

'reboot', 'poweroff' do not work because they are symlinks to systemctl, which relies on program_invocation_short_name to know what to do.
'init 0' causes a segfault.

Comment 9 Michal Schmidt 2012-02-07 22:34:23 UTC
Andre, this is not specific to x86_64, it affects i686 too.
[Platform: x86_64 -> All]

Comment 10 Kay Sievers 2012-02-08 01:18:54 UTC
*** Bug 788300 has been marked as a duplicate of this bug. ***

Comment 11 Kay Sievers 2012-02-08 03:56:02 UTC
*** Bug 788304 has been marked as a duplicate of this bug. ***

Comment 12 Michal Schmidt 2012-02-08 15:36:59 UTC
This looks related: "Fix -gc-sections related abort":
http://cygwin.com/ml/binutils/2012-02/msg00056.html

Comment 13 Michal Schmidt 2012-02-08 16:14:15 UTC
(In reply to comment #12)
> This looks related: "Fix -gc-sections related abort":
> http://cygwin.com/ml/binutils/2012-02/msg00056.html

I made local mockbuild of binutils with the patch. It fixes the bug for me.

Comment 14 Michal Schmidt 2012-02-08 16:29:16 UTC
The patch is applied upstream:

http://sourceware.org/git/?p=binutils.git;a=commitdiff;h=f5edd1ac0e79c0356c6a1e2beffcadc0c532be98

Comment 15 Michal Schmidt 2012-02-09 12:20:49 UTC
Adam Williamson applied the fix to binutils already and rebuilt systemd with it:

$ koji latest-pkg f17 binutils systemd 
Build                                     Tag                   Built by
----------------------------------------  --------------------  ----------------
binutils-2.22.52.0.1-4.fc17               f17                   adamwill
systemd-41-2.fc17                         f17                   adamwill

Comment 16 Michal Schmidt 2012-02-10 10:34:28 UTC
*** Bug 789137 has been marked as a duplicate of this bug. ***

Comment 17 kevin martin 2012-02-10 19:57:36 UTC
updating to latest systemd / binutils seems to have fixed that problem.  Now if I can just figure out why my reboot drops to a dracut prompt every time instead of getting all the way to a grub menu....

Comment 18 Michal Schmidt 2012-02-11 00:19:33 UTC
(In reply to comment #17)
Your initramfs image may still contain the broken version of systemctl. Regenerate the image with 'dracut -f'.

Comment 19 Michal Jaegermann 2012-02-11 06:23:32 UTC
(In reply to comment #18)
> (In reply to comment #17)
>> I can just figure out why my reboot drops to a dracut prompt every time instead
>> of getting all the way to a grub menu....
> Your initramfs image may still contain the broken version of systemctl.

Or you bumped into bug 789119.  There is a patch in comments there if this is the case.


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