diff options
| author | grischka <grischka> | 2009-12-19 19:14:01 +0100 |
|---|---|---|
| committer | grischka <grischka> | 2009-12-19 22:16:18 +0100 |
| commit | 1445fea5827a948996e1c7bea24df4c0df79f432 (patch) | |
| tree | 11c5e6192d922d8329b9a8349cb7ad67e337669b | |
| parent | b5e22384836d5c09602d5cf6fe990485299dfbf0 (diff) | |
| download | tinycc-1445fea5827a948996e1c7bea24df4c0df79f432.tar.gz tinycc-1445fea5827a948996e1c7bea24df4c0df79f432.tar.bz2 | |
tccpe: allow linkage to extern symbols from asm
| -rw-r--r-- | libtcc.c | 1 | ||||
| -rw-r--r-- | tccpe.c | 23 |
2 files changed, 24 insertions, 0 deletions
@@ -1074,6 +1074,7 @@ static Sym *sym_push2(Sym **ps, int v, int t, long c) s = sym_malloc(); s->v = v; s->type.t = t; + s->type.ref = NULL; #ifdef _WIN64 s->d = NULL; #endif @@ -1185,6 +1185,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) { ElfW(Sym) *sym; @@ -1210,6 +1225,14 @@ ST_FN int pe_check_symbols(struct pe_info *pe) if (!is) 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) { unsigned long offset = is->thk_offset; if (offset) { |
