scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 54a6246b34de6eaeb5ac6162d6930b88624563e6
parent 20dbcf4255dc3553c01b18d900d464a85564cc73
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 28 Nov 2017 20:32:51 +0100

[objdump] Print sections in one line format

It helps o scripts.

Diffstat:
Mobjdump/main.c | 51++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 38 insertions(+), 13 deletions(-)

diff --git a/objdump/main.c b/objdump/main.c @@ -72,29 +72,54 @@ printstrings(struct myrohdr *hdr) } } +static char * +sectflags(struct myrosect *sec) +{ + static char flags[10]; + char *s = flags + sizeof(flags); + + if (sec->flags & MYROSEC_READ) + *--s = 'R'; + if (sec->flags & MYROSEC_WRITE) + *--s = 'W'; + if (sec->flags & MYROSEC_EXEC) + *--s = 'X'; + if (sec->flags & MYROSEC_LOAD) + *--s = 'L'; + if (sec->flags & MYROSEC_FILE) + *--s = 'F'; + if (sec->flags & MYROSEC_ABS) + *--s = 'A'; + return s; +} + static int printsections(struct myrohdr *hdr, FILE *fp) { unsigned long long n, i; struct myrosect sect; - puts("sections:"); + printf("sections:\n" + "[Nr]\t%s\t%-16s\t%-16s\t%s\t%s\t%s\n", + "Name", + "Offset", + "Size", + "Fill", + "Align", + "Flags"); + n = hdr->secsize / MYROSECT_SIZ; for (i = 0; i < n; ++i) { if (rdmyrosec(fp, &sect) < 0) return -1; - printf("\tname: %lu (\"%s\")\n" - "\tflags: %x\n" - "\tfill: %x\n" - "\taligment: %u\n" - "\toffset: %llu\n" - "\tlength: %llu\n\n", - sect.name, getstring(sect.name), - sect.flags, - sect.fill, - sect.aligment, - sect.offset, - sect.len); + printf("[%2d]\t%s\t%016X\t%016X\t%02X\t%u\t%s\n", + i, + getstring(sect.name), + sect.offset, + sect.len, + sect.fill, + sect.aligment, + sectflags(&sect)); } return 0; }