Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <SNT146-W38F973B7F18DE315F2B15FA84F0@phx.gbl>
Date: Tue, 6 May 2014 22:11:32 +0100
From: Stephen Thomas <scjthm@...e.com>
To: "musl@...ts.openwall.com" <musl@...ts.openwall.com>
Subject: RE: Linking musl with ld.gold

I think that I have managed to reproduce the problem, in as much isolation as possible. I believe that there is a missing step in your test, which is included in the build, and that is the creation of the archive. I may have done something incorrect also, which is also very likely.
I attach a simple script for running the tests on my machine. Unfortunately, the system I use doesn't display indicate where ld.gold was being used as it chooses to do this by changing the symlink to which ld points to.
To summari(s/z)e when using ar to create an archive the weak symbol doesn't appear to be overridden, using either ld.bfd nor ld.gold. The script that was used to generate the output is attached and this should describe the 4 test cases. Test case #2 is probably irrelevant, and the first two are simply reproducing the results of your tests.
Thomo
gt-bld / # binutils-config --linker ld.bfd * Setting default linker to ld.bfd for x86_64-pc-linux-gnu-2.24.51.0.3 ...     gt-bld / # /tmp/badar.sh ************************************************************Running with ...gcc (Gentoo 4.8.2-r1 p1.4-ssptest, pie-0.5.9-ssptest) 4.8.2Copyright (C) 2013 Free Software Foundation, Inc.This is free software; see the source for copying conditions.  There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
GNU ld (Linux/GNU Binutils) 2.24.51.0.3.20140127Copyright 2014 Free Software Foundation, Inc.This program is free software; you may redistribute it under the terms ofthe GNU General Public License version 3 or (at your option) a later version.This program has absolutely no warranty.************************************************************Case 0: 0************************************************************************************************************************Case 1: 42************************************************************ar: creating a.a
a.o:0000000000000000 r dummy0000000000000000 T f0000000000000000 V hasfoo************************************************************Case 2: 0************************************************************ar: creating a.a
a.o:0000000000000000 r dummy0000000000000000 T f0000000000000000 V hasfoo
b.o:0000000000000000 d foo0000000000000000 R hasfoo************************************************************Case 3: 0************************************************************gt-bld / # binutils-config --linker ld.gold * Setting default linker to ld.gold for x86_64-pc-linux-gnu-2.24.51.0.3 ...                                                                                                                                                            [ ok ]gt-bld / # /tmp/badar.sh ************************************************************Running with ...gcc (Gentoo 4.8.2-r1 p1.4-ssptest, pie-0.5.9-ssptest) 4.8.2Copyright (C) 2013 Free Software Foundation, Inc.This is free software; see the source for copying conditions.  There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
GNU gold (Linux/GNU Binutils 2.24.51.0.3.20140127) 1.11Copyright 2014 Free Software Foundation, Inc.This program is free software; you may redistribute it under the terms ofthe GNU General Public License version 3 or (at your option) a later version.This program has absolutely no warranty.************************************************************Case 0: 0************************************************************************************************************************Case 1: 42************************************************************ar: creating a.a
a.o:0000000000000000 r dummy0000000000000000 T f0000000000000000 V hasfoo************************************************************Case 2: 0************************************************************ar: creating a.a
a.o:0000000000000000 r dummy0000000000000000 T f0000000000000000 V hasfoo
b.o:0000000000000000 d foo0000000000000000 R hasfoo************************************************************Case 3: 0************************************************************ 

> Date: Tue, 6 May 2014 12:14:10 +0200
> From: nsz@...t70.net
> To: musl@...ts.openwall.com
> Subject: Re: [musl] Linking musl with ld.gold
> 
> * Stephen Thomas <scjthm@...e.com> [2014-05-06 10:07:59 +0100]:
> > I have come across a problem and it only appears when the gold linker is used. I am using the latest release of binutils, binutils-2.24.51.0.3.
> > I discovered that busybox was not flushing stdout (as there was no prompt appearing) when using musl. Busybox calls fflush(NULL) which should flush stdout as done in src/stdio/fflush.c. 
> > In that file I checked the value for __stdout_used and it came back as 0. So I changed the declaration of the weak symbol to an extern FILE* __stdout_used and stdout was being flushed.
> > Has anyone else seen this and have they reported this apparent bug in binutils?
> 
> 
> i think we only reported a broken tls visibility issue against gold
> https://sourceware.org/bugzilla/show_bug.cgi?id=16728
> 
> you should try to reproduce the bug on a minimal example, eg. the
> following code works here with gold (binutils 2.22)
> 
> // a.c
> struct foo {int i;};
> static struct foo *const dummy = 0;
> extern struct foo *const hasfoo __attribute__((weak, alias("dummy")));
> int f(void)
> {
>         return hasfoo ? hasfoo->i : 0;
> }
> // b.c
> struct foo {int i;};
> static struct foo foo = {42};
> struct foo *const hasfoo = &foo;
> // main.c
> int f(void);
> int main()
> {
>         return f();
> }
> 
> gcc main.o a.o -o t1
> gcc main.o a.o b.o -o t2
> ./t1 returns 0
> ./t2 returns 42
 		 	   		  
Content of type "text/html" skipped

Download attachment "badar.sh" of type "application/x-sh" (1898 bytes)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.