diff options
| author | Joe Soroka <gits@joesoroka.com> | 2011-03-03 01:58:45 -0800 |
|---|---|---|
| committer | Joe Soroka <gits@joesoroka.com> | 2011-03-03 01:58:45 -0800 |
| commit | c93eca4fe490b0122a9b3a0eb9d280a998bc3054 (patch) | |
| tree | fc6b09b1e4d6ac0ab40273a7e8d5fbe6f54e5553 /tccgen.c | |
| parent | ce8c1886a598618446ee82c829fe8d0509934dda (diff) | |
| download | tinycc-c93eca4fe490b0122a9b3a0eb9d280a998bc3054.tar.gz tinycc-c93eca4fe490b0122a9b3a0eb9d280a998bc3054.tar.bz2 | |
tccgen: handle __attribute((alias("target")))
Diffstat (limited to 'tccgen.c')
| -rw-r--r-- | tccgen.c | 25 |
1 files changed, 24 insertions, 1 deletions
@@ -2472,6 +2472,16 @@ static void parse_attribute(AttributeDef *ad) next(); skip(')'); break; + case TOK_ALIAS1: + case TOK_ALIAS2: + skip('('); + if (tok != TOK_STR) + expect("alias(\"target\")"); + ad->alias_target = /* save string as token, for later */ + tok_alloc((char*)tokc.cstr->data, tokc.cstr->size-1)->tok; + next(); + skip(')'); + break; case TOK_ALIGNED1: case TOK_ALIGNED2: if (tok == '(') { @@ -5578,7 +5588,20 @@ ST_FUNC void decl(int l) /* NOTE: as GCC, uninitialized global static arrays of null size are considered as extern */ - external_sym(v, &type, r, asm_label); + sym = external_sym(v, &type, r, asm_label); + + if (ad.alias_target) { + Section tsec; + Elf32_Sym *esym; + Sym *alias_target; + + alias_target = sym_find(ad.alias_target); + if (!alias_target || !alias_target->c) + error("unsupported forward __alias__ attribute"); + esym = &((Elf32_Sym *)symtab_section->data)[alias_target->c]; + tsec.sh_num = esym->st_shndx; + put_extern_sym2(sym, &tsec, esym->st_value, esym->st_size, 0); + } } else { type.t |= (btype.t & VT_STATIC); /* Retain "static". */ if (type.t & VT_STATIC) |
