[PATCH] readelf: Warn zero-sized relocation sections
Fangrui Song
i@maskray.me
Fri Apr 24 17:19:26 GMT 2020
On 2020-04-24, Nick Clifton via Binutils wrote:
>Hi Guys,
>
> OK, here is a first draft of a patch to implement a checking mode
> for readelf. It incorporates H.J.'s zero-size section test, although
> I have extended it to cover any SHT_PROGBITS section as well. (Mainly
> because it makes writing a test case much easier).
>
> One thing that the patch does not do, but which maybe it should, is
> disable the normal non-warning output when the checking mode is enabled.
> The effect can be achieved by redirecting stdout to the null device
> of course, but I appreciate that this is not always possible/easy to do.
>
> Anyway - comments ?
>
>Cheers
> Nick
Certain linker script constructs can create empty output sections, e.g.
.keep : { KEEP(*(.keep)) }
It is convenient to write a general linker script with lots of output
section descriptions but many omitted in some cases. So empty sections
may be common, especially in embedded systems. Not warning by default
seems sensible.
(In lld, there are a few more cases, e.g.
.bar : { PROVIDE(foo = .) } # when foo is referenced, .bar is kept by lld but discarded by GNU ld/gold
.empty : { *(.empty) } # this is insufficient to keep .empty
.data : AT(ADDR(.empty)+0x2000) { ... } # .empty is referenced an expression and thus retained)
Took a rough look at the patch. Looks great! Just one question, -L's
mnemonic is *L*int. Why is the long option --enable-checks, instead of
--lint?
More information about the Binutils
mailing list