public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Avoid link error with Solaris ld and local COMDAT group signature symbols (PR gas/12181)
@ 2010-11-10 12:50 Rainer Orth
  2010-11-11  2:03 ` Mark Mitchell
  0 siblings, 1 reply; 10+ messages in thread
From: Rainer Orth @ 2010-11-10 12:50 UTC (permalink / raw)
  To: binutils; +Cc: Mark Mitchell

As reported in PR gas/12181, this patch

2010-10-23  Mark Mitchell  <mark@codesourcery.com>

	* config/obj-elf.c (elf_adjust_symtab): New.  Move group section
	processing here from elf_frob_file.  Ensure that group signature
	symbols have the name of the group.
	(elf_frob_file): Move group section processing to
	elf_adjust_symtab.
	* config/obj-elf.h (elf_adjust_symtab): Declare.
	(obj_adjust_symtab): Define.
	* config/tc-arm.c (arm_adjust_symtab): Call elf_adjust_symtab.

broke GCC mainline bootstrap on Solaris 11 with CVS gas and Sun ld.

The problem is seen with this testcase:

$ cat group.s
	.section	.text.D2Ev,"axG",@progbits,D5Ev,comdat
	.type	D2Ev, @function
D2Ev:
	.section	.text.D0Ev,"axG",@progbits,D5Ev,comdat
	.type	D0Ev, @function
D0Ev:
$  gas -o group.o group.s
$ ld -G -o group.so group.o
ld: fatal: file group.o: group section [1].group: invalid group symbol D5Ev
ld: fatal: file group.o: section [1].group: SHF_GROUP flag set, but no
corresponding SHT_GROUP section found
ld: fatal: file group.o: section [5].text.D2Ev: SHF_GROUP flag set, but no
corresponding SHT_GROUP section found
ld: fatal: file group.o: section [6].text.D0Ev: SHF_GROUP flag set, but no
corresponding SHT_GROUP section found
ld: fatal: file processing errors. No output written to group.so

Currently, ld chokes on the local group signature symbol.

While the Solaris linker maintainers are willing to change ld,
unfortunately nobody cared to comment on their analysis in the PR.
Could someone (Mark?) please to so to get some progress on the Sun ld
side of things?

On the other hand, this doesn't help for existing installations.  To
remedy this, I've tried my idea to make the group signature symbol
global hidden instead of local, and this worked without problems.

Therefore I'd like to propose the following patch, both for mainline and
the 2.21 branch:

2010-11-10  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	gas:
	PR gas/12181
	* config/obj-elf.c (elf_adjust_symtab): Make sy global hidden.

diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index 79f8033..34d11fe 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -2142,7 +2142,8 @@ elf_adjust_symtab (void)
 	{
 	  /* Create the symbol now.  */
 	  sy = symbol_new (group_name, now_seg, (valueT) 0, frag_now);
-	  symbol_get_obj (sy)->local = 1;
+	  symbol_get_bfdsym (sy)->flags |= BSF_OBJECT | BSF_GLOBAL;
+	  S_SET_OTHER (sy, STV_HIDDEN);
 	  symbol_table_insert (sy);
 	}
       elf_group_id (s) = symbol_get_bfdsym (sy);

Mainline GCC bootstrap with CVS gas and gld worked, and a bootstrap with
gas and Sun ld allowed libstdc++.so to link.  It later failed linking
various libjava tools against libgcj.so, but this is an artefact of the
Solaris symbol versioning support in GCC: the contrib/make_sunver.pl
script currently uses nm and doesn't take symbol visibility support into
account, so a global hidden symbol becomes global with default
visibility in libgcj.so.  I'm working to use elfdump -s instead of nm
there, both to avoid this issue and because it has become obvious that
the nm-based variant is very fragile.

Ok for mainline and 2.21 branch?

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Avoid link error with Solaris ld and local COMDAT group signature symbols (PR gas/12181)
  2010-11-10 12:50 Avoid link error with Solaris ld and local COMDAT group signature symbols (PR gas/12181) Rainer Orth
@ 2010-11-11  2:03 ` Mark Mitchell
  2010-11-11 20:27   ` Rainer Orth
  2010-11-15 19:49   ` Rainer Orth
  0 siblings, 2 replies; 10+ messages in thread
From: Mark Mitchell @ 2010-11-11  2:03 UTC (permalink / raw)
  To: Rainer Orth; +Cc: binutils

On 11/10/2010 4:50 AM, Rainer Orth wrote:

> 2010-10-23  Mark Mitchell  <mark@codesourcery.com>

> broke GCC mainline bootstrap on Solaris 11 with CVS gas and Sun ld.

I've been insanely busy for the last couple of weeks, so I haven't been
paying as close attention as I should have been.  I'm very sorry.

> While the Solaris linker maintainers are willing to change ld,
> unfortunately nobody cared to comment on their analysis in the PR.
> Could someone (Mark?) please to so to get some progress on the Sun ld
> side of things?

I've now commented in the PR.

> -	  symbol_get_obj (sy)->local = 1;
> +	  symbol_get_bfdsym (sy)->flags |= BSF_OBJECT | BSF_GLOBAL;
> +	  S_SET_OTHER (sy, STV_HIDDEN);

FWIW, this seems like a hack to me.  I think the symbol really should be
local; why expose it to other systems?  If we want to do this for
Solaris ld compatibility (which I agree is a valid reason), I think we
should do conditionally on Solaris.

Thank you,

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Avoid link error with Solaris ld and local COMDAT group signature symbols (PR gas/12181)
  2010-11-11  2:03 ` Mark Mitchell
@ 2010-11-11 20:27   ` Rainer Orth
  2010-11-15 19:49   ` Rainer Orth
  1 sibling, 0 replies; 10+ messages in thread
From: Rainer Orth @ 2010-11-11 20:27 UTC (permalink / raw)
  To: Mark Mitchell; +Cc: binutils

Mark Mitchell <mark@codesourcery.com> writes:

> On 11/10/2010 4:50 AM, Rainer Orth wrote:
>
>> 2010-10-23  Mark Mitchell  <mark@codesourcery.com>
>
>> broke GCC mainline bootstrap on Solaris 11 with CVS gas and Sun ld.
>
> I've been insanely busy for the last couple of weeks, so I haven't been
> paying as close attention as I should have been.  I'm very sorry.

No problem.  I just wanted to make sure that we have some sort of
solution for binutils 2.21.

>> While the Solaris linker maintainers are willing to change ld,
>> unfortunately nobody cared to comment on their analysis in the PR.
>> Could someone (Mark?) please to so to get some progress on the Sun ld
>> side of things?
>
> I've now commented in the PR.

Thanks.  I'll pass that on; I'm confident this will be fixed in the
Solaris ld soon.

>> -	  symbol_get_obj (sy)->local = 1;
>> +	  symbol_get_bfdsym (sy)->flags |= BSF_OBJECT | BSF_GLOBAL;
>> +	  S_SET_OTHER (sy, STV_HIDDEN);
>
> FWIW, this seems like a hack to me.  I think the symbol really should be
> local; why expose it to other systems?  If we want to do this for
> Solaris ld compatibility (which I agree is a valid reason), I think we
> should do conditionally on Solaris.

Ok.  My reasoning for doing this in every case was that I wanted to
avoid target-specific code if we can do without.  I'll wrap the global
hidden change in #ifdef TE_SOLARIS with an appropriate comment (do we
list PRs in code comments for purposes like this?), retest and resubmit.

Thanks.
	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Avoid link error with Solaris ld and local COMDAT group signature symbols (PR gas/12181)
  2010-11-11  2:03 ` Mark Mitchell
  2010-11-11 20:27   ` Rainer Orth
@ 2010-11-15 19:49   ` Rainer Orth
  2010-11-15 19:50     ` Mark Mitchell
  2010-11-15 21:47     ` Alan Modra
  1 sibling, 2 replies; 10+ messages in thread
From: Rainer Orth @ 2010-11-15 19:49 UTC (permalink / raw)
  To: Mark Mitchell; +Cc: binutils

Mark Mitchell <mark@codesourcery.com> writes:

>> While the Solaris linker maintainers are willing to change ld,
>> unfortunately nobody cared to comment on their analysis in the PR.
>> Could someone (Mark?) please to so to get some progress on the Sun ld
>> side of things?
>
> I've now commented in the PR.

Thanks.  I've passed this on and the fill will appear in Solaris 11
build 154.

>> -	  symbol_get_obj (sy)->local = 1;
>> +	  symbol_get_bfdsym (sy)->flags |= BSF_OBJECT | BSF_GLOBAL;
>> +	  S_SET_OTHER (sy, STV_HIDDEN);
>
> FWIW, this seems like a hack to me.  I think the symbol really should be
> local; why expose it to other systems?  If we want to do this for
> Solaris ld compatibility (which I agree is a valid reason), I think we
> should do conditionally on Solaris.

Here's the patch that does this.  It allowed me too bootstrap GCC
mainline with both Sun ld (unfixed) and CVS GNU ld without regressions.

Ok for mainline and 2.2.1 branch now?

Thanks.
	Rainer


2010-11-10  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	PR gas/12181
	* config/obj-elf.c (elf_adjust_symtab) [TE_SOLARIS]: Make sy
	global hidden.

diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index 79f8033..4b84bdb 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -2142,7 +2142,14 @@ elf_adjust_symtab (void)
 	{
 	  /* Create the symbol now.  */
 	  sy = symbol_new (group_name, now_seg, (valueT) 0, frag_now);
+#ifdef TE_SOLARIS
+	  /* Before Solaris 11 build 154, Sun ld rejects local group
+	     signature symbols, so make them global hidden instead.  */
+	  symbol_get_bfdsym (sy)->flags |= BSF_OBJECT | BSF_GLOBAL;
+	  S_SET_OTHER (sy, STV_HIDDEN);
+#else
 	  symbol_get_obj (sy)->local = 1;
+#endif
 	  symbol_table_insert (sy);
 	}
       elf_group_id (s) = symbol_get_bfdsym (sy);

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Avoid link error with Solaris ld and local COMDAT group signature symbols (PR gas/12181)
  2010-11-15 19:49   ` Rainer Orth
@ 2010-11-15 19:50     ` Mark Mitchell
  2010-11-15 21:47     ` Alan Modra
  1 sibling, 0 replies; 10+ messages in thread
From: Mark Mitchell @ 2010-11-15 19:50 UTC (permalink / raw)
  To: Rainer Orth; +Cc: binutils

On 11/15/2010 11:48 AM, Rainer Orth wrote:

> Here's the patch that does this.  It allowed me too bootstrap GCC
> mainline with both Sun ld (unfixed) and CVS GNU ld without regressions.
> 
> Ok for mainline and 2.2.1 branch now?

It looks entirely reasonable to me, but for avoidance of doubt, I don't
have approval privileges.

Thank you,

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Avoid link error with Solaris ld and local COMDAT group signature symbols (PR gas/12181)
  2010-11-15 19:49   ` Rainer Orth
  2010-11-15 19:50     ` Mark Mitchell
@ 2010-11-15 21:47     ` Alan Modra
  2010-11-17 19:47       ` Rainer Orth
  1 sibling, 1 reply; 10+ messages in thread
From: Alan Modra @ 2010-11-15 21:47 UTC (permalink / raw)
  To: Rainer Orth; +Cc: Mark Mitchell, binutils

On Mon, Nov 15, 2010 at 08:48:33PM +0100, Rainer Orth wrote:
> +	  /* Before Solaris 11 build 154, Sun ld rejects local group
> +	     signature symbols, so make them global hidden instead.  */
> +	  symbol_get_bfdsym (sy)->flags |= BSF_OBJECT | BSF_GLOBAL;
> +	  S_SET_OTHER (sy, STV_HIDDEN);

It occurs to me that making the symbol BSF_GLOBAL may cause link
errors.  BSF_WEAK would be better, assuming that the Solaris linker
likes that.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Avoid link error with Solaris ld and local COMDAT group signature symbols (PR gas/12181)
  2010-11-15 21:47     ` Alan Modra
@ 2010-11-17 19:47       ` Rainer Orth
  2010-11-17 21:34         ` Alan Modra
  0 siblings, 1 reply; 10+ messages in thread
From: Rainer Orth @ 2010-11-17 19:47 UTC (permalink / raw)
  To: Mark Mitchell; +Cc: binutils

Alan Modra <amodra@gmail.com> writes:

> On Mon, Nov 15, 2010 at 08:48:33PM +0100, Rainer Orth wrote:
>> +	  /* Before Solaris 11 build 154, Sun ld rejects local group
>> +	     signature symbols, so make them global hidden instead.  */
>> +	  symbol_get_bfdsym (sy)->flags |= BSF_OBJECT | BSF_GLOBAL;
>> +	  S_SET_OTHER (sy, STV_HIDDEN);
>
> It occurs to me that making the symbol BSF_GLOBAL may cause link
> errors.  BSF_WEAK would be better, assuming that the Solaris linker
> likes that.

Works just as well, both for the testcase and GCC.  I've just
successfully bootstrapped GCC mainline on i386-pc-solaris2.11 with the
patch below.  I've omitted the BSF_OBJECT part since the non-Solaris
cases produced symbols with NOTYPE as well and it works fine this way.

Ok for mainline and 2.21 branch now?

Thanks.
	Rainer


2010-11-10  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	gas:
	PR gas/12181
	* config/obj-elf.c (elf_adjust_symtab) [TE_SOLARIS]: Make sy
	weak hidden.

diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index 8eb66ed..c6dc8d6 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -2142,7 +2142,14 @@ elf_adjust_symtab (void)
 	{
 	  /* Create the symbol now.  */
 	  sy = symbol_new (group_name, now_seg, (valueT) 0, frag_now);
+#ifdef TE_SOLARIS
+	  /* Before Solaris 11 build 154, Sun ld rejects local group
+	     signature symbols, so make them weak hidden instead.  */
+	  symbol_get_bfdsym (sy)->flags |= BSF_WEAK;
+	  S_SET_OTHER (sy, STV_HIDDEN);
+#else
 	  symbol_get_obj (sy)->local = 1;
+#endif
 	  symbol_table_insert (sy);
 	}
       elf_group_id (s) = symbol_get_bfdsym (sy);


-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Avoid link error with Solaris ld and local COMDAT group signature symbols (PR gas/12181)
  2010-11-17 19:47       ` Rainer Orth
@ 2010-11-17 21:34         ` Alan Modra
  2010-11-18  7:57           ` Tristan Gingold
  2018-02-18 18:15           ` H.J. Lu
  0 siblings, 2 replies; 10+ messages in thread
From: Alan Modra @ 2010-11-17 21:34 UTC (permalink / raw)
  To: Rainer Orth; +Cc: Mark Mitchell, binutils

On Wed, Nov 17, 2010 at 08:46:52PM +0100, Rainer Orth wrote:
> 	PR gas/12181
> 	* config/obj-elf.c (elf_adjust_symtab) [TE_SOLARIS]: Make sy
> 	weak hidden.

OK.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Avoid link error with Solaris ld and local COMDAT group signature symbols (PR gas/12181)
  2010-11-17 21:34         ` Alan Modra
@ 2010-11-18  7:57           ` Tristan Gingold
  2018-02-18 18:15           ` H.J. Lu
  1 sibling, 0 replies; 10+ messages in thread
From: Tristan Gingold @ 2010-11-18  7:57 UTC (permalink / raw)
  To: Rainer Orth; +Cc: Mark Mitchell, binutils, Alan Modra


On Nov 17, 2010, at 10:33 PM, Alan Modra wrote:

> On Wed, Nov 17, 2010 at 08:46:52PM +0100, Rainer Orth wrote:
>> 	PR gas/12181
>> 	* config/obj-elf.c (elf_adjust_symtab) [TE_SOLARIS]: Make sy
>> 	weak hidden.
> 
> OK.

Just in case, OK too for the branch.

Tristan.

> 
> -- 
> Alan Modra
> Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Avoid link error with Solaris ld and local COMDAT group signature symbols (PR gas/12181)
  2010-11-17 21:34         ` Alan Modra
  2010-11-18  7:57           ` Tristan Gingold
@ 2018-02-18 18:15           ` H.J. Lu
  1 sibling, 0 replies; 10+ messages in thread
From: H.J. Lu @ 2018-02-18 18:15 UTC (permalink / raw)
  To: Rainer Orth, Mark Mitchell, Binutils

On Wed, Nov 17, 2010 at 1:33 PM, Alan Modra <amodra@gmail.com> wrote:
> On Wed, Nov 17, 2010 at 08:46:52PM +0100, Rainer Orth wrote:
>>       PR gas/12181
>>       * config/obj-elf.c (elf_adjust_symtab) [TE_SOLARIS]: Make sy
>>       weak hidden.
>
> OK.
>

This is wrong and caused:

FAIL: ld-elf/pr22836-1a
FAIL: ld-elf/pr22836-1b

on Solaris.

-- 
H.J.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-02-18 18:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-10 12:50 Avoid link error with Solaris ld and local COMDAT group signature symbols (PR gas/12181) Rainer Orth
2010-11-11  2:03 ` Mark Mitchell
2010-11-11 20:27   ` Rainer Orth
2010-11-15 19:49   ` Rainer Orth
2010-11-15 19:50     ` Mark Mitchell
2010-11-15 21:47     ` Alan Modra
2010-11-17 19:47       ` Rainer Orth
2010-11-17 21:34         ` Alan Modra
2010-11-18  7:57           ` Tristan Gingold
2018-02-18 18:15           ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).