aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorAndrew Chambers <[email protected]>2021-10-14 21:46:41 +1300
committerAndrew Chambers <[email protected]>2021-10-14 21:46:41 +1300
commitec403dd16c5b417086e63faee5912b78a1ffeb59 (patch)
tree25f007315c327d2a60a67e714ed9f8920d1c6d25 /main.c
parenteefef08f5a465eefe1eaf3d86950af6f6c30ee46 (diff)
Simplify.
Diffstat (limited to 'main.c')
-rw-r--r--main.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/main.c b/main.c
index c3ebf98..dd3c3db 100644
--- a/main.c
+++ b/main.c
@@ -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(&sections[i]), name) == 0)
+ secname = (char *)shstrtab->data + sections[i].hdr.sh_name;
+ if (strcmp(secname, name) == 0)
return &sections[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;