mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-26 05:25:47 +00:00
[dsymutil] Add function size to the debug map.
The debug map embedded by ld64 in binaries conatins function sizes. These sizes are less precise than the ones given by the debug information (byte granularity vs linker atom granularity), but they might cover code that is referenced in the line table but not in the DIE tree (that might very well be a compiler bug that I need to investigate later). Anyway, extracting that information is necessary to be able to mimic dsymutil's behavior exactly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232300 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -51,6 +51,10 @@ private:
|
||||
/// Element of the debug map corresponfing to the current object file.
|
||||
DebugMapObject *CurrentDebugMapObject;
|
||||
|
||||
/// Holds function info while function scope processing.
|
||||
const char *CurrentFunctionName;
|
||||
uint64_t CurrentFunctionAddress;
|
||||
|
||||
void switchToNewDebugMapObject(StringRef Filename);
|
||||
void resetParserState();
|
||||
uint64_t getMainBinarySymbolAddress(StringRef Name);
|
||||
@@ -149,6 +153,7 @@ void MachODebugMapParser::handleStabSymbolTableEntry(uint32_t StringIndex,
|
||||
if (!CurrentDebugMapObject)
|
||||
return;
|
||||
|
||||
uint32_t Size = 0;
|
||||
switch (Type) {
|
||||
case MachO::N_GSYM:
|
||||
// This is a global variable. We need to query the main binary
|
||||
@@ -159,11 +164,18 @@ void MachODebugMapParser::handleStabSymbolTableEntry(uint32_t StringIndex,
|
||||
return;
|
||||
break;
|
||||
case MachO::N_FUN:
|
||||
// Functions are scopes in STABS. They have an end marker that we
|
||||
// need to ignore.
|
||||
if (Name[0] == '\0')
|
||||
// Functions are scopes in STABS. They have an end marker that
|
||||
// contains the function size.
|
||||
if (Name[0] == '\0') {
|
||||
Size = Value;
|
||||
Value = CurrentFunctionAddress;
|
||||
Name = CurrentFunctionName;
|
||||
break;
|
||||
} else {
|
||||
CurrentFunctionName = Name;
|
||||
CurrentFunctionAddress = Value;
|
||||
return;
|
||||
break;
|
||||
}
|
||||
case MachO::N_STSYM:
|
||||
break;
|
||||
default:
|
||||
@@ -174,7 +186,8 @@ void MachODebugMapParser::handleStabSymbolTableEntry(uint32_t StringIndex,
|
||||
if (ObjectSymIt == CurrentObjectAddresses.end())
|
||||
return Warning("could not find object file symbol for symbol " +
|
||||
Twine(Name));
|
||||
if (!CurrentDebugMapObject->addSymbol(Name, ObjectSymIt->getValue(), Value))
|
||||
if (!CurrentDebugMapObject->addSymbol(Name, ObjectSymIt->getValue(), Value,
|
||||
Size))
|
||||
return Warning(Twine("failed to insert symbol '") + Name +
|
||||
"' in the debug map.");
|
||||
}
|
||||
|
Reference in New Issue
Block a user