[PATCH] D37767: [llvm-objcopy] Add e_machine validity check for reserved section indexes
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 12 20:06:19 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313114: [llvm-objcopy] Add e_machine validity check for reserved section indexes (authored by phosek).
Changed prior to commit:
https://reviews.llvm.org/D37767?vs=114934&id=114959#toc
Repository:
rL LLVM
https://reviews.llvm.org/D37767
Files:
llvm/trunk/test/tools/llvm-objcopy/common-symbol.test
llvm/trunk/tools/llvm-objcopy/Object.cpp
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<SymbolShndxType>(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: " +
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37767.114959.patch
Type: text/x-patch
Size: 2097 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170913/057416ec/attachment.bin>
More information about the llvm-commits
mailing list