[llvm-dev] [ELF] String literals don't obey -fdata-sections
Gaël Jobin via llvm-dev
llvm-dev at lists.llvm.org
Thu Sep 17 01:38:14 PDT 2020
On 2020-09-16 19:42, Fangrui Song wrote:
> On 2020-09-16, Gaël Jobin wrote:
>
> Your example uses global mutable variables "test" and "unused" and that
> is why they are in the .data.* sections. They are initialized to
> addresses of string literals in .rodata.* . .rodata.* are what we care
> about, not .data.* (.data.* can always be correctly garbage collected by
> GNU ld/gold/LLD).
Of course, the issue here is .rodata.*. I use the .data.* section as a
counterexample
but it could be any section. I compare those two sections because they
contain both
small datas and the ratio "section header size" vs "data size" is not
optimal.
But my point is: Why the implementation of -fdata-sections should differ
between .data.*
and .rodata.* sections? Or why .rodata.* should be treated differently?
If the only reason is because it is suboptimal due to the additional
section header,
this is definitely not a valid reason. Having everything in its own
section is the
purpose of the -f*-sections and allows the linker to easily strip them.
I really
don't get the exception made for .rodata.* here.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200917/202a8038/attachment-0001.html>
More information about the llvm-dev
mailing list