Object, COFF: Cleanup symbol type code, improve binutils compatibility

Do a better job classifying symbols.  This increases the consistency
between the COFF handling code and the ELF side of things.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220952 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Majnemer
2014-10-31 05:07:00 +00:00
parent 534d9042b1
commit a2715904e5
9 changed files with 112 additions and 68 deletions

View File

@ -301,9 +301,26 @@ public:
uint8_t getComplexType() const { return (getType() & 0xF0) >> 4; }
bool isExternal() const {
return getStorageClass() == COFF::IMAGE_SYM_CLASS_EXTERNAL;
}
bool isCommon() const {
return isExternal() && getSectionNumber() == COFF::IMAGE_SYM_UNDEFINED &&
getValue() != 0;
}
bool isUndefined() const {
return isExternal() && getSectionNumber() == COFF::IMAGE_SYM_UNDEFINED &&
getValue() == 0;
}
bool isWeakExternal() const {
return getStorageClass() == COFF::IMAGE_SYM_CLASS_WEAK_EXTERNAL;
}
bool isFunctionDefinition() const {
return getStorageClass() == COFF::IMAGE_SYM_CLASS_EXTERNAL &&
getBaseType() == COFF::IMAGE_SYM_TYPE_NULL &&
return isExternal() && getBaseType() == COFF::IMAGE_SYM_TYPE_NULL &&
getComplexType() == COFF::IMAGE_SYM_DTYPE_FUNCTION &&
!COFF::isReservedSectionNumber(getSectionNumber());
}
@ -312,10 +329,8 @@ public:
return getStorageClass() == COFF::IMAGE_SYM_CLASS_FUNCTION;
}
bool isWeakExternal() const {
return getStorageClass() == COFF::IMAGE_SYM_CLASS_WEAK_EXTERNAL ||
(getStorageClass() == COFF::IMAGE_SYM_CLASS_EXTERNAL &&
getSectionNumber() == COFF::IMAGE_SYM_UNDEFINED && getValue() == 0);
bool isAnyUndefined() const {
return isUndefined() || isWeakExternal();
}
bool isFileRecord() const {
@ -329,6 +344,8 @@ public:
getStorageClass() == COFF::IMAGE_SYM_CLASS_EXTERNAL &&
getSectionNumber() == COFF::IMAGE_SYM_ABSOLUTE;
bool isOrdinarySection = getStorageClass() == COFF::IMAGE_SYM_CLASS_STATIC;
if (!getNumberOfAuxSymbols())
return false;
return isAppdomainGlobal || isOrdinarySection;
}