[llvm] [SPARC][Utilities] Add names for SPARC ELF flags in LLVM binary utilities (PR #102843)

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 14 04:51:09 PDT 2024


================
@@ -0,0 +1,57 @@
+# RUN: yaml2obj %s -o %t -DCLASS_NAME="ELFCLASS32" -DMACHINE_NAME="EM_SPARC" -DFLAG_NAME=""
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=V8 -DFLAG_VALUE=0x0
+# RUN: llvm-readelf -h %t | FileCheck %s --check-prefix=READELF -DFLAG_VALUE=0x0 -DREADELF_FLAG_NAME=""
+
+# RUN: yaml2obj %s -o %t -DCLASS_NAME="ELFCLASS32" -DMACHINE_NAME="EM_SPARC32PLUS" -DFLAG_NAME="EF_SPARC_32PLUS"
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=V8PLUS-PLAIN -DFLAG_NAME=EF_SPARC_32PLUS -DFLAG_VALUE=0x100
+# RUN: llvm-readelf -h %t | FileCheck %s --check-prefix=READELF -DFLAG_VALUE=0x100 -DREADELF_FLAG_NAME=", V8+ ABI"
+
+# RUN: yaml2obj %s -o %t -DCLASS_NAME="ELFCLASS32" -DMACHINE_NAME="EM_SPARC32PLUS" -DFLAG_NAME="EF_SPARC_32PLUS, EF_SPARC_SUN_US1"
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=V8PLUS-US1 -DFLAG0_NAME=EF_SPARC_32PLUS -DFLAG1_NAME=EF_SPARC_SUN_US1 -DFLAG_VALUE=0x300
+# RUN: llvm-readelf -h %t | FileCheck %s --check-prefix=READELF -DFLAG_VALUE=0x300 -DREADELF_FLAG_NAME=", V8+ ABI, Sun UltraSPARC I extensions"
+
+# RUN: yaml2obj %s -o %t -DCLASS_NAME="ELFCLASS64" -DMACHINE_NAME="EM_SPARCV9" -DFLAG_NAME=""
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=V9-PLAIN -DFLAG_VALUE=0x0
+# RUN: llvm-readelf -h %t | FileCheck %s --check-prefix=READELF -DFLAG_VALUE=0x0 -DREADELF_FLAG_NAME=""
+
+# RUN: yaml2obj %s -o %t -DCLASS_NAME="ELFCLASS64" -DMACHINE_NAME="EM_SPARCV9" -DFLAG_NAME="EF_SPARC_SUN_US1"
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=V9-US1 -DFLAG_NAME=EF_SPARC_SUN_US1 -DFLAG_VALUE=0x200
+# RUN: llvm-readelf -h %t | FileCheck %s --check-prefix=READELF -DFLAG_VALUE=0x200 -DREADELF_FLAG_NAME=", Sun UltraSPARC I extensions"
+
+# RUN: yaml2obj %s -o %t -DCLASS_NAME="ELFCLASS64" -DMACHINE_NAME="EM_SPARCV9" -DFLAG_NAME="EF_SPARC_SUN_US1, EF_SPARCV9_RMO"
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=V9-US1-RMO -DFLAG0_NAME=EF_SPARCV9_RMO -DFLAG1_NAME=EF_SPARC_SUN_US1 -DFLAG_VALUE=0x202
+# RUN: llvm-readelf -h %t | FileCheck %s --check-prefix=READELF -DFLAG_VALUE=0x202 -DREADELF_FLAG_NAME=", Sun UltraSPARC I extensions, Relaxed Memory Ordering"
----------------
s-barannikov wrote:

> Hm, just noticed something
> 
> Having a `0xXX3` flag in EM_SPARCV9 object should not happen since I shouldn't be able to ask for more than one memory model, yet yaml2obj doesn't complain when I pass all three of them: `EF_SPARCV9_RMO, EF_SPARCV9_PSO, EF_SPARCV9_TSO`. On the other hand this behavior seems to not be limited to SPARC; I can also make an ELF with weird flag combinations for other architectures. Should I just go ahead and write the test, or...?

So it appears `0xXX3` is just invalid as memory model isn't a bitfield but enum (and '3' is unassigned value). Let's not try to combine memory models and test just flags? `0xF00` should be valid, right?



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


More information about the llvm-commits mailing list