bug-binutils
[Top][All Lists]
Advanced

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

[Bug ld/22677] New: ld -r --gc-collect does not KEEP .init_array/.fini_a


From: address@hidden
Subject: [Bug ld/22677] New: ld -r --gc-collect does not KEEP .init_array/.fini_array
Date: Fri, 05 Jan 2018 09:38:38 +0000

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: address@hidden
  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.


reply via email to

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