public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/98210] New: SHF_GNU_RETAIN breaks gold linker generated binaries
@ 2020-12-09  7:46 amodra at gmail dot com
  2020-12-09  9:06 ` [Bug target/98210] [11 Regression] " rguenth at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: amodra at gmail dot com @ 2020-12-09  7:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98210

            Bug ID: 98210
           Summary: SHF_GNU_RETAIN breaks gold linker generated binaries
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: amodra at gmail dot com
  Target Milestone: ---

gcc.dg/split-1.exe and other split-stack executables broke recently on
powerpc64le-linux, most likely due to git commit 6fbec038f7a7.

I see

  [22] .init_array       INIT_ARRAY      000000001001fda8 00fda8 000008 08 WAo 
0   0  8
  [23] .init_array       INIT_ARRAY      000000001001fdb0 00fdb0 000010 00  WA 
0   0  8

and in dynamic tags

 0x0000000000000019 (INIT_ARRAY)         0x1001fda8
 0x000000000000001b (INIT_ARRAYSZ)       8 (bytes)
 0x0000000000000019 (INIT_ARRAY)         0x1001fdb0
 0x000000000000001b (INIT_ARRAYSZ)       16 (bytes)

ld.so won't handle multiple tags like this, and symbols __init_array_start and
__init_array_end are defined to cover just the first .init_array section.

The same thing happens on x86_64 when using gold, objects like crtbegin.o that
have .init_array with "WAR" flags create separate .init_array output sections
if being linked with glibc files containing .init_array without the "R" flag.

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

* [Bug target/98210] [11 Regression] SHF_GNU_RETAIN breaks gold linker generated binaries
  2020-12-09  7:46 [Bug target/98210] New: SHF_GNU_RETAIN breaks gold linker generated binaries amodra at gmail dot com
@ 2020-12-09  9:06 ` rguenth at gcc dot gnu.org
  2020-12-09 13:12 ` hjl.tools at gmail dot com
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-12-09  9:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98210

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.0
            Summary|SHF_GNU_RETAIN breaks gold  |[11 Regression]
                   |linker generated binaries   |SHF_GNU_RETAIN breaks gold
                   |                            |linker generated binaries

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

* [Bug target/98210] [11 Regression] SHF_GNU_RETAIN breaks gold linker generated binaries
  2020-12-09  7:46 [Bug target/98210] New: SHF_GNU_RETAIN breaks gold linker generated binaries amodra at gmail dot com
  2020-12-09  9:06 ` [Bug target/98210] [11 Regression] " rguenth at gcc dot gnu.org
@ 2020-12-09 13:12 ` hjl.tools at gmail dot com
  2020-12-09 22:53 ` amodra at gmail dot com
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: hjl.tools at gmail dot com @ 2020-12-09 13:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98210

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |MOVED
           See Also|                            |https://sourceware.org/bugz
                   |                            |illa/show_bug.cgi?id=27039
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
Moved.

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

* [Bug target/98210] [11 Regression] SHF_GNU_RETAIN breaks gold linker generated binaries
  2020-12-09  7:46 [Bug target/98210] New: SHF_GNU_RETAIN breaks gold linker generated binaries amodra at gmail dot com
  2020-12-09  9:06 ` [Bug target/98210] [11 Regression] " rguenth at gcc dot gnu.org
  2020-12-09 13:12 ` hjl.tools at gmail dot com
@ 2020-12-09 22:53 ` amodra at gmail dot com
  2020-12-09 23:00 ` hjl.tools at gmail dot com
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: amodra at gmail dot com @ 2020-12-09 22:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98210

Alan Modra <amodra at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|MOVED                       |---
             Status|RESOLVED                    |REOPENED
   Last reconfirmed|                            |2020-12-09
     Ever confirmed|0                           |1

--- Comment #2 from Alan Modra <amodra at gmail dot com> ---
When the gold patch goes in, gcc should have a configure test such that the
combination of gold being the default linker and SHF_GNU_RETAIN support should
not be allowed unless gold has the patch.  And even if gold is not the default
linker it is required for split-stack go support, so go being compiled also
ought to trigger a dependence on gold being recent enough.

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

* [Bug target/98210] [11 Regression] SHF_GNU_RETAIN breaks gold linker generated binaries
  2020-12-09  7:46 [Bug target/98210] New: SHF_GNU_RETAIN breaks gold linker generated binaries amodra at gmail dot com
                   ` (2 preceding siblings ...)
  2020-12-09 22:53 ` amodra at gmail dot com
@ 2020-12-09 23:00 ` hjl.tools at gmail dot com
  2020-12-15 15:23 ` jozefl at gcc dot gnu.org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: hjl.tools at gmail dot com @ 2020-12-09 23:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98210

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jozef.l at somniumtech dot com

--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> ---
Jozef, SHF_GNU_RETAIN is yours.

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

* [Bug target/98210] [11 Regression] SHF_GNU_RETAIN breaks gold linker generated binaries
  2020-12-09  7:46 [Bug target/98210] New: SHF_GNU_RETAIN breaks gold linker generated binaries amodra at gmail dot com
                   ` (3 preceding siblings ...)
  2020-12-09 23:00 ` hjl.tools at gmail dot com
@ 2020-12-15 15:23 ` jozefl at gcc dot gnu.org
  2020-12-15 15:34 ` hjl.tools at gmail dot com
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jozefl at gcc dot gnu.org @ 2020-12-15 15:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98210

--- Comment #4 from Jozef Lawrynowicz <jozefl at gcc dot gnu.org> ---
Since gold is not built by default, should we just disable SHF_GNU_RETAIN
support if gold has been built at all, for Binutils versions without the gold
patch.

There's 2 weeks between the GCC "used" implying SHF_GNU_RETAIN patch and gold
being fixed, so the real fix if you want SHF_GNU_RETAIN support but are using a
Binutils version in this timeframe is to just upgrade. Meanwhile we should just
completely turn off SHF_GNU_RETAIN if GCC can spot that a broken gold is
available.

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

* [Bug target/98210] [11 Regression] SHF_GNU_RETAIN breaks gold linker generated binaries
  2020-12-09  7:46 [Bug target/98210] New: SHF_GNU_RETAIN breaks gold linker generated binaries amodra at gmail dot com
                   ` (4 preceding siblings ...)
  2020-12-15 15:23 ` jozefl at gcc dot gnu.org
@ 2020-12-15 15:34 ` hjl.tools at gmail dot com
  2020-12-16 18:41 ` jozefl at gcc dot gnu.org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: hjl.tools at gmail dot com @ 2020-12-15 15:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98210

--- Comment #5 from H.J. Lu <hjl.tools at gmail dot com> ---
Since gold has been fixed now, you can add a check for broken gold and set
HAVE_GAS_SHF_GNU_RETAIN to 0 for broken gold.

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

* [Bug target/98210] [11 Regression] SHF_GNU_RETAIN breaks gold linker generated binaries
  2020-12-09  7:46 [Bug target/98210] New: SHF_GNU_RETAIN breaks gold linker generated binaries amodra at gmail dot com
                   ` (5 preceding siblings ...)
  2020-12-15 15:34 ` hjl.tools at gmail dot com
@ 2020-12-16 18:41 ` jozefl at gcc dot gnu.org
  2021-01-14 11:04 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jozefl at gcc dot gnu.org @ 2020-12-16 18:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98210

--- Comment #6 from Jozef Lawrynowicz <jozefl at gcc dot gnu.org> ---
I've posted a patch where the HAVE_GAS_SHF_GNU_RETAIN configure test has been
extended to check for SHF_GNU_RETAIN gold support:
https://gcc.gnu.org/pipermail/gcc-patches/2020-December/562100.html

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

* [Bug target/98210] [11 Regression] SHF_GNU_RETAIN breaks gold linker generated binaries
  2020-12-09  7:46 [Bug target/98210] New: SHF_GNU_RETAIN breaks gold linker generated binaries amodra at gmail dot com
                   ` (6 preceding siblings ...)
  2020-12-16 18:41 ` jozefl at gcc dot gnu.org
@ 2021-01-14 11:04 ` rguenth at gcc dot gnu.org
  2021-01-29 21:53 ` segher at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-01-14 11:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98210

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1

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

* [Bug target/98210] [11 Regression] SHF_GNU_RETAIN breaks gold linker generated binaries
  2020-12-09  7:46 [Bug target/98210] New: SHF_GNU_RETAIN breaks gold linker generated binaries amodra at gmail dot com
                   ` (7 preceding siblings ...)
  2021-01-14 11:04 ` rguenth at gcc dot gnu.org
@ 2021-01-29 21:53 ` segher at gcc dot gnu.org
  2021-02-19 11:21 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: segher at gcc dot gnu.org @ 2021-01-29 21:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98210

Segher Boessenkool <segher at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |segher at gcc dot gnu.org

--- Comment #7 from Segher Boessenkool <segher at gcc dot gnu.org> ---
This also needs a backport to 10?  Can someone please fill in the
known_to_{work,fail} fields?

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

* [Bug target/98210] [11 Regression] SHF_GNU_RETAIN breaks gold linker generated binaries
  2020-12-09  7:46 [Bug target/98210] New: SHF_GNU_RETAIN breaks gold linker generated binaries amodra at gmail dot com
                   ` (8 preceding siblings ...)
  2021-01-29 21:53 ` segher at gcc dot gnu.org
@ 2021-02-19 11:21 ` jakub at gcc dot gnu.org
  2021-02-19 12:40 ` jozefl at gcc dot gnu.org
  2021-02-19 17:20 ` jozefl at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-02-19 11:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98210

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Isn't this problem gone with r11-7284-g6347f4a0904fce17eedf5c071be6f3c118680290
?
I mean, attribute used now means what it used to mean before, and retain
attribute is not used in whatever is emitted into .init_array section at least
in existing code.  Yes, one might use it in user code, but the answer can be
don't do it then.

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

* [Bug target/98210] [11 Regression] SHF_GNU_RETAIN breaks gold linker generated binaries
  2020-12-09  7:46 [Bug target/98210] New: SHF_GNU_RETAIN breaks gold linker generated binaries amodra at gmail dot com
                   ` (9 preceding siblings ...)
  2021-02-19 11:21 ` jakub at gcc dot gnu.org
@ 2021-02-19 12:40 ` jozefl at gcc dot gnu.org
  2021-02-19 17:20 ` jozefl at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: jozefl at gcc dot gnu.org @ 2021-02-19 12:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98210

--- Comment #9 from Jozef Lawrynowicz <jozefl at gcc dot gnu.org> ---
I believe this PR only relates to the fact that GCC support for SHF_GNU_RETAIN
was available before GOLD supported that section flag.

My proposed patch was to turn off GCC support for SHF_GNU_RETAIN if an
unsupported GOLD is detected.

I think at this point, the GOLD functionality was only broken for such a narrow
period of time in development (not corresponding to a concrete version of
Binutils), there's no point adding a configure test to try and catch that now.

(In reply to Jakub Jelinek from comment #8)
> Isn't this problem gone with
> r11-7284-g6347f4a0904fce17eedf5c071be6f3c118680290 ?
> I mean, attribute used now means what it used to mean before, and retain
> attribute is not used in whatever is emitted into .init_array section at
> least in existing code.  Yes, one might use it in user code, but the answer
> can be don't do it then.

And yes, since none of the libraries using the "used" attribute will implicitly
create SHF_GNU_RETAIN sections any more, even if you used the Binutils version
with broken GOLD, it won't cause any problems.

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

* [Bug target/98210] [11 Regression] SHF_GNU_RETAIN breaks gold linker generated binaries
  2020-12-09  7:46 [Bug target/98210] New: SHF_GNU_RETAIN breaks gold linker generated binaries amodra at gmail dot com
                   ` (10 preceding siblings ...)
  2021-02-19 12:40 ` jozefl at gcc dot gnu.org
@ 2021-02-19 17:20 ` jozefl at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: jozefl at gcc dot gnu.org @ 2021-02-19 17:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98210

Jozef Lawrynowicz <jozefl at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |WONTFIX
             Status|REOPENED                    |RESOLVED

--- Comment #10 from Jozef Lawrynowicz <jozefl at gcc dot gnu.org> ---
I think its best to close this as WONTFIX.

GCC will only erroneously enable SHF_GNU_RETAIN support if a Binutils version
between:
> commit 99fabbc9739a87ba3433e66792e93b773896790e
> Author: Jozef Lawrynowicz <jozef.l@mittosystems.com>
> Date:   Wed Nov 18 11:51:13 2020 +0000
>
>    Support SHF_GNU_RETAIN ELF section flag

and

> commit ff4bc37d77a0ca7286883a477adcb3aa145fc782
> Author: Cary Coutant <ccoutant@gmail.com>
> Date:   Mon Dec 14 15:46:47 2020 -0800
> 
>     Keep input SHF_GNU_RETAIN sections and strip output SHF_GNU_RETAIN for GNU/FreBSD ELFOSABIs.

is being used. There's no Binutils release in this range.

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

end of thread, other threads:[~2021-02-19 17:20 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-09  7:46 [Bug target/98210] New: SHF_GNU_RETAIN breaks gold linker generated binaries amodra at gmail dot com
2020-12-09  9:06 ` [Bug target/98210] [11 Regression] " rguenth at gcc dot gnu.org
2020-12-09 13:12 ` hjl.tools at gmail dot com
2020-12-09 22:53 ` amodra at gmail dot com
2020-12-09 23:00 ` hjl.tools at gmail dot com
2020-12-15 15:23 ` jozefl at gcc dot gnu.org
2020-12-15 15:34 ` hjl.tools at gmail dot com
2020-12-16 18:41 ` jozefl at gcc dot gnu.org
2021-01-14 11:04 ` rguenth at gcc dot gnu.org
2021-01-29 21:53 ` segher at gcc dot gnu.org
2021-02-19 11:21 ` jakub at gcc dot gnu.org
2021-02-19 12:40 ` jozefl at gcc dot gnu.org
2021-02-19 17:20 ` jozefl at gcc dot gnu.org

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).