Add getSymbolAlignment to the ObjectFile interface.
For regular object files this is only meaningful for common symbols. An object file format with direct support for atoms should be able to provide alignment information for all symbols. This replaces getCommonSymbolAlignment and fixes test-common-symbols-alignment.ll on darwin. This also includes a fix to MachOObjectFile::getSymbolFlags. It was marking undefined symbols as common (already tested by existing mcjit tests now that it is used). llvm-svn: 180736
This commit is contained in:
@@ -495,6 +495,19 @@ MachOObjectFile::getSymbolFileOffset(DataRefImpl Symb,
|
||||
return object_error::success;
|
||||
}
|
||||
|
||||
error_code MachOObjectFile::getSymbolAlignment(DataRefImpl DRI,
|
||||
uint32_t &Result) const {
|
||||
uint32_t flags;
|
||||
this->getSymbolFlags(DRI, flags);
|
||||
if (flags & SymbolRef::SF_Common) {
|
||||
SymbolTableEntryBase Entry = getSymbolTableEntryBase(this, DRI);
|
||||
Result = 1 << MachO::GET_COMM_ALIGN(Entry.Flags);
|
||||
} else {
|
||||
Result = 0;
|
||||
}
|
||||
return object_error::success;
|
||||
}
|
||||
|
||||
error_code MachOObjectFile::getSymbolSize(DataRefImpl DRI,
|
||||
uint64_t &Result) const {
|
||||
uint64_t BeginOffset;
|
||||
@@ -609,8 +622,12 @@ error_code MachOObjectFile::getSymbolFlags(DataRefImpl DRI,
|
||||
|
||||
if (MachOType & MachO::NlistMaskExternal) {
|
||||
Result |= SymbolRef::SF_Global;
|
||||
if ((MachOType & MachO::NlistMaskType) == MachO::NListTypeUndefined)
|
||||
Result |= SymbolRef::SF_Common;
|
||||
if ((MachOType & MachO::NlistMaskType) == MachO::NListTypeUndefined) {
|
||||
uint64_t Value;
|
||||
getSymbolAddress(DRI, Value);
|
||||
if (Value)
|
||||
Result |= SymbolRef::SF_Common;
|
||||
}
|
||||
}
|
||||
|
||||
if (MachOFlags & (MachO::NListDescWeakRef | MachO::NListDescWeakDef))
|
||||
|
||||
Reference in New Issue
Block a user