aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/COFFObjectFile.cpp
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2014-03-18 23:37:53 +0000
committerRui Ueyama <ruiu@google.com>2014-03-18 23:37:53 +0000
commitf078eff39c48f213903a572a2dc2dabd8c719adc (patch)
treea54393be632d3813e4f00df3f66b361d5c17a7ac /llvm/lib/Object/COFFObjectFile.cpp
parent2e21f634628965fad362e3623501dd1b55537557 (diff)
downloadllvm-f078eff39c48f213903a572a2dc2dabd8c719adc.zip
llvm-f078eff39c48f213903a572a2dc2dabd8c719adc.tar.gz
llvm-f078eff39c48f213903a572a2dc2dabd8c719adc.tar.bz2
Object/COFF: Add function to check if section number is reserved one.
Differential Revision: http://llvm-reviews.chandlerc.com/D3103 llvm-svn: 204199
Diffstat (limited to 'llvm/lib/Object/COFFObjectFile.cpp')
-rw-r--r--llvm/lib/Object/COFFObjectFile.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp
index 7f66c6a..039bc4e 100644
--- a/llvm/lib/Object/COFFObjectFile.cpp
+++ b/llvm/lib/Object/COFFObjectFile.cpp
@@ -16,6 +16,7 @@
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/Triple.h"
+#include "llvm/Support/COFF.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include <cctype>
@@ -177,7 +178,7 @@ error_code COFFObjectFile::getSymbolType(DataRefImpl Ref,
Result = SymbolRef::ST_Function;
} else {
uint32_t Characteristics = 0;
- if (Symb->SectionNumber > 0) {
+ if (!COFF::isReservedSectionNumber(Symb->SectionNumber)) {
const coff_section *Section = NULL;
if (error_code EC = getSection(Symb->SectionNumber, Section))
return EC;
@@ -239,9 +240,9 @@ error_code COFFObjectFile::getSymbolSize(DataRefImpl Ref,
error_code COFFObjectFile::getSymbolSection(DataRefImpl Ref,
section_iterator &Result) const {
const coff_symbol *Symb = toSymb(Ref);
- if (Symb->SectionNumber <= COFF::IMAGE_SYM_UNDEFINED)
+ if (COFF::isReservedSectionNumber(Symb->SectionNumber)) {
Result = section_end();
- else {
+ } else {
const coff_section *Sec = 0;
if (error_code EC = getSection(Symb->SectionNumber, Sec)) return EC;
DataRefImpl Ref;
@@ -721,9 +722,7 @@ error_code COFFObjectFile::getDataDirectory(uint32_t Index,
error_code COFFObjectFile::getSection(int32_t Index,
const coff_section *&Result) const {
// Check for special index values.
- if (Index == COFF::IMAGE_SYM_UNDEFINED ||
- Index == COFF::IMAGE_SYM_ABSOLUTE ||
- Index == COFF::IMAGE_SYM_DEBUG)
+ if (COFF::isReservedSectionNumber(Index))
Result = NULL;
else if (Index > 0 && Index <= COFFHeader->NumberOfSections)
// We already verified the section table data, so no need to check again.