That is not available on osx so I tweaked the gas.c api a little to conditionally output the two directives.
Unified · Split
| @@ -523,9 +523,15 @@ void spill(Fn *); · 522 unmodified lines | ||
| 523 | 523 | void rega(Fn *); |
| 524 | 524 | |
| 525 | 525 | /* gas.c */ |
| 526 | +enum Asm { | |
| 527 | + Gasmacho, | |
| 528 | + Gaself, | |
| 529 | +}; | |
| 526 | 530 | extern char *gasloc; |
| 527 | 531 | extern char *gassym; |
| 532 | +void gasinit(enum Asm); | |
| 528 | 533 | void gasemitlnk(char *, Lnk *, char *, FILE *); |
| 534 | +void gasemitfntail(char *, FILE *); | |
| 529 | 535 | void gasemitdat(Dat *, FILE *); |
| 530 | 536 | int gasstash(void *, int); |
| 531 | 537 | void gasemitfin(FILE *); |
| @@ -2,6 +2,23 @@ · 1 unmodified line | ||
| 2 | 2 | |
| 3 | 3 | |
| 4 | 4 | char *gasloc, *gassym; |
| 5 | +static int gasasm; | |
| 6 | + | |
| 7 | +void | |
| 8 | +gasinit(enum Asm asmmode) | |
| 9 | +{ | |
| 10 | + gasasm = asmmode; | |
| 11 | + switch (gasasm) { | |
| 12 | + case Gaself: | |
| 13 | + gasloc = ".L"; | |
| 14 | + gassym = ""; | |
| 15 | + break; | |
| 16 | + case Gasmacho: | |
| 17 | + gasloc = "L"; | |
| 18 | + gassym = "_"; | |
| 19 | + break; | |
| 20 | + } | |
| 21 | +} | |
| 5 | 22 | |
| 6 | 23 | void |
| 7 | 24 | gasemitlnk(char *n, Lnk *l, char *s, FILE *f) |
| @@ -24,6 +41,15 @@ gasemitlnk(char *n, Lnk *l, char *s, FILE *f) · 16 unmodified lines | ||
| 24 | 41 | fprintf(f, "%s%s:\n", p, n); |
| 25 | 42 | } |
| 26 | 43 | |
| 44 | +void | |
| 45 | +gasemitfntail(char *fn, FILE *f) | |
| 46 | +{ | |
| 47 | + if (gasasm == Gaself) { | |
| 48 | + fprintf(f, ".type %s, @function\n", fn); | |
| 49 | + fprintf(f, ".size %s, .-%s\n", fn, fn); | |
| 50 | + } | |
| 51 | +} | |
| 52 | + | |
| 27 | 53 | void |
| 28 | 54 | gasemitdat(Dat *d, FILE *f) |
| 29 | 55 | { |
| @@ -19,11 +19,6 @@ static struct TMap { · 18 unmodified lines | ||
| 19 | 19 | { 0, 0 } |
| 20 | 20 | }; |
| 21 | 21 | |
| 22 | −enum Asm { | |
| 23 | − Gasmacho, | |
| 24 | − Gaself, | |
| 25 | −}; | |
| 26 | − | |
| 27 | 22 | char debug['Z'+1] = { |
| 28 | 23 | ['P'] = 0, /* parsing */ |
| 29 | 24 | ['M'] = 0, /* memory optimization */ |
| @@ -101,6 +96,7 @@ func(Fn *fn) · 71 unmodified lines | ||
| 101 | 96 | fn->rpo[n]->link = fn->rpo[n+1]; |
| 102 | 97 | if (!dbg) { |
| 103 | 98 | T.emitfn(fn, outf); |
| 99 | + gasemitfntail(fn->name, outf); | |
| 104 | 100 | fprintf(outf, "/* end function %s */\n\n", fn->name); |
| 105 | 101 | } else |
| 106 | 102 | fprintf(stderr, "\n"); |
| @@ -174,16 +170,7 @@ main(int ac, char *av[]) · 67 unmodified lines | ||
| 174 | 170 | exit(c != 'h'); |
| 175 | 171 | } |
| 176 | 172 | |
| 177 | − switch (asmmode) { | |
| 178 | − case Gaself: | |
| 179 | − gasloc = ".L"; | |
| 180 | − gassym = ""; | |
| 181 | − break; | |
| 182 | − case Gasmacho: | |
| 183 | − gasloc = "L"; | |
| 184 | − gassym = "_"; | |
| 185 | − break; | |
| 186 | − } | |
| 173 | + gasinit(asmmode); | |
| 187 | 174 | |
| 188 | 175 | do { |
| 189 | 176 | f = av[optind]; |