mirror of
https://github.com/frida/tinycc
synced 2024-12-25 14:36:49 +03:00
tccpe: allow linkage to extern symbols from asm
This commit is contained in:
parent
b5e2238483
commit
1445fea582
1
libtcc.c
1
libtcc.c
@ -1074,6 +1074,7 @@ static Sym *sym_push2(Sym **ps, int v, int t, long c)
|
|||||||
s = sym_malloc();
|
s = sym_malloc();
|
||||||
s->v = v;
|
s->v = v;
|
||||||
s->type.t = t;
|
s->type.t = t;
|
||||||
|
s->type.ref = NULL;
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
s->d = NULL;
|
s->d = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
23
tccpe.c
23
tccpe.c
@ -1184,6 +1184,21 @@ ST_FN void pe_relocate_rva (struct pe_info *pe, Section *s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
static int pe_isafunc(int sym_index)
|
||||||
|
{
|
||||||
|
Section *sr = text_section->reloc;
|
||||||
|
ElfW_Rel *rel, *rel_end;
|
||||||
|
Elf32_Word info = ELF32_R_INFO(sym_index, R_386_PC32);
|
||||||
|
if (!sr)
|
||||||
|
return 0;
|
||||||
|
rel_end = (ElfW_Rel *)(sr->data + sr->data_offset);
|
||||||
|
for (rel = (ElfW_Rel *)sr->data; rel < rel_end; rel++)
|
||||||
|
if (rel->r_info == info)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
ST_FN int pe_check_symbols(struct pe_info *pe)
|
ST_FN int pe_check_symbols(struct pe_info *pe)
|
||||||
{
|
{
|
||||||
@ -1210,6 +1225,14 @@ ST_FN int pe_check_symbols(struct pe_info *pe)
|
|||||||
if (!is)
|
if (!is)
|
||||||
goto not_found;
|
goto not_found;
|
||||||
|
|
||||||
|
if (type == STT_NOTYPE) {
|
||||||
|
/* symbols from assembler have no type, find out which */
|
||||||
|
if (pe_isafunc(sym_index))
|
||||||
|
type = STT_FUNC;
|
||||||
|
else
|
||||||
|
type = STT_OBJECT;
|
||||||
|
}
|
||||||
|
|
||||||
if (type == STT_FUNC) {
|
if (type == STT_FUNC) {
|
||||||
unsigned long offset = is->thk_offset;
|
unsigned long offset = is->thk_offset;
|
||||||
if (offset) {
|
if (offset) {
|
||||||
|
Loading…
Reference in New Issue
Block a user