History

output symbol type and size

That is not available on osx so I tweaked the gas.c api a little to conditionally output the two directives.

Quentin Carbonneaux committed 4 years ago

Commit 6ca93991 parent 7a7a5f43 files · +34 −15Browse files

Unified · Split

3 files
  1. all.h +6 −0
  2. gas.c +26 −0
  3. main.c +2 −15
all.h+6−0
@@ -523,9 +523,15 @@ void spill(Fn *); · 522 unmodified lines
523523 void rega(Fn *);
524524
525525 /* gas.c */
526+enum Asm {
527+ Gasmacho,
528+ Gaself,
529+};
526530 extern char *gasloc;
527531 extern char *gassym;
532+void gasinit(enum Asm);
528533 void gasemitlnk(char *, Lnk *, char *, FILE *);
534+void gasemitfntail(char *, FILE *);
529535 void gasemitdat(Dat *, FILE *);
530536 int gasstash(void *, int);
531537 void gasemitfin(FILE *);
gas.c+26−0
@@ -2,6 +2,23 @@ · 1 unmodified line
22
33
44 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+}
522
623 void
724 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
2441 fprintf(f, "%s%s:\n", p, n);
2542 }
2643
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+
2753 void
2854 gasemitdat(Dat *d, FILE *f)
2955 {
main.c+2−15
@@ -19,11 +19,6 @@ static struct TMap { · 18 unmodified lines
1919 { 0, 0 }
2020 };
2121
22−enum Asm {
23− Gasmacho,
24− Gaself,
25−};
26−
2722 char debug['Z'+1] = {
2823 ['P'] = 0, /* parsing */
2924 ['M'] = 0, /* memory optimization */
@@ -101,6 +96,7 @@ func(Fn *fn) · 71 unmodified lines
10196 fn->rpo[n]->link = fn->rpo[n+1];
10297 if (!dbg) {
10398 T.emitfn(fn, outf);
99+ gasemitfntail(fn->name, outf);
104100 fprintf(outf, "/* end function %s */\n\n", fn->name);
105101 } else
106102 fprintf(stderr, "\n");
@@ -174,16 +170,7 @@ main(int ac, char *av[]) · 67 unmodified lines
174170 exit(c != 'h');
175171 }
176172
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);
187174
188175 do {
189176 f = av[optind];

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t