diff options
| author | Andrew Chambers <[email protected]> | 2021-10-14 21:46:41 +1300 |
|---|---|---|
| committer | Andrew Chambers <[email protected]> | 2021-10-14 21:46:41 +1300 |
| commit | ec403dd16c5b417086e63faee5912b78a1ffeb59 (patch) | |
| tree | 25f007315c327d2a60a67e714ed9f8920d1c6d25 /main.c | |
| parent | eefef08f5a465eefe1eaf3d86950af6f6c30ee46 (diff) | |
Simplify.
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -52,10 +52,6 @@ static Symbol *getsym(const char *name) { return s; } -static const char *secname(Section *s) { - return (const char *)shstrtab->data + s->hdr.sh_name; -} - static void secaddbytes(Section *s, const void *bytes, size_t n) { if (s->hdr.sh_type == SHT_NOBITS) { @@ -92,10 +88,12 @@ static Section *newsection() { static Section *getsection(const char *name) { size_t i; + char *secname; Section *s; for (i = 0; i < nsections; i++) { - if (strcmp(secname(§ions[i]), name) == 0) + secname = (char *)shstrtab->data + sections[i].hdr.sh_name; + if (strcmp(secname, name) == 0) return §ions[i]; } s = newsection(); @@ -1201,6 +1199,7 @@ static void outelf(void) { } static void usage(char *argv0) { + fprintf(stderr, "minias - a mini assembler."); fprintf(stderr, "usage: %s [-o out] [input]\n", argv0); exit(2); } @@ -1215,6 +1214,7 @@ static void parseargs(int argc, char *argv[]) { break; for (a = &argv[0][1]; *a; a++) { switch (*a) { + case '-': case 'h': usage(argv0); break; |
