From 1445fea5827a948996e1c7bea24df4c0df79f432 Mon Sep 17 00:00:00 2001 From: grischka Date: Sat, 19 Dec 2009 19:14:01 +0100 Subject: tccpe: allow linkage to extern symbols from asm --- tccpe.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tccpe.c') diff --git a/tccpe.c b/tccpe.c index 9b6c524..41de3f6 100644 --- a/tccpe.c +++ b/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) { @@ -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) { -- cgit v1.3.1