This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] PR ld/19579: [Regression] link error linking fortran code with PIE
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Alan Modra <amodra at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Mon, 7 Mar 2016 10:44:29 -0800
- Subject: Re: [PATCH] PR ld/19579: [Regression] link error linking fortran code with PIE
- Authentication-results: sourceware.org; auth=none
- References: <20160304134833 dot GA11350 at gmail dot com> <20160305015242 dot GE9617 at bubble dot grove dot modra dot org> <CAMe9rOq=mgfjaFgAdw=u3dzvtt3sG519Pipy4VyyPS1T3+GJSA at mail dot gmail dot com> <20160307152818 dot GH9617 at bubble dot grove dot modra dot org>
On Mon, Mar 7, 2016 at 7:28 AM, Alan Modra <amodra@gmail.com> wrote:
> On Fri, Mar 04, 2016 at 07:41:42PM -0800, H.J. Lu wrote:
>> On Fri, Mar 4, 2016 at 5:52 PM, Alan Modra <amodra@gmail.com> wrote:
>> > On Fri, Mar 04, 2016 at 05:48:33AM -0800, H.J. Lu wrote:
>> >> --- a/bfd/elflink.c
>> >> +++ b/bfd/elflink.c
>> >> @@ -1172,9 +1172,12 @@ _bfd_elf_merge_symbol (bfd *abfd,
>> >>
>> >> newdef = !bfd_is_und_section (sec) && !bfd_is_com_section (sec);
>> >>
>> >> + /* The old common symbol in executable is a definition if the new
>> >> + definition comes from a shared library. */
>> >> olddef = (h->root.type != bfd_link_hash_undefined
>> >> && h->root.type != bfd_link_hash_undefweak
>> >> - && h->root.type != bfd_link_hash_common);
>> >> + && (h->root.type != bfd_link_hash_common
>> >> + || (!olddyn && newdyn && bfd_link_executable (info))));
>> >>
>> >> /* NEWFUNC and OLDFUNC indicate whether the new or old symbol,
>> >> respectively, appear to be a function. */
>> >
>> > Why is this the correct place to change, and not code after the
>> > comment "We treat a common symbol as a definition"?
>>
>> olddef has been checked well before that.
>
> And do any of those matter?
[hjl@gnu-6 pr19579b]$ cat foo.c
__thread int foo[2];
[hjl@gnu-6 pr19579b]$ cat x.c
#include <stdio.h>
int foo[1];
int
main ()
{
if (foo[0] == 0)
printf ("PASS\n");
return 0;
}
[hjl@gnu-6 pr19579b]$ make
gcc -pie -B./ -fPIE -O0 -c -o x.o x.c
gcc -pie -B./ -fPIE -O0 -fPIC -c -o foo.o foo.c
gcc -pie -B./ -shared -o libfoo.so foo.o
gcc -pie -B./ -o x x.o libfoo.so -Wl,-R.
./ld: foo: TLS definition in libfoo.so section .tbss mismatches
non-TLS reference in x.o
libfoo.so: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
Makefile:17: recipe for target 'x' failed
make: *** [x] Error 1
vs
[hjl@gnu-6 pr19579b]$ gcc -pie -o x x.o libfoo.so -Wl,-R.
/usr/local/bin/ld: foo: TLS definition in libfoo.so section .tbss
mismatches non-TLS definition in x.o section COMMON
libfoo.so: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
[hjl@gnu-6 pr19579b]$
>> We need to get it right.
>
> That's why I asked. You haven't yet replied with anything more than a
> superficial reason for not moving the change to where it ought to go,
> I think.
The old common symbol is a definition in this case. Why shouldn't
olddef set to yes?
--
H.J.