mirror of
https://github.com/frida/tinycc
synced 2024-11-28 02:29:38 +03:00
tccasm: Don't abuse dllexport/dllimport
For tracking if asm symbols are connected with a C symbol, and if asm symbols need to be global use new flags, instead of reusing dllimport/dllexport, which would cause unrequested exported entries on Windows. This is a stop-gap until the C and asm symtable are unified.
This commit is contained in:
parent
e7c71e2473
commit
4266ebd69c
4
tcc.h
4
tcc.h
@ -440,7 +440,9 @@ struct SymAttr {
|
|||||||
visibility : 2,
|
visibility : 2,
|
||||||
dllexport : 1,
|
dllexport : 1,
|
||||||
dllimport : 1,
|
dllimport : 1,
|
||||||
unused : 5;
|
asmcsym : 1,
|
||||||
|
asmexport : 1,
|
||||||
|
unused : 3;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* function attributes or temporary attributes for parsing */
|
/* function attributes or temporary attributes for parsing */
|
||||||
|
14
tccasm.c
14
tccasm.c
@ -91,8 +91,8 @@ ST_FUNC Sym* get_asm_sym(int name, Sym *csym)
|
|||||||
/* XXX can't yet store st_size anywhere. */
|
/* XXX can't yet store st_size anywhere. */
|
||||||
sym->type.t = VT_VOID | (csym->type.t & VT_STATIC);
|
sym->type.t = VT_VOID | (csym->type.t & VT_STATIC);
|
||||||
/* Mark that this asm symbol doesn't need to be fed back. */
|
/* Mark that this asm symbol doesn't need to be fed back. */
|
||||||
sym->a.dllimport = 1;
|
sym->a.asmcsym = 1;
|
||||||
sym->a.dllexport = !(csym->type.t & VT_STATIC);
|
sym->a.asmexport = !(csym->type.t & VT_STATIC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sym;
|
return sym;
|
||||||
@ -454,11 +454,11 @@ ST_FUNC void asm_free_labels(TCCState *st)
|
|||||||
/* define symbol value in object file and care for updating
|
/* define symbol value in object file and care for updating
|
||||||
the C and asm symbols */
|
the C and asm symbols */
|
||||||
s->type.t &= ~VT_EXTERN;
|
s->type.t &= ~VT_EXTERN;
|
||||||
if (!s->a.dllimport) {
|
if (!s->a.asmcsym) {
|
||||||
Sym *csym = sym_find(s->v);
|
Sym *csym = sym_find(s->v);
|
||||||
ElfW(Sym) *esym = NULL;
|
ElfW(Sym) *esym = NULL;
|
||||||
if (csym) {
|
if (csym) {
|
||||||
s->a.dllexport |= !(csym->type.t & VT_STATIC);
|
s->a.asmexport |= !(csym->type.t & VT_STATIC);
|
||||||
if (csym->c) {
|
if (csym->c) {
|
||||||
esym = &((ElfW(Sym) *)symtab_section->data)[csym->c];
|
esym = &((ElfW(Sym) *)symtab_section->data)[csym->c];
|
||||||
if (s->c) {
|
if (s->c) {
|
||||||
@ -473,7 +473,7 @@ ST_FUNC void asm_free_labels(TCCState *st)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!s->a.dllexport)
|
if (!s->a.asmexport)
|
||||||
s->type.t |= VT_STATIC;
|
s->type.t |= VT_STATIC;
|
||||||
if (s->r) {
|
if (s->r) {
|
||||||
if (s->r == SHN_ABS)
|
if (s->r == SHN_ABS)
|
||||||
@ -485,7 +485,7 @@ ST_FUNC void asm_free_labels(TCCState *st)
|
|||||||
if (!esym || esym->st_shndx == SHN_UNDEF || !was_ext)
|
if (!esym || esym->st_shndx == SHN_UNDEF || !was_ext)
|
||||||
put_extern_sym2(s, sec, s->jnext, 0, 0);
|
put_extern_sym2(s, sec, s->jnext, 0, 0);
|
||||||
} else /* undefined symbols are global */
|
} else /* undefined symbols are global */
|
||||||
s->type.t &= ~VT_STATIC, s->a.dllexport = 1;
|
s->type.t &= ~VT_STATIC, s->a.asmexport = 1;
|
||||||
patch_binding(s);
|
patch_binding(s);
|
||||||
}
|
}
|
||||||
/* remove label */
|
/* remove label */
|
||||||
@ -750,7 +750,7 @@ static void asm_parse_directive(TCCState *s1, int global)
|
|||||||
next();
|
next();
|
||||||
sym = get_asm_sym(tok, NULL);
|
sym = get_asm_sym(tok, NULL);
|
||||||
if (tok1 != TOK_ASMDIR_hidden)
|
if (tok1 != TOK_ASMDIR_hidden)
|
||||||
sym->type.t &= ~VT_STATIC, sym->a.dllexport = 1;
|
sym->type.t &= ~VT_STATIC, sym->a.asmexport = 1;
|
||||||
if (tok1 == TOK_ASMDIR_weak)
|
if (tok1 == TOK_ASMDIR_weak)
|
||||||
sym->a.weak = 1;
|
sym->a.weak = 1;
|
||||||
else if (tok1 == TOK_ASMDIR_hidden)
|
else if (tok1 == TOK_ASMDIR_hidden)
|
||||||
|
Loading…
Reference in New Issue
Block a user