commit f627c8efe61656e28b04a5f8bdd05477c765a2dc
parent 40276ee4198f7553c815e0e785f2f1062077e2b8
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Tue, 21 Jan 2025 19:29:51 +0100
objdump/coff32: Fix file header printing
Checking in advance for pflag was avoiding assinging the start address
that only can be known when we know that we have an aout header.
Diffstat:
1 file changed, 36 insertions(+), 35 deletions(-)
diff --git a/src/cmd/scc-objdump/coff32.c b/src/cmd/scc-objdump/coff32.c
@@ -125,43 +125,44 @@ coff32fhdr(Obj *obj, unsigned long long *start, Flags *f)
setflag(f, flags & F_EXEC, EXEC_P);
setflag(f, flags & F_EXEC, D_PAGED);
- if (!pflag)
- return;
-
- printf("FILEHDR:\n"
- "\tf_magic: %#x\n"
- "\tf_nscns: %u\n"
- "\tf_timdat: %ld\n"
- "\tf_symptr: %ld\n"
- "\tf_nsyms: %ld\n"
- "\tf_opthdr: %u\n"
- "\tf_flags: 0x%04x\n\n",
- hdr->f_magic,
- hdr->f_nscns,
- hdr->f_timdat,
- hdr->f_symptr,
- hdr->f_nsyms,
- hdr->f_opthdr,
- hdr->f_flags);
+ if (pflag) {
+ printf("FILEHDR:\n"
+ "\tf_magic: %#x\n"
+ "\tf_nscns: %u\n"
+ "\tf_timdat: %ld\n"
+ "\tf_symptr: %ld\n"
+ "\tf_nsyms: %ld\n"
+ "\tf_opthdr: %u\n"
+ "\tf_flags: 0x%04x\n\n",
+ hdr->f_magic,
+ hdr->f_nscns,
+ hdr->f_timdat,
+ hdr->f_symptr,
+ hdr->f_nsyms,
+ hdr->f_opthdr,
+ hdr->f_flags);
+ }
if (hdr->f_opthdr > 0) {
- printf("AOUTHDR:\n"
- "\tmagic: %x\n"
- "\tvstamp: %x\n"
- "\ttsize: %04lx\n"
- "\tdsize: %04lx\n"
- "\tbsize: %04lx\n"
- "\tentry: %04lx\n"
- "\ttext_start: %04lx\n"
- "\tdata_start: %04lx\n\n",
- aout->magic,
- aout->vstamp,
- aout->tsize,
- aout->dsize,
- aout->bsize,
- aout->entry,
- aout->text_start,
- aout->data_start);
*start = aout->entry;
+ if (pflag) {
+ printf("AOUTHDR:\n"
+ "\tmagic: %x\n"
+ "\tvstamp: %x\n"
+ "\ttsize: %04lx\n"
+ "\tdsize: %04lx\n"
+ "\tbsize: %04lx\n"
+ "\tentry: %04lx\n"
+ "\ttext_start: %04lx\n"
+ "\tdata_start: %04lx\n\n",
+ aout->magic,
+ aout->vstamp,
+ aout->tsize,
+ aout->dsize,
+ aout->bsize,
+ aout->entry,
+ aout->text_start,
+ aout->data_start);
+ }
}
}