Author: Phoebe Wang
Date: 2026-07-06T10:43:18+08:00
New Revision: f7d75024bf194e660aa56714e7f0fdb56b92de69

URL: 
https://github.com/llvm/llvm-project/commit/f7d75024bf194e660aa56714e7f0fdb56b92de69
DIFF: 
https://github.com/llvm/llvm-project/commit/f7d75024bf194e660aa56714e7f0fdb56b92de69.diff

LOG: [SPARC] Make SPARC_REGISTER Sparc specific in llvm-readobj and LLDB 
(#206316)

The commit 4418a8e5 failed to limit SPARC_REGISTER to Sparc targets
only, which causes conflict when adding new dynamic tags for other
targets.

Added: 
    

Modified: 
    lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
    llvm/include/llvm/BinaryFormat/DynamicTags.def
    llvm/lib/Object/ELF.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp 
b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index eccb24e3d7aa1..daf74bd3ba48e 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -3818,6 +3818,16 @@ std::string static getDynamicTagAsString(uint16_t Arch, 
uint64_t Type) {
 #undef RISCV_DYNAMIC_TAG
     }
     break;
+
+  case llvm::ELF::EM_SPARC:
+  case llvm::ELF::EM_SPARC32PLUS:
+  case llvm::ELF::EM_SPARCV9:
+    switch (Type) {
+#define SPARC_DYNAMIC_TAG(name, value) DYNAMIC_STRINGIFY_ENUM(name, value)
+#include "llvm/BinaryFormat/DynamicTags.def"
+#undef SPARC_DYNAMIC_TAG
+    }
+    break;
   }
 #undef DYNAMIC_TAG
   switch (Type) {
@@ -3828,6 +3838,7 @@ std::string static getDynamicTagAsString(uint16_t Arch, 
uint64_t Type) {
 #define PPC_DYNAMIC_TAG(name, value)
 #define PPC64_DYNAMIC_TAG(name, value)
 #define RISCV_DYNAMIC_TAG(name, value)
+#define SPARC_DYNAMIC_TAG(name, value)
 // Also ignore marker tags such as DT_HIOS (maps to DT_VERNEEDNUM), etc.
 #define DYNAMIC_TAG_MARKER(name, value)
 #define DYNAMIC_TAG(name, value)                                               
\
@@ -3841,6 +3852,7 @@ std::string static getDynamicTagAsString(uint16_t Arch, 
uint64_t Type) {
 #undef PPC_DYNAMIC_TAG
 #undef PPC64_DYNAMIC_TAG
 #undef RISCV_DYNAMIC_TAG
+#undef SPARC_DYNAMIC_TAG
 #undef DYNAMIC_TAG_MARKER
 #undef DYNAMIC_STRINGIFY_ENUM
   default:

diff  --git a/llvm/include/llvm/BinaryFormat/DynamicTags.def 
b/llvm/include/llvm/BinaryFormat/DynamicTags.def
index 1e9b87e1e58a7..75606e58da80d 100644
--- a/llvm/include/llvm/BinaryFormat/DynamicTags.def
+++ b/llvm/include/llvm/BinaryFormat/DynamicTags.def
@@ -282,3 +282,7 @@ DYNAMIC_TAG(FILTER, 0x7FFFFFFF)    // Shared object to get 
values from
 #undef RISCV_DYNAMIC_TAG
 #undef RISCV_DYNAMIC_TAG_DEFINED
 #endif
+#ifdef SPARC_DYNAMIC_TAG_DEFINED
+#undef SPARC_DYNAMIC_TAG
+#undef SPARC_DYNAMIC_TAG_DEFINED
+#endif

diff  --git a/llvm/lib/Object/ELF.cpp b/llvm/lib/Object/ELF.cpp
index f159fd82e7117..5dbdecc9915b0 100644
--- a/llvm/lib/Object/ELF.cpp
+++ b/llvm/lib/Object/ELF.cpp
@@ -588,6 +588,16 @@ std::string ELFFile<ELFT>::getDynamicTagAsString(unsigned 
Arch,
 #undef RISCV_DYNAMIC_TAG
     }
     break;
+
+  case ELF::EM_SPARC:
+  case ELF::EM_SPARC32PLUS:
+  case ELF::EM_SPARCV9:
+    switch (Type) {
+#define SPARC_DYNAMIC_TAG(name, value) DYNAMIC_STRINGIFY_ENUM(name, value)
+#include "llvm/BinaryFormat/DynamicTags.def"
+#undef SPARC_DYNAMIC_TAG
+    }
+    break;
   }
 #undef DYNAMIC_TAG
   switch (Type) {
@@ -598,6 +608,7 @@ std::string ELFFile<ELFT>::getDynamicTagAsString(unsigned 
Arch,
 #define PPC_DYNAMIC_TAG(name, value)
 #define PPC64_DYNAMIC_TAG(name, value)
 #define RISCV_DYNAMIC_TAG(name, value)
+#define SPARC_DYNAMIC_TAG(name, value)
 // Also ignore marker tags such as DT_HIOS (maps to DT_VERNEEDNUM), etc.
 #define DYNAMIC_TAG_MARKER(name, value)
 #define DYNAMIC_TAG(name, value) case value: return #name;
@@ -609,6 +620,7 @@ std::string ELFFile<ELFT>::getDynamicTagAsString(unsigned 
Arch,
 #undef PPC_DYNAMIC_TAG
 #undef PPC64_DYNAMIC_TAG
 #undef RISCV_DYNAMIC_TAG
+#undef SPARC_DYNAMIC_TAG
 #undef DYNAMIC_TAG_MARKER
 #undef DYNAMIC_STRINGIFY_ENUM
   default:


        
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to