Summary: | --gc-sections -u __start_cident inconsistent for -r and non-relocatable links | ||
---|---|---|---|
Product: | binutils | Reporter: | Fangrui Song <i> |
Component: | ld | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED NOTABUG | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Last reconfirmed: |
Description
Fangrui Song
2020-07-20 17:53:26 UTC
A relocatable link doesn't create __start and __end symbols, thus the undefined reference to __start_cident is not related to any section. Use -Ur if you want them. (In reply to Andreas Schwab from comment #1) > A relocatable link doesn't create __start and __end symbols, thus the > undefined reference to __start_cident is not related to any section. Use > -Ur if you want them. The documentation says -Ur is equivalent to -r for non-C++ programs @kindex -Ur @cindex constructors @item -Ur For anything other than C++ programs, this option is equivalent to @samp{-r}: it generates relocatable output---i.e., an output file that can in turn serve as input to @command{ld}. When linking C++ programs, @samp{-Ur} @emph{does} resolve references to constructors, unlike @samp{-r}. It does not work to use @samp{-Ur} on files that were themselves linked with @samp{-Ur}; once the constructor table has been built, it cannot be added to. Use @samp{-Ur} only for the last partial link, and @samp{-r} for the others. ld -r is allowed to not defined __start_cindent, but it should not discard the sections. Not only -u __start_cindent does not retain 'cindent', a relocation '.quad __start_cindent' does not retain 'cindent' as well. I don't think this is invalid. __start_cident isn't meaningful for -r since the output cident section isn't the final one. Try "-T keep.t" with --keep.t-- SECTIONS { cident : { KEEP(*(cident)) } } -- comment #1 is the answer to this question |