[llvm] [AArch64] Add support for SHF_AARCH64_PURECODE ELF section flag (1/3) (PR #125687)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 13 00:59:41 PST 2025


=?utf-8?q?Csanád_Hajdú?= <csanad.hajdu at arm.com>,
=?utf-8?q?Csanád_Hajdú?= <csanad.hajdu at arm.com>,
=?utf-8?q?Csanád_Hajdú?= <csanad.hajdu at arm.com>,
=?utf-8?q?Csanád_Hajdú?= <csanad.hajdu at arm.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/125687 at github.com>


================
@@ -138,3 +138,25 @@ Sections:
   - Name:  foo
     Type:  SHT_PROGBITS
     Flags: [ SHF_ARM_PURECODE ]
+
+# RUN: yaml2obj --docnum 6 %s -o %t-aarch64.o
+# RUN: llvm-readobj -S %t-aarch64.o | FileCheck --check-prefix=AARCH64-LLVM %s
+# RUN: llvm-readelf -S %t-aarch64.o | FileCheck --check-prefix=AARCH64-GNU %s
+
+# AARCH64-LLVM:      Flags [ (0x20000000)
+# AARCH64-LLVM-NEXT:   SHF_AARCH64_PURECODE (0x20000000)
+# AARCH64-LLVM-NEXT: ]
+
+# AARCH64-GNU: [Nr] Name Type     Address          Off    Size   ES Flg Lk Inf Al
+# AARCH64-GNU: [ 1] foo  PROGBITS 0000000000000000 000040 000000 00   y 0   0  0
+
+--- !ELF
----------------
jh7370 wrote:

You can avoid duplicating this YAML block with the ARM case by leveraging yaml2obj's -D option. This works a bit like a compiler preprocessor macro and allows you to do something like this:

```
# RUN: yaml2obj --docnum 5 -DMACH=ARM %s -o %t-arm.o
# RUN: yaml2obj --docnum 5 -DMACH=AARCH64 %s -o %t-aarch64.o

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_REL
  Machine: EM_[[MACH]]
Sections:
  - Name:  foo
    Type:  SHT_PROGBITS
    Flags: [ SHF_[[MACH]]_PURECODE ]
```

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


More information about the llvm-commits mailing list