[compiler-rt] [compiler-rt] Add CMake option to enable execute-only code generation on AArch64 (PR #140555)

Saleem Abdulrasool via llvm-commits llvm-commits at lists.llvm.org
Mon May 19 08:58:19 PDT 2025


compnerd wrote:

> > I don't think that this properly handles MachO.
> 
> Can you expand on this more? MachO doesn't have execute-only code AFAIK. This is intended for AArch64 ELF targets only.

These macros are not ELF specific is the issue. You are changing macros that are shared across all architectures and file formats. If you could scope this down somehow to not touch these global macros, that might be easier.

> > Additionally, I don't understand the need for the `unique` flag on the section, nor the section id (`0`).
> 
> `unique,0` is needed because the assembler creates an implicit `.text` section with default flags. If we tried to just do `.section .text,"axy"`, we'd get the following error: `error: changed section flags for .text, expected: 0x6`. So the execute-only `.text` section needs to be different from the implicit `.text` section. The id `0` is arbitrary, but we need to provide something anyways.
> 
> This also matches what LLVM outputs when it generates execute-only code: https://godbolt.org/z/a8xa7qsxG

Ah, I see. I think that deserves a comment explaining why we need those flags are being added. I do wonder if we should simply drop the `unique,0` and instead build the builtins as `-ffunction-sections` instead as that places the text into a separate section.


https://github.com/llvm/llvm-project/pull/140555


More information about the llvm-commits mailing list