[PATCH] D100944: [MC][ELF] Emit separate unique sections for different flags

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 14 14:09:32 PDT 2021


MaskRay added a comment.

In D100944#2876554 <https://reviews.llvm.org/D100944#2876554>, @bd1976llvm wrote:

> In D100944#2870297 <https://reviews.llvm.org/D100944#2870297>, @MaskRay wrote:
>
>>> 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.
>
> Thanks for the feedback, very much appreciated. I agree that a compiler based solution is more appropriate.
>
> We appear to have the only codebase with this issue. Therefore, we are currently looking hard to see if there is any way to  rewrite or remove the feature.
>
> If this is not possible we will persue a new toolchain feature to support our use case.

If there is widespread usage, you may consider `llvm-objcopy --set-section-flags=debug_special=readonly`


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