https://sourceware.org/bugzilla/show_bug.cgi?id=22677
Bug ID: 22677 Summary: ld -r --gc-collect does not KEEP .init_array/.fini_array Product: binutils Version: unspecified Status: UNCONFIRMED Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: d+sourcew...@adaptive-enterprises.com Target Milestone: --- "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?) 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)) } } My use case is using ld -r as part of a post-processing step to reduce shared library size in a firmware image. The gc root set is passed into ld as -u options via a @file. GNU ld (GNU Binutils for Ubuntu) 2.29.1 gcc version 7.2.0 (Ubuntu 7.2.0-8ubuntu3) Target: x86_64-linux-gnu The KEEP() for these arrays appears to have been lost in commit 3cff7cc71fc25ffa83e7d5ce8f4aeb308fb656db ("Don't combine .init_array.* or .fini_array.* when do relocatable linking.") -- You are receiving this mail because: You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils