Adds section base address.
This commit is contained in:
parent
9a69d7d3d7
commit
0a70f1cbd7
3 changed files with 8 additions and 5 deletions
|
@ -24,6 +24,7 @@ struct expfile
|
|||
struct expsection
|
||||
{
|
||||
uint32_t type; // Type of the section: 0 = code, 1 = data
|
||||
uint32_t base; // Base address of the section in memory.
|
||||
uint32_t start; // File pointer to the begin of the section
|
||||
uint32_t length; // Length of the section in bytes
|
||||
char name[64]; // Name of the section, null terminated c-string
|
||||
|
|
|
@ -103,14 +103,14 @@ const char *commandStrings[] =
|
|||
|
||||
int disassembleVerbose = 0;
|
||||
|
||||
void disassemble(Instruction *list, uint32_t count, FILE *f)
|
||||
void disassemble(Instruction *list, uint32_t count, uint32_t base, FILE *f)
|
||||
{
|
||||
int v = disassembleVerbose;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
Instruction instr = list[i];
|
||||
|
||||
fprintf(f, "%8X: ", i);
|
||||
fprintf(f, "%8X: ", base + i);
|
||||
|
||||
struct PredefinedCmd *knownInstruction = NULL;
|
||||
|
||||
|
@ -287,9 +287,10 @@ int main(int argc, char **argv)
|
|||
fprintf(stdout, " Section #%d\n", i);
|
||||
fprintf(stdout, " Name: %s\n", section.name);
|
||||
fprintf(stdout, " Type: %s\n", (section.type ? "Data" : "Code"));
|
||||
fprintf(stdout, " Base: 0x%X\n", section.base);
|
||||
fprintf(stdout, " Start: %d\n", section.start);
|
||||
fprintf(stdout, " Size: %d\n", section.length);
|
||||
|
||||
|
||||
// Call disassembler
|
||||
if (disassembleSections && section.type == 0)
|
||||
{
|
||||
|
@ -305,6 +306,7 @@ int main(int argc, char **argv)
|
|||
disassemble(
|
||||
buffer,
|
||||
section.length / sizeof(Instruction),
|
||||
section.base,
|
||||
stdout);
|
||||
|
||||
free(buffer);
|
||||
|
|
|
@ -97,10 +97,10 @@ int main(int argc, char **argv)
|
|||
|
||||
DEBUG_VAL(fileHeader.posSections);
|
||||
|
||||
expsection_t codeSection = { 0 };
|
||||
expsection_t codeSection = { 0, 0 };
|
||||
strcpy(codeSection.name, ".code");
|
||||
|
||||
expsection_t dataSection = { 1 };
|
||||
expsection_t dataSection = { 1, 0 };
|
||||
strcpy(dataSection.name, ".data");
|
||||
|
||||
if (codefileName != NULL)
|
||||
|
|
Loading…
Reference in a new issue