History

tccasm: support alternate .type syntaxes

Joe Soroka committed 15 years ago

Commit bec84fa1 parent 15b8a572 files · +23 −8Browse files

Unified · Split

2 files
  1. tccasm.c +9 −8
  2. tests/asmtest.S +14 −0
tccasm.c+9−8
@@ -601,8 +601,7 @@ static void asm_parse_directive(TCCState *s1) · 600 unmodified lines
601601 case TOK_ASM_type:
602602 {
603603 Sym *sym;
604− char newtype[64];
605− newtype[0] = 0;
604+ const char *newtype;
606605
607606 next();
608607 sym = label_find(tok);
@@ -613,13 +612,15 @@ static void asm_parse_directive(TCCState *s1) · 4 unmodified lines
613612
614613 next();
615614 skip(',');
616− skip('@');
617− if (tok == TOK_STR)
618− pstrcat(newtype, sizeof(newtype), tokc.cstr->data);
619− else
620− pstrcat(newtype, sizeof(newtype), get_tok_str(tok, NULL));
615+ if (tok == TOK_STR) {
616+ newtype = tokc.cstr->data;
617+ } else {
618+ if (tok == '@' || tok == '%')
619+ skip(tok);
620+ newtype = get_tok_str(tok, NULL);
621+ }
621622
622− if (!strcmp(newtype, "function")) {
623+ if (!strcmp(newtype, "function") || !strcmp(newtype, "STT_FUNC")) {
623624 sym->type.t = VT_FUNC;
624625 }
625626 else if (s1->warn_unsupported)
tests/asmtest.S+14−0
@@ -592,3 +592,17 @@ int $0x10 · 591 unmodified lines
592592 #ifdef __ASSEMBLER__ // should be defined, for S files
593593 inc %eax
594594 #endif
595+
596+ft1: ft2: ft3: ft4: ft5: ft6: ft7: ft8: ft9:
597+ xor %eax, %eax
598+ ret
599+
600+.type ft1,STT_FUNC
601+.type ft2,@STT_FUNC
602+.type ft3,%STT_FUNC
603+.type ft4,"STT_FUNC"
604+.type ft5,function
605+.type ft6,@function
606+.type ft7,%function
607+.type ft8,"function"
608+