Index: llvm/trunk/test/tools/llvm-objcopy/common-symbol.test =================================================================== --- llvm/trunk/test/tools/llvm-objcopy/common-symbol.test +++ llvm/trunk/test/tools/llvm-objcopy/common-symbol.test @@ -7,7 +7,7 @@ Class: ELFCLASS64 Data: ELFDATA2LSB Type: ET_EXEC - Machine: EM_X86_64 + Machine: EM_HEXAGON Symbols: Global: - Name: test Index: llvm/trunk/tools/llvm-objcopy/Object.cpp =================================================================== --- llvm/trunk/tools/llvm-objcopy/Object.cpp +++ llvm/trunk/tools/llvm-objcopy/Object.cpp @@ -90,18 +90,22 @@ StrTabBuilder.write(Out.getBufferStart() + Offset); } -static bool isValidReservedSectionIndex(uint16_t Index) { +static bool isValidReservedSectionIndex(uint16_t Index, uint16_t Machine) { switch (Index) { case SHN_ABS: case SHN_COMMON: - case SHN_HEXAGON_SCOMMON: - case SHN_HEXAGON_SCOMMON_2: - case SHN_HEXAGON_SCOMMON_4: - case SHN_HEXAGON_SCOMMON_8: return true; - default: - return false; } + if (Machine == EM_HEXAGON) { + switch (Index) { + case SHN_HEXAGON_SCOMMON: + case SHN_HEXAGON_SCOMMON_2: + case SHN_HEXAGON_SCOMMON_4: + case SHN_HEXAGON_SCOMMON_8: + return true; + } + } + return false; } uint16_t Symbol::getShndx() const { @@ -133,7 +137,7 @@ Sym.Type = Type; Sym.DefinedIn = DefinedIn; if (DefinedIn == nullptr) { - if (isValidReservedSectionIndex(Shndx)) + if (Shndx >= SHN_LORESERVE) Sym.ShndxType = static_cast(Shndx); else Sym.ShndxType = SYMBOL_SIMPLE_INDEX; @@ -289,7 +293,7 @@ SectionBase *DefSection = nullptr; StringRef Name = unwrapOrError(Sym.getName(StrTabData)); if (Sym.st_shndx >= SHN_LORESERVE) { - if (!isValidReservedSectionIndex(Sym.st_shndx)) { + if (!isValidReservedSectionIndex(Sym.st_shndx, Machine)) { error( "Symbol '" + Name + "' has unsupported value greater than or equal to SHN_LORESERVE: " +