mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
Place a.out symbols at their image address
loadSymbols adds n_value to the start of the block the symbol belongs to, but n_value is an address (see https://man.freebsd.org/cgi/man.cgi?a.out(5) ), not an offset into its segment, so we need to subtract the segment's base. In most cases `determineTextAddr` is 0, so they are the same for the .text segment, which is why function symbols still loaded fine. But for the .data and .bss segments they don't, so their symbol locations ended up shifted.
This commit is contained in:
@@ -252,19 +252,20 @@ public class UnixAoutProgramLoader {
|
||||
|
||||
for (UnixAoutSymbol symbol : symtab) {
|
||||
Address address = null;
|
||||
long blockOffset = 0;
|
||||
MemoryBlock block = null;
|
||||
|
||||
switch (symbol.type) {
|
||||
case N_TEXT:
|
||||
address = textBlock != null ? textBlock.getStart().add(symbol.value) : null;
|
||||
blockOffset = symbol.value - header.getTextAddr();
|
||||
block = textBlock;
|
||||
break;
|
||||
case N_DATA:
|
||||
address = dataBlock != null ? dataBlock.getStart().add(symbol.value) : null;
|
||||
blockOffset = symbol.value - header.getDataAddr();
|
||||
block = dataBlock;
|
||||
break;
|
||||
case N_BSS:
|
||||
address = bssBlock != null ? bssBlock.getStart().add(symbol.value) : null;
|
||||
blockOffset = symbol.value - header.getBssAddr();
|
||||
block = bssBlock;
|
||||
break;
|
||||
case N_UNDF:
|
||||
@@ -290,10 +291,14 @@ public class UnixAoutProgramLoader {
|
||||
break;
|
||||
}
|
||||
|
||||
if (address == null || block == null) {
|
||||
if (block == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (address == null) {
|
||||
address = block.getStart().add(blockOffset);
|
||||
}
|
||||
|
||||
switch (symbol.kind) {
|
||||
case AUX_FUNC:
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user