summaryrefslogtreecommitdiff
path: root/lib/Object/COFFObjectFile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Object/COFFObjectFile.cpp')
-rw-r--r--lib/Object/COFFObjectFile.cpp40
1 files changed, 29 insertions, 11 deletions
diff --git a/lib/Object/COFFObjectFile.cpp b/lib/Object/COFFObjectFile.cpp
index b544fa5c14702..d72da3187e079 100644
--- a/lib/Object/COFFObjectFile.cpp
+++ b/lib/Object/COFFObjectFile.cpp
@@ -217,10 +217,10 @@ uint32_t COFFObjectFile::getSymbolFlags(DataRefImpl Ref) const {
if (Symb.isExternal() || Symb.isWeakExternal())
Result |= SymbolRef::SF_Global;
- if (Symb.isWeakExternal()) {
+ if (const coff_aux_weak_external *AWE = Symb.getWeakExternal()) {
Result |= SymbolRef::SF_Weak;
- // We use indirect to allow the archiver to write weak externs
- Result |= SymbolRef::SF_Indirect;
+ if (AWE->Characteristics != COFF::IMAGE_WEAK_EXTERN_SEARCH_ALIAS)
+ Result |= SymbolRef::SF_Undefined;
}
if (Symb.getSectionNumber() == COFF::IMAGE_SYM_ABSOLUTE)
@@ -235,7 +235,7 @@ uint32_t COFFObjectFile::getSymbolFlags(DataRefImpl Ref) const {
if (Symb.isCommon())
Result |= SymbolRef::SF_Common;
- if (Symb.isAnyUndefined())
+ if (Symb.isUndefined())
Result |= SymbolRef::SF_Undefined;
return Result;
@@ -910,6 +910,12 @@ Triple::ArchType COFFObjectFile::getArch() const {
}
}
+Expected<uint64_t> COFFObjectFile::getStartAddress() const {
+ if (PE32Header)
+ return PE32Header->AddressOfEntryPoint;
+ return 0;
+}
+
iterator_range<import_directory_iterator>
COFFObjectFile::import_directories() const {
return make_range(import_directory_begin(), import_directory_end());
@@ -944,7 +950,7 @@ COFFObjectFile::getPE32PlusHeader(const pe32plus_header *&Res) const {
std::error_code
COFFObjectFile::getDataDirectory(uint32_t Index,
const data_directory *&Res) const {
- // Error if if there's no data directory or the index is out of range.
+ // Error if there's no data directory or the index is out of range.
if (!DataDirectory) {
Res = nullptr;
return object_error::parse_failed;
@@ -973,6 +979,21 @@ std::error_code COFFObjectFile::getSection(int32_t Index,
return object_error::parse_failed;
}
+std::error_code COFFObjectFile::getSection(StringRef SectionName,
+ const coff_section *&Result) const {
+ Result = nullptr;
+ StringRef SecName;
+ for (const SectionRef &Section : sections()) {
+ if (std::error_code E = Section.getName(SecName))
+ return E;
+ if (SecName == SectionName) {
+ Result = getCOFFSection(Section);
+ return std::error_code();
+ }
+ }
+ return object_error::parse_failed;
+}
+
std::error_code COFFObjectFile::getString(uint32_t Offset,
StringRef &Result) const {
if (StringTableSize <= 4)
@@ -1147,13 +1168,10 @@ COFFObjectFile::getCOFFRelocation(const RelocationRef &Reloc) const {
return toRel(Reloc.getRawDataRefImpl());
}
-iterator_range<const coff_relocation *>
+ArrayRef<coff_relocation>
COFFObjectFile::getRelocations(const coff_section *Sec) const {
- const coff_relocation *I = getFirstReloc(Sec, Data, base());
- const coff_relocation *E = I;
- if (I)
- E += getNumberOfRelocations(Sec, Data, base());
- return make_range(I, E);
+ return {getFirstReloc(Sec, Data, base()),
+ getNumberOfRelocations(Sec, Data, base())};
}
#define LLVM_COFF_SWITCH_RELOC_TYPE_NAME(reloc_type) \