bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/27495] -z start_stop_gc isn't compatible with static glibc


From: amodra at gmail dot com
Subject: [Bug ld/27495] -z start_stop_gc isn't compatible with static glibc
Date: Wed, 03 Mar 2021 00:49:05 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=27495

Alan Modra <amodra at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|-z start_stop_gc isn't      |-z start_stop_gc isn't
                   |compatible with             |compatible with static
                   |--gc-sections               |glibc

--- Comment #7 from Alan Modra <amodra at gmail dot com> ---
Here is a testcase showing when -z start-stop-gc might be useful.  Imagine that
you want to add some per-function data to each function, and collect that data
in a table.  You use section groups naturally so that --gc-sections will remove
the per-function data along with the function code.  However, you find that
--gc-sections is not doing anything, because the reference to __start_xx that
you are using to access the table is marking all the xx sections and along with
them their code sections.

If you had control of the startup objects, you could add a __start_xx
definition in crt1.o and a __stop_xx in crtn.o to prevent the linker magic with
start/stop symbols.  Also, if you had control of the linker scripts, then you
could place an output xx section with __start_xx = .; and __stop_xx = .; around
the input xx sections which would also disable the linker magic..  But it is
likely you have control over neither.  Other work-arounds might be possible
too.

It is true that --start-stop-gc may break linking with current static glibc, a
fact that limits --start-stop-gc usefulness.

BTW, this testcase also shows an interaction between section groups and
start/stop symbol gc.  If you move the foo reference before the __start_xx
reference then no magic linker marking of xx sections happens.


 .weak __start_xx
 .weak __stop_xx

 .text
 .global _start
_start:
 .dc.a __start_xx, __stop_xx
 .dc.a foo


 .section .text,"axG",%progbits,foo_group
foo:
 .dc.a 0

 .section xx,"aG",%progbits,foo_group
 .dc.a 1


 .section .text,"axG",%progbits,bar_group
bar:
 .dc.a 2

 .section xx,"aG",%progbits,bar_group
 .dc.a 3

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]