Skip to content

Commit

Permalink
Added some robustness for when dumpobj is run on files which are...
Browse files Browse the repository at this point in the history
almost an object file, such as an object library.
  • Loading branch information
Rhialto committed Jun 9, 2015
1 parent 22886c4 commit ce2d526
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion dumpobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ DAMAGE.

#define WORD(cp) ((*(cp) & 0xff) + ((*((cp)+1) & 0xff) << 8))

#define NPSECTS 256

int psectid = 0;
char *psects[256];
char *psects[NPSECTS];
FILE *bin = NULL;
int badbin = 0;
int xferad = 1;
Expand Down Expand Up @@ -367,6 +369,7 @@ void got_gsd(
flags);
psects[psectid] = strdup(name);
trim(psects[psectid++]);
psectid %= NPSECTS;
break;
case 6:
sprintf(gsdline, "\tIDENT %s=%o flags=%o\n", name, value, flags);
Expand Down Expand Up @@ -406,6 +409,10 @@ void got_endgsd(
(void)cp;
(void)len;

if (nr_gsds == 0) {
return;
}

qsort(all_gsds, nr_gsds, sizeof(char *), compare_gsdlines);

printf("GSD:\n");
Expand All @@ -418,6 +425,9 @@ void got_endgsd(
printf("ENDGSD\n");

free(all_gsds);
all_gsds = NULL;
nr_gsds = 0;
gsdsize = 0;
}

unsigned last_text_addr = 0;
Expand Down

0 comments on commit ce2d526

Please sign in to comment.