mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
[Object] Add symbol attribute flags: ST_ThreadLocal, ST_Common, and ST_Undefined. Implement these completely for ELF.
Rename ST_External to ST_Unknown, and slightly change its semantics. It now only indicates that the symbol's type is unknown, not that the symbol is undefined. (For that, use ST_Undefined). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151696 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -625,12 +625,10 @@ error_code ELFObjectFile<target_endianness, is64Bits>
|
|||||||
validateSymbol(Symb);
|
validateSymbol(Symb);
|
||||||
const Elf_Sym *symb = getSymbol(Symb);
|
const Elf_Sym *symb = getSymbol(Symb);
|
||||||
|
|
||||||
if (getSymbolTableIndex(symb) == ELF::SHN_UNDEF) {
|
|
||||||
Result = SymbolRef::ST_External;
|
|
||||||
return object_error::success;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (symb->getType()) {
|
switch (symb->getType()) {
|
||||||
|
case ELF::STT_NOTYPE:
|
||||||
|
Result = SymbolRef::ST_Unknown;
|
||||||
|
break;
|
||||||
case ELF::STT_SECTION:
|
case ELF::STT_SECTION:
|
||||||
Result = SymbolRef::ST_Debug;
|
Result = SymbolRef::ST_Debug;
|
||||||
break;
|
break;
|
||||||
@@ -641,6 +639,8 @@ error_code ELFObjectFile<target_endianness, is64Bits>
|
|||||||
Result = SymbolRef::ST_Function;
|
Result = SymbolRef::ST_Function;
|
||||||
break;
|
break;
|
||||||
case ELF::STT_OBJECT:
|
case ELF::STT_OBJECT:
|
||||||
|
case ELF::STT_COMMON:
|
||||||
|
case ELF::STT_TLS:
|
||||||
Result = SymbolRef::ST_Data;
|
Result = SymbolRef::ST_Data;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -672,6 +672,16 @@ error_code ELFObjectFile<target_endianness, is64Bits>
|
|||||||
symb->getType() == ELF::STT_SECTION)
|
symb->getType() == ELF::STT_SECTION)
|
||||||
Result |= SymbolRef::SF_FormatSpecific;
|
Result |= SymbolRef::SF_FormatSpecific;
|
||||||
|
|
||||||
|
if (getSymbolTableIndex(symb) == ELF::SHN_UNDEF)
|
||||||
|
Result |= SymbolRef::SF_Undefined;
|
||||||
|
|
||||||
|
if (symb->getType() == ELF::STT_COMMON ||
|
||||||
|
getSymbolTableIndex(symb) == ELF::SHN_COMMON)
|
||||||
|
Result |= SymbolRef::SF_Common;
|
||||||
|
|
||||||
|
if (symb->getType() == ELF::STT_TLS)
|
||||||
|
Result |= SymbolRef::SF_ThreadLocal;
|
||||||
|
|
||||||
return object_error::success;
|
return object_error::success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -180,9 +180,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum Type {
|
enum Type {
|
||||||
|
ST_Unknown, // Type not specified
|
||||||
ST_Data,
|
ST_Data,
|
||||||
ST_Debug,
|
ST_Debug,
|
||||||
ST_External, // Defined in another object file
|
|
||||||
ST_File,
|
ST_File,
|
||||||
ST_Function,
|
ST_Function,
|
||||||
ST_Other
|
ST_Other
|
||||||
@@ -190,11 +190,14 @@ public:
|
|||||||
|
|
||||||
enum Flags {
|
enum Flags {
|
||||||
SF_None = 0,
|
SF_None = 0,
|
||||||
SF_Global = 1 << 0, // Global symbol
|
SF_Undefined = 1U << 0, // Symbol is defined in another object file
|
||||||
SF_Weak = 1 << 1, // Weak symbol
|
SF_Global = 1U << 1, // Global symbol
|
||||||
SF_Absolute = 1 << 2, // Absolute symbol
|
SF_Weak = 1U << 2, // Weak symbol
|
||||||
SF_FormatSpecific = 1 << 3 // Specific to the object file format
|
SF_Absolute = 1U << 3, // Absolute symbol
|
||||||
// (e.g. section symbols)
|
SF_ThreadLocal = 1U << 4, // Thread local symbol
|
||||||
|
SF_Common = 1U << 5, // Symbol has common linkage
|
||||||
|
SF_FormatSpecific = 1U << 31 // Specific to the object file format
|
||||||
|
// (e.g. section symbols)
|
||||||
};
|
};
|
||||||
|
|
||||||
SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner);
|
SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner);
|
||||||
|
@@ -143,7 +143,7 @@ error_code COFFObjectFile::getSymbolType(DataRefImpl Symb,
|
|||||||
Result = SymbolRef::ST_Other;
|
Result = SymbolRef::ST_Other;
|
||||||
if (symb->StorageClass == COFF::IMAGE_SYM_CLASS_EXTERNAL &&
|
if (symb->StorageClass == COFF::IMAGE_SYM_CLASS_EXTERNAL &&
|
||||||
symb->SectionNumber == COFF::IMAGE_SYM_UNDEFINED) {
|
symb->SectionNumber == COFF::IMAGE_SYM_UNDEFINED) {
|
||||||
Result = SymbolRef::ST_External;
|
Result = SymbolRef::ST_Unknown;
|
||||||
} else {
|
} else {
|
||||||
if (symb->getComplexType() == COFF::IMAGE_SYM_DTYPE_FUNCTION) {
|
if (symb->getComplexType() == COFF::IMAGE_SYM_DTYPE_FUNCTION) {
|
||||||
Result = SymbolRef::ST_Function;
|
Result = SymbolRef::ST_Function;
|
||||||
@@ -164,7 +164,11 @@ error_code COFFObjectFile::getSymbolFlags(DataRefImpl Symb,
|
|||||||
const coff_symbol *symb = toSymb(Symb);
|
const coff_symbol *symb = toSymb(Symb);
|
||||||
Result = SymbolRef::SF_None;
|
Result = SymbolRef::SF_None;
|
||||||
|
|
||||||
// TODO: Set SF_FormatSpecific.
|
// TODO: Correctly set SF_FormatSpecific, SF_ThreadLocal, SF_Common
|
||||||
|
|
||||||
|
if (symb->StorageClass == COFF::IMAGE_SYM_CLASS_EXTERNAL &&
|
||||||
|
symb->SectionNumber == COFF::IMAGE_SYM_UNDEFINED)
|
||||||
|
Result |= SymbolRef::SF_Undefined;
|
||||||
|
|
||||||
// TODO: This are certainly too restrictive.
|
// TODO: This are certainly too restrictive.
|
||||||
if (symb->StorageClass == COFF::IMAGE_SYM_CLASS_EXTERNAL)
|
if (symb->StorageClass == COFF::IMAGE_SYM_CLASS_EXTERNAL)
|
||||||
|
@@ -278,7 +278,12 @@ error_code MachOObjectFile::getSymbolFlags(DataRefImpl DRI,
|
|||||||
MachOType = Entry->Type;
|
MachOType = Entry->Type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Correctly set SF_ThreadLocal and SF_Common.
|
||||||
Result = SymbolRef::SF_None;
|
Result = SymbolRef::SF_None;
|
||||||
|
|
||||||
|
if ((MachOType & MachO::NlistMaskType) == MachO::NListTypeUndefined)
|
||||||
|
Result |= SymbolRef::SF_Undefined;
|
||||||
|
|
||||||
if (MachOFlags & macho::STF_StabsEntryMask)
|
if (MachOFlags & macho::STF_StabsEntryMask)
|
||||||
Result |= SymbolRef::SF_FormatSpecific;
|
Result |= SymbolRef::SF_FormatSpecific;
|
||||||
|
|
||||||
@@ -337,7 +342,7 @@ error_code MachOObjectFile::getSymbolType(DataRefImpl Symb,
|
|||||||
|
|
||||||
switch (n_type & MachO::NlistMaskType) {
|
switch (n_type & MachO::NlistMaskType) {
|
||||||
case MachO::NListTypeUndefined :
|
case MachO::NListTypeUndefined :
|
||||||
Res = SymbolRef::ST_External;
|
Res = SymbolRef::ST_Unknown;
|
||||||
break;
|
break;
|
||||||
case MachO::NListTypeSection :
|
case MachO::NListTypeSection :
|
||||||
Res = SymbolRef::ST_Function;
|
Res = SymbolRef::ST_Function;
|
||||||
@@ -554,7 +559,7 @@ error_code MachOObjectFile::sectionContainsSymbol(DataRefImpl Sec,
|
|||||||
bool &Result) const {
|
bool &Result) const {
|
||||||
SymbolRef::Type ST;
|
SymbolRef::Type ST;
|
||||||
getSymbolType(Symb, ST);
|
getSymbolType(Symb, ST);
|
||||||
if (ST == SymbolRef::ST_External) {
|
if (ST == SymbolRef::ST_Unknown) {
|
||||||
Result = false;
|
Result = false;
|
||||||
return object_error::success;
|
return object_error::success;
|
||||||
}
|
}
|
||||||
|
@@ -502,7 +502,7 @@ static void PrintSymbolTable(const ObjectFile *o) {
|
|||||||
if (Size == UnknownAddressOrSize)
|
if (Size == UnknownAddressOrSize)
|
||||||
Size = 0;
|
Size = 0;
|
||||||
char GlobLoc = ' ';
|
char GlobLoc = ' ';
|
||||||
if (Type != SymbolRef::ST_External)
|
if (Type != SymbolRef::ST_Unknown)
|
||||||
GlobLoc = Global ? 'g' : 'l';
|
GlobLoc = Global ? 'g' : 'l';
|
||||||
char Debug = (Type == SymbolRef::ST_Debug || Type == SymbolRef::ST_File)
|
char Debug = (Type == SymbolRef::ST_Debug || Type == SymbolRef::ST_File)
|
||||||
? 'd' : ' ';
|
? 'd' : ' ';
|
||||||
|
Reference in New Issue
Block a user