[PATCH] D92052: [MC][ELF] Accept abbreviated form with sh_flags and sh_entsize

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 24 14:33:15 PST 2020


MaskRay added a comment.

In D92052#2414890 <https://reviews.llvm.org/D92052#2414890>, @burnus wrote:

> In D92052#2414665 <https://reviews.llvm.org/D92052#2414665>, @MaskRay wrote:
>
>> This is known. I'd like it to be an error but it is unfortunate that GCC uses it this way. Can you share a code snippet which can trigger the relevant GCC logic?
>
> It looks as if one way to get it is requires the `-ffunction-sections` flag, example: https://godbolt.org/z/Yfveoh which creates:
>
> - `.section        .text.ULtod,"ax", at progbits`
> - `.section        .text.ULtod`
>
> `-ffunction-sections`/`-fdata-sections` is described as: //Place each function or data item into its own section in the output file if the target supports arbitrary sections. ... Only use these options when there are significant benefits from doing so.  When you specify these options, the assembler and linker create larger object and executable files and are also slower.//
>
> As there is already a huge growth, avoiding the repetition of the flags/entsize helps a bit. Thus, the GCC and GNU assembler short variant makes kind of sense.

OK, thanks for the example: a jump table causes the second `.section .text.foobar` directive without attributes. This makes sense.

>> There is a variant where an empty string literal is used (https://sourceware.org/pipermail/binutils/2020-March/110441.html): I haven't receive a reply yet.
>> Shall we continue erroring for that?
>
> No strong opinion, but I don't see how why one would write such code in real-world code; and if there is no good reason for valid code, giving an error should not harm, should it?

Right, if we can continue rejecting `.section .foo,""` relatively easily, I hope we continue rejecting it (even though GNU as allows it). If a bit difficult, I'll not push too hard on losing the diagnostic.



================
Comment at: llvm/test/MC/ELF/section-flags-changed-2.s:9
+# CHECK: {{.*}}.s:[[# @LINE+1]]:1: error: changed section flags for .foo, expected: 0x6
+.section .foo,"awx", at progbits
+
----------------
Please drop tests which are already tested in section-flags-changed.s


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92052/new/

https://reviews.llvm.org/D92052



More information about the llvm-commits mailing list