Mercurial > hg > index.cgi
comparison lwasm/main.c @ 365:3f8abaac214c
Add map file output and option to suppress local symbols in listings
Add --map option to generate a symbol map in a regular format that can be
used as an import for other tools.
Also add --symbols-nolocals to suppress output of local symbols in the
symbol listing. In other words, only global symbols are listed.
Thanks to Erik G <erik@6809.org> for the patch.
author | William Astle <lost@l-w.ca> |
---|---|
date | Tue, 02 Jun 2015 20:08:58 -0600 |
parents | 5d401d1eb3e9 |
children | 433dbc18fb41 |
comparison
equal
deleted
inserted
replaced
364:44270b66df3c | 365:3f8abaac214c |
---|---|
45 { "output", 'o', "FILE", 0, "Output to FILE"}, | 45 { "output", 'o', "FILE", 0, "Output to FILE"}, |
46 { "debug", 'd', "LEVEL", lw_cmdline_opt_optional, "Set debug mode"}, | 46 { "debug", 'd', "LEVEL", lw_cmdline_opt_optional, "Set debug mode"}, |
47 { "format", 'f', "TYPE", 0, "Select output format: decb, raw, obj, os9"}, | 47 { "format", 'f', "TYPE", 0, "Select output format: decb, raw, obj, os9"}, |
48 { "list", 'l', "FILE", lw_cmdline_opt_optional, "Generate list [to FILE]"}, | 48 { "list", 'l', "FILE", lw_cmdline_opt_optional, "Generate list [to FILE]"}, |
49 { "symbols", 's', 0, lw_cmdline_opt_optional, "Generate symbol list in listing, no effect without --list"}, | 49 { "symbols", 's', 0, lw_cmdline_opt_optional, "Generate symbol list in listing, no effect without --list"}, |
50 { "symbols-nolocals", 0x103, 0, lw_cmdline_opt_optional, "Same as --symbols but with local labels ignored"}, | |
51 { "map", 'm', "FILE", lw_cmdline_opt_optional, "Generate map [to FILE]"}, | |
50 { "decb", 'b', 0, 0, "Generate DECB .bin format output, equivalent of --format=decb"}, | 52 { "decb", 'b', 0, 0, "Generate DECB .bin format output, equivalent of --format=decb"}, |
51 { "raw", 'r', 0, 0, "Generate raw binary format output, equivalent of --format=raw"}, | 53 { "raw", 'r', 0, 0, "Generate raw binary format output, equivalent of --format=raw"}, |
52 { "obj", 0x100, 0, 0, "Generate proprietary object file format for later linking, equivalent of --format=obj" }, | 54 { "obj", 0x100, 0, 0, "Generate proprietary object file format for later linking, equivalent of --format=obj" }, |
53 { "depend", 0x101, 0, 0, "Output a dependency list to stdout; do not do any actual output though assembly is completed as usual" }, | 55 { "depend", 0x101, 0, 0, "Output a dependency list to stdout; do not do any actual output though assembly is completed as usual" }, |
54 { "dependnoerr", 0x102, 0, 0, "Output a dependency list to stdout; do not do any actual output though assembly is completed as usual; don't bail on missing include files" }, | 56 { "dependnoerr", 0x102, 0, 0, "Output a dependency list to stdout; do not do any actual output though assembly is completed as usual; don't bail on missing include files" }, |
120 else | 122 else |
121 as -> list_file = lw_strdup(arg); | 123 as -> list_file = lw_strdup(arg); |
122 as -> flags |= FLAG_LIST; | 124 as -> flags |= FLAG_LIST; |
123 break; | 125 break; |
124 | 126 |
127 case 'm': | |
128 if (as -> map_file) | |
129 lw_free(as -> map_file); | |
130 if (!arg) | |
131 as -> map_file = lw_strdup("-"); | |
132 else | |
133 as -> map_file = lw_strdup(arg); | |
134 as -> flags |= FLAG_MAP; | |
135 break; | |
136 | |
125 case 's': | 137 case 's': |
126 as -> flags |= FLAG_SYMBOLS; | 138 as -> flags |= FLAG_SYMBOLS; |
127 break; | 139 break; |
128 | 140 |
141 case 0x103: | |
142 as -> flags |= FLAG_SYMBOLS | FLAG_SYMBOLS_NOLOCALS; | |
143 break; | |
144 | |
129 case 'b': | 145 case 'b': |
130 as -> output_format = OUTPUT_DECB; | 146 as -> output_format = OUTPUT_DECB; |
131 break; | 147 break; |
132 | 148 |
133 case 'r': | 149 case 'r': |
234 extern void do_pass5(asmstate_t *as); | 250 extern void do_pass5(asmstate_t *as); |
235 extern void do_pass6(asmstate_t *as); | 251 extern void do_pass6(asmstate_t *as); |
236 extern void do_pass7(asmstate_t *as); | 252 extern void do_pass7(asmstate_t *as); |
237 extern void do_output(asmstate_t *as); | 253 extern void do_output(asmstate_t *as); |
238 extern void do_list(asmstate_t *as); | 254 extern void do_list(asmstate_t *as); |
255 extern void do_map(asmstate_t *as); | |
239 extern lw_expr_t lwasm_evaluate_special(int t, void *ptr, void *priv); | 256 extern lw_expr_t lwasm_evaluate_special(int t, void *ptr, void *priv); |
240 extern lw_expr_t lwasm_evaluate_var(char *var, void *priv); | 257 extern lw_expr_t lwasm_evaluate_var(char *var, void *priv); |
241 extern lw_expr_t lwasm_parse_term(char **p, void *priv); | 258 extern lw_expr_t lwasm_parse_term(char **p, void *priv); |
242 extern void lwasm_dividezero(void *priv); | 259 extern void lwasm_dividezero(void *priv); |
243 | 260 |
341 { | 358 { |
342 debug_message(&asmstate, 50, "Invoking unicorns"); | 359 debug_message(&asmstate, 50, "Invoking unicorns"); |
343 lwasm_do_unicorns(&asmstate); | 360 lwasm_do_unicorns(&asmstate); |
344 } | 361 } |
345 do_list(&asmstate); | 362 do_list(&asmstate); |
363 do_map(&asmstate); | |
346 exit(0); | 364 exit(0); |
347 } | 365 } |