[AArch64] Always add PURECODE flag to empty .text if "+execute-only" is set by Il-Capitano · Pull Request #132196 · llvm/llvm-project (original) (raw)

@llvm/pr-subscribers-backend-aarch64

Author: Csanád Hajdú (Il-Capitano)

Changes

The previous approach only added the SHF_AARCH64_PURECODE section flag to the implicitly created .text section if there was any other section containing the flag already. This doesn't work for the case, where the module doesn't contain any code.

Now, the SHF_AARCH64_PURECODE is always added if the "+execute-only" target feature is set for the module.


Full diff: https://github.com/llvm/llvm-project/pull/132196.diff

3 Files Affected:

MCSectionELF *MemtagSec = nullptr; for (const MCSymbol &Symbol : Asm.symbols()) { const auto &Sym = cast(Symbol); diff --git a/llvm/test/CodeGen/AArch64/execute-only-empty.ll b/llvm/test/CodeGen/AArch64/execute-only-empty.ll new file mode 100644 index 0000000000000..cdf9b3afe8daf --- /dev/null +++ b/llvm/test/CodeGen/AArch64/execute-only-empty.ll @@ -0,0 +1,13 @@ +; RUN: llc -filetype=obj -mtriple=aarch64 -mattr=+execute-only %s -o %t.o +; RUN: llvm-readobj -S %t.o | FileCheck %s + +; CHECK: Name: .text +; CHECK-NEXT: Type: SHT_PROGBITS +; CHECK-NEXT: Flags [ +; CHECK-NEXT: SHF_AARCH64_PURECODE +; CHECK-NEXT: SHF_ALLOC +; CHECK-NEXT: SHF_EXECINSTR +; CHECK-NEXT: ] +; CHECK-NEXT: Address: +; CHECK-NEXT: Offset: +; CHECK-NEXT: Size: 0