[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 |
https://sourceware.org/bugzilla/show_bug.cgi?id=22677
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:
>
> SECTIONS {
> .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.*)
SORT_BY_INIT_PRIORITY(.ctors.*)))
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...
Cheers
Nick
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug ld/22677] New: ld -r --gc-collect does not KEEP .init_array/.fini_array, address@hidden, 2018/01/05
- [Bug ld/22677] ld -r --gc-collect does not KEEP .init_array/.fini_array, address@hidden, 2018/01/05
- [Bug ld/22677] ld -r --gc-section does not KEEP .init_array/.fini_array, address@hidden, 2018/01/05
- [Bug ld/22677] ld -r --gc-section does not KEEP .init_array/.fini_array,
nickc at redhat dot com <=
- [Bug ld/22677] ld -r --gc-section does not KEEP .init_array/.fini_array, address@hidden, 2018/01/10
- [Bug ld/22677] ld -r --gc-section does not KEEP .init_array/.fini_array, nickc at redhat dot com, 2018/01/11
- [Bug ld/22677] ld -r --gc-section does not KEEP .init_array/.fini_array, cvs-commit at gcc dot gnu.org, 2018/01/11
- [Bug ld/22677] ld -r --gc-section does not KEEP .init_array/.fini_array, hjl.tools at gmail dot com, 2018/01/11
- [Bug ld/22677] ld -r --gc-section does not KEEP .init_array/.fini_array, address@hidden, 2018/01/11