diff --git a/llvm/include/llvm/BinaryFormat/ELF.h b/llvm/include/llvm/BinaryFormat/ELF.h --- a/llvm/include/llvm/BinaryFormat/ELF.h +++ b/llvm/include/llvm/BinaryFormat/ELF.h @@ -564,6 +564,15 @@ EF_MIPS_ARCH = 0xf0000000 // Mask for applying EF_MIPS_ARCH_ variant }; +// MIPS-specific section indexes +enum { + SHN_MIPS_ACOMMON = 0xff00, // Common symbols which are defined and allocated + SHN_MIPS_TEXT = 0xff01, // Not ABI compliant + SHN_MIPS_DATA = 0xff02, // Not ABI compliant + SHN_MIPS_SCOMMON = 0xff03, // Common symbols for global data area + SHN_MIPS_SUNDEFINED = 0xff04 // Undefined symbols for global data area +}; + // ELF Relocation types for Mips enum { #include "ELFRelocs/Mips.def" diff --git a/llvm/lib/ObjCopy/ELF/ELFObject.h b/llvm/lib/ObjCopy/ELF/ELFObject.h --- a/llvm/lib/ObjCopy/ELF/ELFObject.h +++ b/llvm/lib/ObjCopy/ELF/ELFObject.h @@ -617,6 +617,11 @@ SYMBOL_COMMON = ELF::SHN_COMMON, SYMBOL_LOPROC = ELF::SHN_LOPROC, SYMBOL_AMDGPU_LDS = ELF::SHN_AMDGPU_LDS, + SYMBOL_MIPS_ACOMMON = ELF::SHN_MIPS_ACOMMON, + SYMBOL_MIPS_TEXT = ELF::SHN_MIPS_TEXT, + SYMBOL_MIPS_DATA = ELF::SHN_MIPS_DATA, + SYMBOL_MIPS_SCOMMON = ELF::SHN_MIPS_SCOMMON, + SYMBOL_MIPS_SUNDEFINED = ELF::SHN_MIPS_SUNDEFINED, SYMBOL_HEXAGON_SCOMMON = ELF::SHN_HEXAGON_SCOMMON, SYMBOL_HEXAGON_SCOMMON_2 = ELF::SHN_HEXAGON_SCOMMON_2, SYMBOL_HEXAGON_SCOMMON_4 = ELF::SHN_HEXAGON_SCOMMON_4, diff --git a/llvm/lib/ObjCopy/ELF/ELFObject.cpp b/llvm/lib/ObjCopy/ELF/ELFObject.cpp --- a/llvm/lib/ObjCopy/ELF/ELFObject.cpp +++ b/llvm/lib/ObjCopy/ELF/ELFObject.cpp @@ -655,6 +655,15 @@ return Index == SHN_AMDGPU_LDS; } + if (Machine == EM_MIPS) { + switch (Index) { + case SHN_MIPS_ACOMMON: + case SHN_MIPS_SCOMMON: + case SHN_MIPS_SUNDEFINED: + return true; + } + } + if (Machine == EM_HEXAGON) { switch (Index) { case SHN_HEXAGON_SCOMMON: diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp --- a/llvm/lib/ObjectYAML/ELFYAML.cpp +++ b/llvm/lib/ObjectYAML/ELFYAML.cpp @@ -751,6 +751,8 @@ void ScalarEnumerationTraits::enumeration( IO &IO, ELFYAML::ELF_SHN &Value) { + const auto *Object = static_cast(IO.getContext()); + assert(Object && "The IO context is not initialized"); #define ECase(X) IO.enumCase(Value, #X, ELF::X) ECase(SHN_UNDEF); ECase(SHN_LORESERVE); @@ -763,6 +765,11 @@ ECase(SHN_XINDEX); ECase(SHN_HIRESERVE); ECase(SHN_AMDGPU_LDS); + //ECase(SHN_MIPS_ACOMMON); + //ECase(SHN_MIPS_TEXT); + //ECase(SHN_MIPS_DATA); + //ECase(SHN_MIPS_SCOMMON); + //ECase(SHN_MIPS_SUNDEFINED); ECase(SHN_HEXAGON_SCOMMON); ECase(SHN_HEXAGON_SCOMMON_1); ECase(SHN_HEXAGON_SCOMMON_2);