Index: test/tools/llvm-objcopy/common-symbol.test =================================================================== --- test/tools/llvm-objcopy/common-symbol.test +++ 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: tools/llvm-objcopy/Object.cpp =================================================================== --- tools/llvm-objcopy/Object.cpp +++ tools/llvm-objcopy/Object.cpp @@ -90,15 +90,16 @@ 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: + return true; case SHN_HEXAGON_SCOMMON: case SHN_HEXAGON_SCOMMON_2: case SHN_HEXAGON_SCOMMON_4: case SHN_HEXAGON_SCOMMON_8: - return true; + return Machine == EM_HEXAGON; default: return false; } @@ -133,7 +134,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 +290,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: " +