History

tccgen: handle __attribute((alias("target")))

Joe Soroka committed 15 years ago

Commit c93eca41 parent ce8c1883 files · +27 −1Browse files

Unified · Split

3 files
  1. tcc.h +1 −0
  2. tccgen.c +24 −1
  3. tcctok.h +2 −0
tcc.h+1−0
@@ -285,6 +285,7 @@ typedef struct AttributeDef { · 284 unmodified lines
285 resize : 1,285 resize : 1,
286 fill : 10;286 fill : 10;
287 struct Section *section;287 struct Section *section;
288 int alias_target; /* token */
288} AttributeDef;289} AttributeDef;
289 290
290/* gr: wrappers for casting sym->r for other purposes */291/* gr: wrappers for casting sym->r for other purposes */
tccgen.c+24−1
@@ -2472,6 +2472,16 @@ static void parse_attribute(AttributeDef *ad) · 2471 unmodified lines
2472 next();2472 next();
2473 skip(')');2473 skip(')');
2474 break;2474 break;
2475 case TOK_ALIAS1:
2476 case TOK_ALIAS2:
2477 skip('(');
2478 if (tok != TOK_STR)
2479 expect("alias(\"target\")");
2480 ad->alias_target = /* save string as token, for later */
2481 tok_alloc((char*)tokc.cstr->data, tokc.cstr->size-1)->tok;
2482 next();
2483 skip(')');
2484 break;
2475 case TOK_ALIGNED1:2485 case TOK_ALIGNED1:
2476 case TOK_ALIGNED2:2486 case TOK_ALIGNED2:
2477 if (tok == '(') {2487 if (tok == '(') {
@@ -5578,7 +5588,20 @@ ST_FUNC void decl(int l) · 3100 unmodified lines
5578 /* NOTE: as GCC, uninitialized global static5588 /* NOTE: as GCC, uninitialized global static
5579 arrays of null size are considered as5589 arrays of null size are considered as
5580 extern */5590 extern */
5581 external_sym(v, &type, r, asm_label);5591 sym = external_sym(v, &type, r, asm_label);
5592
5593 if (ad.alias_target) {
5594 Section tsec;
5595 Elf32_Sym *esym;
5596 Sym *alias_target;
5597
5598 alias_target = sym_find(ad.alias_target);
5599 if (!alias_target || !alias_target->c)
5600 error("unsupported forward __alias__ attribute");
5601 esym = &((Elf32_Sym *)symtab_section->data)[alias_target->c];
5602 tsec.sh_num = esym->st_shndx;
5603 put_extern_sym2(sym, &tsec, esym->st_value, esym->st_size, 0);
5604 }
5582 } else {5605 } else {
5583 type.t |= (btype.t & VT_STATIC); /* Retain "static". */5606 type.t |= (btype.t & VT_STATIC); /* Retain "static". */
5584 if (type.t & VT_STATIC)5607 if (type.t & VT_STATIC)
tcctok.h+2−0
@@ -100,6 +100,8 @@ · 99 unmodified lines
100 DEF(TOK_PACKED2, "__packed__")100 DEF(TOK_PACKED2, "__packed__")
101 DEF(TOK_WEAK1, "weak")101 DEF(TOK_WEAK1, "weak")
102 DEF(TOK_WEAK2, "__weak__")102 DEF(TOK_WEAK2, "__weak__")
103 DEF(TOK_ALIAS1, "alias")
104 DEF(TOK_ALIAS2, "__alias__")
103 DEF(TOK_UNUSED1, "unused")105 DEF(TOK_UNUSED1, "unused")
104 DEF(TOK_UNUSED2, "__unused__")106 DEF(TOK_UNUSED2, "__unused__")
105 DEF(TOK_CDECL1, "cdecl")107 DEF(TOK_CDECL1, "cdecl")

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