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
601 case TOK_ASM_type:601 case TOK_ASM_type:
602 { 602 {
603 Sym *sym;603 Sym *sym;
604 char newtype[64];604 const char *newtype;
605 newtype[0] = 0;
606 605
607 next();606 next();
608 sym = label_find(tok);607 sym = label_find(tok);
@@ -613,13 +612,15 @@ static void asm_parse_directive(TCCState *s1) · 4 unmodified lines
613 612
614 next();613 next();
615 skip(',');614 skip(',');
616 skip('@');615 if (tok == TOK_STR) {
617 if (tok == TOK_STR)616 newtype = tokc.cstr->data;
618 pstrcat(newtype, sizeof(newtype), tokc.cstr->data);617 } else {
619 else618 if (tok == '@' || tok == '%')
620 pstrcat(newtype, sizeof(newtype), get_tok_str(tok, NULL));619 skip(tok);
620 newtype = get_tok_str(tok, NULL);
621 }
621 622
622 if (!strcmp(newtype, "function")) {623 if (!strcmp(newtype, "function") || !strcmp(newtype, "STT_FUNC")) {
623 sym->type.t = VT_FUNC;624 sym->type.t = VT_FUNC;
624 }625 }
625 else if (s1->warn_unsupported)626 else if (s1->warn_unsupported)
tests/asmtest.S+14−0
@@ -592,3 +592,17 @@ int $0x10 · 591 unmodified lines
592#ifdef __ASSEMBLER__ // should be defined, for S files592#ifdef __ASSEMBLER__ // should be defined, for S files
593 inc %eax593 inc %eax
594#endif594#endif
595
596ft1: 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