[PATCH] D100944: [MC][ELF] Emit separate unique sections for different flags
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 11 20:39:47 PDT 2021
MaskRay added a comment.
> Augment compiler section attribute to allow specifying the section flags as well as the section name.
Recent GNU as reports errors for changed section attributes, so gcc with such a GNU as will report an error
% cat a.c
asm(".section debug_special,\"\", at progbits");
__attribute__((used, section("debug_special"))) int var;
% gcc -c a.c
/tmp/ccrwXjUO.s: Assembler messages:
/tmp/ccrwXjUO.s:7: Error: changed section attributes for debug_special
So I think a compiler oriented solution is more appropriate than a linker oriented one.
A GNU attribute beside `section` looks good to me. Such a request needed to be raised on the GCC Bugzilla.
> linkerscript feature to force the input sections to an output section to be considered non-ALLOC e.g. NOADDR (analogous to the existing NOLOAD).
If `NOADDR` (customizing the flags of an output section) is desired, it needs to be raised on binutils feature request.
It is a bit possible that such a thing already exists and more importantly, it is likely they have opinions on what this should be called.
> Assembler feature to override the section flags for specified section.
I think this has a low probability that this may be accepted on GNU side.
Assemblers are in streamer styles, and a later directive overriding previous directives contradicts with GNU as's design.
When `SHF_GNU_RETAIN` was introduced, the author considered `.retain` as a directive to modify a section attribute and it was rejected.
> Linker doesn't check for overlap if a section is assigned to the NONE phdr.
s/NONE/non-SHF_ALLOC/ ?
A foo without SHF_ALLOC and a foo with SHF_ALLOC are combined into an output foo with SHF_ALLOC.
So I don't see how such a special case can help.
> Add linker feature to disable address overlap checks for specific sections (currently there is -no-check-sections but it disables checks on all sections).
Looks like you have a workaround `--no-check-sections` for now.
As a workaround (and considering the potential usage), I think adding such a capatibility to `--no-check-sections` is likely overengineering.
The similar check can be performed by a post-link tool which checks section addresses.
Such a tool is likely already in place if you need a verification tool (or watermark or the like).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D100944/new/
https://reviews.llvm.org/D100944
More information about the llvm-commits
mailing list