[Top][All Lists]

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

[Bug ld/22677] ld -r --gc-section does not KEEP .init_array/.fini_array

From: nickc at redhat dot com
Subject: [Bug ld/22677] ld -r --gc-section does not KEEP .init_array/.fini_array
Date: Mon, 08 Jan 2018 12:15:08 +0000


Nick Clifton <nickc at redhat dot com> changed:

           What    |Removed                     |Added
                 CC|                            |nickc at redhat dot com

--- Comment #2 from Nick Clifton <nickc at redhat dot com> ---
(In reply to David Leonard from comment #0)

Hi David,

> "ld -r --gc-collect" drops the .init_array/.fini_array sections, although it
> preserves .init, .fini and the .preinit_array sections. It should probably
> KEEP() the .init_array/.fini_array sections too? (And others?)

Indeed it should.

> There doesn't seem to be a clean indirect way to make --gc-collect keep the
> .{init,fini}_array sections. A (noisy) workaround is to add this linker
> script as an argument:
>     .init_array : { KEEP (*(.init_array)) }
>     .fini_array : { KEEP (*(.fini_array)) }
>   }

This appears to be an artifact of the linker that you are using.  If you
build an x86_64 linker using the FSF sources and run "ld --verbose" you
should see this as part of the output:

  .init_array     :
    PROVIDE_HIDDEN (__init_array_start = .);
    KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*)
    KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o
*crtend?.o ) .ctors))
    PROVIDE_HIDDEN (__init_array_end = .);

So the input sections should survive garbage collection.

I think however that the ubuntu version of the linker that you are using may
have its own, different built-in linker script, without the KEEP statements.
Please could you check ?  If I am right, then you need to complain to Ubuntu
and not us...


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]