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

Tomas Matheson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 29 07:14:02 PDT 2021


tmatheson added a comment.

Not sure I fully understand the issue, but it sounds like the final combined `debug_special` section the linker is trying to create is allocatable at address 0, whereas before it was non-allocatable at address zero. Therefore now it conflicts with other allocatable sections at the same address.

The solution looks like one of the following to me:

- Use a linkerscript that enforces non-alloc for `debug_special`. I don't know if either `ld` or `lld` support setting flags explicitly.
- Allow the user to specify flags through the frontend, or at least in IR.

Users can specify section flags in the attribute with GCC by exploiting string quoting, e.g. `__attribute__((section("debug_special,\"\", at progbits#")))` in which the section name is actually given the desired assembly followed by a comment character `#`, effectively commenting out whatever assembly GCC was going to output for the section and using the user supplied string instead.

A better solution for llvm would be to expand the `__attribute__((section(name)))` to accept flags, and to expand the LLVM IR `section` to allow specifying flags, section type, etc. If the `attribute` can't be changed then being able to express this in IR would still enable clang to make more sensible choices.


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