mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-15 05:24:01 +00:00
Object: make the following changes into SymbolRef
- Add enum SymbolType and function getSymbolType() - Add function isGlobal() - it's returns true for symbols that can be used in another objects, such as library functions. - Rename function getAddress() to getOffset() and add new function getAddress(), because currently getAddress() returns section offset of symbol first byte. new getAddress() return symbol address. - Change usage SymbolRef::getAddress() to getOffset() in tools/llvm-nm and tools/llvm-objdump. Patch by Danil Malyshev! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139683 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -114,7 +114,7 @@ error_code COFFObjectFile::getSymbolNext(DataRefImpl Symb,
|
||||
return object_error::success;
|
||||
}
|
||||
|
||||
error_code COFFObjectFile::getSymbolAddress(DataRefImpl Symb,
|
||||
error_code COFFObjectFile::getSymbolOffset(DataRefImpl Symb,
|
||||
uint64_t &Result) const {
|
||||
const coff_symbol *symb = toSymb(Symb);
|
||||
const coff_section *Section = NULL;
|
||||
@ -132,6 +132,55 @@ error_code COFFObjectFile::getSymbolAddress(DataRefImpl Symb,
|
||||
return object_error::success;
|
||||
}
|
||||
|
||||
error_code COFFObjectFile::getSymbolAddress(DataRefImpl Symb,
|
||||
uint64_t &Result) const {
|
||||
const coff_symbol *symb = toSymb(Symb);
|
||||
const coff_section *Section = NULL;
|
||||
if (error_code ec = getSection(symb->SectionNumber, Section))
|
||||
return ec;
|
||||
char Type;
|
||||
if (error_code ec = getSymbolNMTypeChar(Symb, Type))
|
||||
return ec;
|
||||
if (Type == 'U' || Type == 'w')
|
||||
Result = UnknownAddressOrSize;
|
||||
else if (Section)
|
||||
Result = reinterpret_cast<uintptr_t>(base() +
|
||||
Section->PointerToRawData +
|
||||
symb->Value);
|
||||
else
|
||||
Result = reinterpret_cast<uintptr_t>(base() + symb->Value);
|
||||
return object_error::success;
|
||||
}
|
||||
|
||||
error_code COFFObjectFile::getSymbolType(DataRefImpl Symb,
|
||||
SymbolRef::SymbolType &Result) const {
|
||||
const coff_symbol *symb = toSymb(Symb);
|
||||
Result = SymbolRef::ST_Other;
|
||||
if (symb->StorageClass == COFF::IMAGE_SYM_CLASS_EXTERNAL &&
|
||||
symb->SectionNumber == COFF::IMAGE_SYM_UNDEFINED) {
|
||||
Result = SymbolRef::ST_External;
|
||||
} else {
|
||||
if (symb->Type.ComplexType == COFF::IMAGE_SYM_DTYPE_FUNCTION) {
|
||||
Result = SymbolRef::ST_Function;
|
||||
} else {
|
||||
char Type;
|
||||
if (error_code ec = getSymbolNMTypeChar(Symb, Type))
|
||||
return ec;
|
||||
if (Type == 'r' || Type == 'R') {
|
||||
Result = SymbolRef::ST_Data;
|
||||
}
|
||||
}
|
||||
}
|
||||
return object_error::success;
|
||||
}
|
||||
|
||||
error_code COFFObjectFile::isSymbolGlobal(DataRefImpl Symb,
|
||||
bool &Result) const {
|
||||
const coff_symbol *symb = toSymb(Symb);
|
||||
Result = (symb->StorageClass == COFF::IMAGE_SYM_CLASS_EXTERNAL);
|
||||
return object_error::success;
|
||||
}
|
||||
|
||||
error_code COFFObjectFile::getSymbolSize(DataRefImpl Symb,
|
||||
uint64_t &Result) const {
|
||||
// FIXME: Return the correct size. This requires looking at all the symbols
|
||||
|
Reference in New Issue
Block a user