aboutsummaryrefslogtreecommitdiff
path: root/lib/Object
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Object')
-rw-r--r--lib/Object/COFFObjectFile.cpp21
-rw-r--r--lib/Object/MachOObjectFile.cpp55
2 files changed, 72 insertions, 4 deletions
diff --git a/lib/Object/COFFObjectFile.cpp b/lib/Object/COFFObjectFile.cpp
index 53b15d07ea..bd27a56e73 100644
--- a/lib/Object/COFFObjectFile.cpp
+++ b/lib/Object/COFFObjectFile.cpp
@@ -356,6 +356,27 @@ error_code COFFObjectFile::isSectionBSS(DataRefImpl Sec,
return object_error::success;
}
+error_code COFFObjectFile::isSectionRequiredForExecution(DataRefImpl Sec,
+ bool &Result) const {
+ // FIXME: Unimplemented
+ Result = true;
+ return object_error::success;
+}
+
+error_code COFFObjectFile::isSectionVirtual(DataRefImpl Sec,
+ bool &Result) const {
+ const coff_section *sec = toSec(Sec);
+ Result = sec->Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA;
+ return object_error::success;
+}
+
+error_code COFFObjectFile::isSectionZeroInit(DataRefImpl Sec,
+ bool &Result) const {
+ // FIXME: Unimplemented
+ Result = false;
+ return object_error::success;
+}
+
error_code COFFObjectFile::sectionContainsSymbol(DataRefImpl Sec,
DataRefImpl Symb,
bool &Result) const {
diff --git a/lib/Object/MachOObjectFile.cpp b/lib/Object/MachOObjectFile.cpp
index ac90d5ccb4..1078faa481 100644
--- a/lib/Object/MachOObjectFile.cpp
+++ b/lib/Object/MachOObjectFile.cpp
@@ -175,7 +175,12 @@ error_code MachOObjectFile::getSymbolSize(DataRefImpl DRI,
BeginOffset = Entry->Value;
SectionIndex = Entry->SectionIndex;
if (!SectionIndex) {
- Result = UnknownAddressOrSize;
+ uint32_t flags = SymbolRef::SF_None;
+ getSymbolFlags(DRI, flags);
+ if (flags & SymbolRef::SF_Common)
+ Result = Entry->Value;
+ else
+ Result = UnknownAddressOrSize;
return object_error::success;
}
// Unfortunately symbols are unsorted so we need to touch all
@@ -198,7 +203,12 @@ error_code MachOObjectFile::getSymbolSize(DataRefImpl DRI,
BeginOffset = Entry->Value;
SectionIndex = Entry->SectionIndex;
if (!SectionIndex) {
- Result = UnknownAddressOrSize;
+ uint32_t flags = SymbolRef::SF_None;
+ getSymbolFlags(DRI, flags);
+ if (flags & SymbolRef::SF_Common)
+ Result = Entry->Value;
+ else
+ Result = UnknownAddressOrSize;
return object_error::success;
}
// Unfortunately symbols are unsorted so we need to touch all
@@ -265,19 +275,22 @@ error_code MachOObjectFile::getSymbolFlags(DataRefImpl DRI,
uint32_t &Result) const {
uint16_t MachOFlags;
uint8_t MachOType;
+ uint8_t MachOSectionIndex;
if (MachOObj->is64Bit()) {
InMemoryStruct<macho::Symbol64TableEntry> Entry;
getSymbol64TableEntry(DRI, Entry);
MachOFlags = Entry->Flags;
MachOType = Entry->Type;
+ MachOSectionIndex = Entry->SectionIndex;
} else {
InMemoryStruct<macho::SymbolTableEntry> Entry;
getSymbolTableEntry(DRI, Entry);
MachOFlags = Entry->Flags;
MachOType = Entry->Type;
+ MachOSectionIndex = Entry->SectionIndex;
}
- // TODO: Correctly set SF_ThreadLocal and SF_Common.
+ // TODO: Correctly set SF_ThreadLocal
Result = SymbolRef::SF_None;
if ((MachOType & MachO::NlistMaskType) == MachO::NListTypeUndefined)
@@ -286,8 +299,11 @@ error_code MachOObjectFile::getSymbolFlags(DataRefImpl DRI,
if (MachOFlags & macho::STF_StabsEntryMask)
Result |= SymbolRef::SF_FormatSpecific;
- if (MachOType & MachO::NlistMaskExternal)
+ if (MachOType & MachO::NlistMaskExternal) {
Result |= SymbolRef::SF_Global;
+ if ((MachOType & MachO::NlistMaskType) == MachO::NListTypeUndefined)
+ Result |= SymbolRef::SF_Common;
+ }
if (MachOFlags & (MachO::NListDescWeakRef | MachO::NListDescWeakDef))
Result |= SymbolRef::SF_Weak;
@@ -566,6 +582,37 @@ error_code MachOObjectFile::isSectionBSS(DataRefImpl DRI,
return object_error::success;
}
+error_code MachOObjectFile::isSectionRequiredForExecution(DataRefImpl Sec,
+ bool &Result) const {
+ // FIXME: Unimplemented
+ Result = true;
+ return object_error::success;
+}
+
+error_code MachOObjectFile::isSectionVirtual(DataRefImpl Sec,
+ bool &Result) const {
+ // FIXME: Unimplemented
+ Result = false;
+ return object_error::success;
+}
+
+error_code MachOObjectFile::isSectionZeroInit(DataRefImpl DRI,
+ bool &Result) const {
+ if (MachOObj->is64Bit()) {
+ InMemoryStruct<macho::Section64> Sect;
+ getSection64(DRI, Sect);
+ Result = (Sect->Flags & MachO::SectionTypeZeroFill ||
+ Sect->Flags & MachO::SectionTypeZeroFillLarge);
+ } else {
+ InMemoryStruct<macho::Section> Sect;
+ getSection(DRI, Sect);
+ Result = (Sect->Flags & MachO::SectionTypeZeroFill ||
+ Sect->Flags & MachO::SectionTypeZeroFillLarge);
+ }
+
+ return object_error::success;
+}
+
error_code MachOObjectFile::sectionContainsSymbol(DataRefImpl Sec,
DataRefImpl Symb,
bool &Result) const {