History

win64: fix pe_isafunc()

- tccpe.c: commit "tidy support for helper function" created STT_NOTYPE symbols and hence relied on ad-hoc detection which didn't work for x86_64 (as reported by Christian Jullien) - tccgen.c: However to be more safe the helper symbols are now made STT_FUNC anyway (via new VT_ASM_FUNC).

grischka committed 5 years ago

Commit cf8d9cf1 parent 13a18909 files · +66 −49Browse files

Unified · Split

9 files
  1. Makefile +1 −1
  2. arm64-gen.c +2 −2
  3. arm64-link.c +3 −3
  4. riscv64-gen.c +2 −2
  5. riscv64-link.c +9 −9
  6. tcc.h +23 −20
  7. tccgen.c +4 −2
  8. tccmacho.c +8 −8
  9. tccpe.c +14 −2
Makefile+1−1
@@ -138,7 +138,7 @@ DEF-i386-win32 = -DTCC_TARGET_PE -DTCC_TARGET_I386 · 137 unmodified lines
138138 DEF-x86_64-win32= -DTCC_TARGET_PE -DTCC_TARGET_X86_64
139139 DEF-x86_64-osx = -DTCC_TARGET_MACHO -DTCC_TARGET_X86_64
140140 DEF-arm-wince = -DTCC_TARGET_PE -DTCC_TARGET_ARM -DTCC_ARM_EABI -DTCC_ARM_VFP -DTCC_ARM_HARDFLOAT
141−DEF-arm64 = -DTCC_TARGET_ARM64 -Wno-format
141+DEF-arm64 = -DTCC_TARGET_ARM64
142142 DEF-c67 = -DTCC_TARGET_C67 -w # disable warnigs
143143 DEF-arm-fpa = -DTCC_TARGET_ARM
144144 DEF-arm-fpa-ld = -DTCC_TARGET_ARM -DLDOUBLE_SIZE=12
arm64-gen.c+2−2
@@ -587,7 +587,7 @@ ST_FUNC void load(int r, SValue *sv) · 586 unmodified lines
587587 return;
588588 }
589589
590− printf("load(%x, (%x, %x, %llx))\n", r, svtt, sv->r, (long long)svcul);
590+ printf("load(%x, (%x, %x, %lx))\n", r, svtt, sv->r, (long)svcul);
591591 assert(0);
592592 }
593593
@@ -639,7 +639,7 @@ ST_FUNC void store(int r, SValue *sv) · 45 unmodified lines
639639 return;
640640 }
641641
642− printf("store(%x, (%x, %x, %llx))\n", r, svtt, sv->r, (long long)svcul);
642+ printf("store(%x, (%x, %x, %lx))\n", r, svtt, sv->r, (long)svcul);
643643 assert(0);
644644 }
645645
arm64-link.c+3−3
@@ -116,7 +116,7 @@ ST_FUNC void relocate_plt(TCCState *s1) · 115 unmodified lines
116116 uint64_t got = s1->got->sh_addr;
117117 uint64_t off = (got >> 12) - (plt >> 12);
118118 if ((off + ((uint32_t)1 << 20)) >> 21)
119− tcc_error("Failed relocating PLT (off=0x%lx, got=0x%lx, plt=0x%lx)", off, got, plt);
119+ tcc_error("Failed relocating PLT (off=0x%lx, got=0x%lx, plt=0x%lx)", (long)off, (long)got, (long)plt);
120120 write32le(p, 0xa9bf7bf0); // stp x16,x30,[sp,#-16]!
121121 write32le(p + 4, (0x90000010 | // adrp x16,...
122122 (off & 0x1ffffc) << 3 | (off & 3) << 29));
@@ -134,7 +134,7 @@ ST_FUNC void relocate_plt(TCCState *s1) · 11 unmodified lines
134134 uint64_t addr = got + read64le(p);
135135 uint64_t off = (addr >> 12) - (pc >> 12);
136136 if ((off + ((uint32_t)1 << 20)) >> 21)
137− tcc_error("Failed relocating PLT (off=0x%lx, addr=0x%lx, pc=0x%lx)", off, addr, pc);
137+ tcc_error("Failed relocating PLT (off=0x%lx, addr=0x%lx, pc=0x%lx)", (long)off, (long)addr, (long)pc);
138138 write32le(p, (0x90000010 | // adrp x16,...
139139 (off & 0x1ffffc) << 3 | (off & 3) << 29));
140140 write32le(p + 4, (0xf9400211 | // ldr x17,[x16,#...]
@@ -239,7 +239,7 @@ void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t · 98 unmodified lines
239239 #endif
240240 if (((val - addr) + ((uint64_t)1 << 27)) & ~(uint64_t)0xffffffc)
241241 tcc_error("R_AARCH64_(JUMP|CALL)26 relocation failed"
242− " (val=%lx, addr=%lx)", val, addr);
242+ " (val=%lx, addr=%lx)", (long)val, (long)addr);
243243 write32le(ptr, (0x14000000 |
244244 (uint32_t)(type == R_AARCH64_CALL26) << 31 |
245245 ((val - addr) >> 2 & 0x3ffffff)));
riscv64-gen.c+2−2
@@ -166,7 +166,7 @@ static int load_symofs(int r, SValue *sv, int forstore) · 165 unmodified lines
166166 sv->c.i = 0;
167167 } else {
168168 if (((unsigned)fc + (1 << 11)) >> 12)
169− tcc_error("unimp: large addend for global address (0x%llx)", (long long)sv->c.i);
169+ tcc_error("unimp: large addend for global address (0x%lx)", (long)sv->c.i);
170170 greloca(cur_text_section, sv->sym, ind,
171171 R_RISCV_GOT_HI20, 0);
172172 doload = 1;
@@ -188,7 +188,7 @@ static int load_symofs(int r, SValue *sv, int forstore) · 15 unmodified lines
188188 } else if (v == VT_LOCAL || v == VT_LLOCAL) {
189189 rr = 8; // s0
190190 if (fc != sv->c.i)
191− tcc_error("unimp: store(giant local off) (0x%llx)", (long long)sv->c.i);
191+ tcc_error("unimp: store(giant local off) (0x%lx)", (long)sv->c.i);
192192 if (((unsigned)fc + (1 << 11)) >> 12) {
193193 rr = is_ireg(r) ? ireg(r) : 5; // t0
194194 o(0x37 | (rr << 7) | ((0x800 + fc) & 0xfffff000)); //lui RR, upper(fc)
riscv64-link.c+9−9
@@ -127,7 +127,7 @@ ST_FUNC void relocate_plt(TCCState *s1) · 126 unmodified lines
127127 uint64_t got = s1->got->sh_addr;
128128 uint64_t off = (got - plt + 0x800) >> 12;
129129 if ((off + ((uint32_t)1 << 20)) >> 21)
130− tcc_error("Failed relocating PLT (off=0x%lx, got=0x%lx, plt=0x%lx)", off, got, plt);
130+ tcc_error("Failed relocating PLT (off=0x%lx, got=0x%lx, plt=0x%lx)", (long)off, (long)got, (long)plt);
131131 write32le(p, 0x397 | (off << 12)); // auipc t2, %pcrel_hi(got)
132132 write32le(p + 4, 0x41c30333); // sub t1, t1, t3
133133 write32le(p + 8, 0x0003be03 // ld t3, %pcrel_lo(got)(t2)
@@ -144,7 +144,7 @@ ST_FUNC void relocate_plt(TCCState *s1) · 10 unmodified lines
144144 uint64_t addr = got + read64le(p);
145145 uint64_t off = (addr - pc + 0x800) >> 12;
146146 if ((off + ((uint32_t)1 << 20)) >> 21)
147− tcc_error("Failed relocating PLT (off=0x%lx, addr=0x%lx, pc=0x%lx)", off, addr, pc);
147+ tcc_error("Failed relocating PLT (off=0x%lx, addr=0x%lx, pc=0x%lx)", (long)off, (long)addr, (long)pc);
148148 write32le(p, 0xe17 | (off << 12)); // auipc t3, %pcrel_hi(func@got)
149149 write32le(p + 4, 0x000e3e03 // ld t3, %pcrel_lo(func@got)(t3)
150150 | (((addr - pc) & 0xfff) << 20));
@@ -177,7 +177,7 @@ void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, · 26 unmodified lines
177177 off64 = val - addr;
178178 if ((off64 + (1 << 12)) & ~(uint64_t)0x1ffe)
179179 tcc_error("R_RISCV_BRANCH relocation failed"
180− " (val=%lx, addr=%lx)", val, addr);
180+ " (val=%lx, addr=%lx)", (long)val, (long)addr);
181181 off32 = off64 >> 1;
182182 write32le(ptr, (read32le(ptr) & ~0xfe000f80)
183183 | ((off32 & 0x800) << 20)
@@ -189,7 +189,7 @@ void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, · 5 unmodified lines
189189 off64 = val - addr;
190190 if ((off64 + (1 << 21)) & ~(((uint64_t)1 << 22) - 2))
191191 tcc_error("R_RISCV_JAL relocation failed"
192− " (val=%lx, addr=%lx)", val, addr);
192+ " (val=%lx, addr=%lx)", (long)val, (long)addr);
193193 off32 = off64;
194194 write32le(ptr, (read32le(ptr) & 0xfff)
195195 | (((off32 >> 12) & 0xff) << 12)
@@ -206,12 +206,12 @@ void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, · 10 unmodified lines
206206 return;
207207 case R_RISCV_PCREL_HI20:
208208 #ifdef DEBUG_RELOC
209− printf("PCREL_HI20: val=%lx addr=%lx\n", val, addr);
209+ printf("PCREL_HI20: val=%lx addr=%lx\n", (long)val, (long)addr);
210210 #endif
211211 off64 = (int64_t)(val - addr + 0x800) >> 12;
212212 if ((off64 + ((uint64_t)1 << 20)) >> 21)
213213 tcc_error("R_RISCV_PCREL_HI20 relocation failed: off=%lx cond=%lx sym=%s",
214− off64, ((int64_t)(off64 + ((uint64_t)1 << 20)) >> 21),
214+ (long)off64, (long)((int64_t)(off64 + ((uint64_t)1 << 20)) >> 21),
215215 symtab_section->link->data + sym->st_name);
216216 write32le(ptr, (read32le(ptr) & 0xfff)
217217 | ((off64 & 0xfffff) << 12));
@@ -230,7 +230,7 @@ void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, · 12 unmodified lines
230230 return;
231231 case R_RISCV_PCREL_LO12_I:
232232 #ifdef DEBUG_RELOC
233− printf("PCREL_LO12_I: val=%lx addr=%lx\n", val, addr);
233+ printf("PCREL_LO12_I: val=%lx addr=%lx\n", (long)val, (long)addr);
234234 #endif
235235 if (val != last_hi.addr)
236236 tcc_error("unsupported hi/lo pcrel reloc scheme");
@@ -254,7 +254,7 @@ void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, · 17 unmodified lines
254254 off64 = (val - addr);
255255 if ((off64 + (1 << 8)) & ~(uint64_t)0x1fe)
256256 tcc_error("R_RISCV_RVC_BRANCH relocation failed"
257− " (val=%lx, addr=%lx)", val, addr);
257+ " (val=%lx, addr=%lx)", (long)val, (long)addr);
258258 off32 = off64;
259259 write16le(ptr, (read16le(ptr) & 0xe383)
260260 | (((off32 >> 5) & 1) << 2)
@@ -267,7 +267,7 @@ void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, · 6 unmodified lines
267267 off64 = (val - addr);
268268 if ((off64 + (1 << 11)) & ~(uint64_t)0xffe)
269269 tcc_error("R_RISCV_RVC_BRANCH relocation failed"
270− " (val=%lx, addr=%lx)", val, addr);
270+ " (val=%lx, addr=%lx)", (long)val, (long)addr);
271271 off32 = off64;
272272 write16le(ptr, (read16le(ptr) & 0xe003)
273273 | (((off32 >> 5) & 1) << 2)
tcc.h+23−20
@@ -1011,7 +1011,8 @@ struct filespec { · 1010 unmodified lines
10111011 #define VT_TYPE (~(VT_STORAGE|VT_STRUCT_MASK))
10121012
10131013 /* symbol was created by tccasm.c first */
1014−#define VT_ASM (VT_VOID | VT_UNSIGNED)
1014+#define VT_ASM (VT_VOID | 1 << VT_STRUCT_SHIFT)
1015+#define VT_ASM_FUNC (VT_ASM | 2 << VT_STRUCT_SHIFT)
10151016 #define IS_ASM_SYM(sym) (((sym)->type.t & (VT_BTYPE | VT_ASM)) == VT_ASM)
10161017
10171018 /* general: set/get the pseudo-bitfield value for bit-mask M */
@@ -1251,15 +1252,6 @@ ST_FUNC void cstr_free(CString *cstr); · 233 unmodified lines
12511252 ST_FUNC int cstr_printf(CString *cs, const char *fmt, ...) PRINTF_LIKE(2,3);
12521253 ST_FUNC void cstr_reset(CString *cstr);
12531254
1254−ST_INLN void sym_free(Sym *sym);
1255−ST_FUNC Sym *sym_push2(Sym **ps, int v, int t, int c);
1256−ST_FUNC Sym *sym_find2(Sym *s, int v);
1257−ST_FUNC Sym *sym_push(int v, CType *type, int r, int c);
1258−ST_FUNC void sym_pop(Sym **ptop, Sym *b, int keep);
1259−ST_INLN Sym *struct_find(int v);
1260−ST_INLN Sym *sym_find(int v);
1261−ST_FUNC Sym *global_identifier_push(int v, int t, int c);
1262−
12631255 ST_FUNC void tcc_open_bf(TCCState *s1, const char *filename, int initlen);
12641256 ST_FUNC int tcc_open(TCCState *s1, const char *filename);
12651257 ST_FUNC void tcc_close(void);
@@ -1433,25 +1425,44 @@ ST_INLN int is_float(int t); · 167 unmodified lines
14331425 ST_FUNC int ieee_finite(double d);
14341426 ST_FUNC int exact_log2p1(int i);
14351427 ST_FUNC void test_lvalue(void);
1436−ST_FUNC void vpushi(int v);
1428+
14371429 ST_FUNC ElfSym *elfsym(Sym *);
14381430 ST_FUNC void update_storage(Sym *sym);
1431+ST_FUNC void put_extern_sym2(Sym *sym, int sh_num, addr_t value, unsigned long size, int can_add_underscore);
1432+ST_FUNC void put_extern_sym(Sym *sym, Section *section, addr_t value, unsigned long size);
1433+#if PTR_SIZE == 4
1434+ST_FUNC void greloc(Section *s, Sym *sym, unsigned long offset, int type);
1435+#endif
1436+ST_FUNC void greloca(Section *s, Sym *sym, unsigned long offset, int type, addr_t addend);
1437+
1438+ST_INLN void sym_free(Sym *sym);
1439+ST_FUNC Sym *sym_push(int v, CType *type, int r, int c);
1440+ST_FUNC void sym_pop(Sym **ptop, Sym *b, int keep);
1441+ST_FUNC Sym *sym_push2(Sym **ps, int v, int t, int c);
1442+ST_FUNC Sym *sym_find2(Sym *s, int v);
1443+ST_INLN Sym *sym_find(int v);
1444+ST_INLN Sym *struct_find(int v);
1445+
1446+ST_FUNC Sym *global_identifier_push(int v, int t, int c);
14391447 ST_FUNC Sym *external_global_sym(int v, CType *type);
14401448 ST_FUNC Sym *external_helper_sym(int v);
14411449 ST_FUNC void vpush_helper_func(int v);
14421450 ST_FUNC void vset(CType *type, int r, int v);
14431451 ST_FUNC void vset_VT_CMP(int op);
1452+ST_FUNC void vpushi(int v);
1453+ST_FUNC void vpushv(SValue *v);
1454+ST_FUNC void vpushsym(CType *type, Sym *sym);
14441455 ST_FUNC void vswap(void);
14451456 ST_FUNC void vrote(SValue *e, int n);
14461457 ST_FUNC void vrott(int n);
14471458 ST_FUNC void vrotb(int n);
1459+ST_FUNC void vpop(void);
14481460 #if PTR_SIZE == 4
14491461 ST_FUNC void lexpand(void);
14501462 #endif
14511463 #ifdef TCC_TARGET_ARM
14521464 ST_FUNC int get_reg_ex(int rc, int rc2);
14531465 #endif
1454−ST_FUNC void vpushv(SValue *v);
14551466 ST_FUNC void save_reg(int r);
14561467 ST_FUNC void save_reg_upstack(int r, int n);
14571468 ST_FUNC int get_reg(int rc);
@@ -1459,7 +1470,6 @@ ST_FUNC void save_regs(int n); · 1 unmodified line
14591470 ST_FUNC void gaddrof(void);
14601471 ST_FUNC int gv(int rc);
14611472 ST_FUNC void gv2(int rc1, int rc2);
1462−ST_FUNC void vpop(void);
14631473 ST_FUNC void gen_op(int op);
14641474 ST_FUNC int type_size(CType *type, int *a);
14651475 ST_FUNC void mk_pointer(CType *type);
@@ -1513,13 +1523,6 @@ ST_FUNC void *section_ptr_add(Section *sec, addr_t size); · 47 unmodified lines
15131523 ST_FUNC Section *find_section(TCCState *s1, const char *name);
15141524 ST_FUNC Section *new_symtab(TCCState *s1, const char *symtab_name, int sh_type, int sh_flags, const char *strtab_name, const char *hash_name, int hash_sh_flags);
15151525
1516−ST_FUNC void put_extern_sym2(Sym *sym, int sh_num, addr_t value, unsigned long size, int can_add_underscore);
1517−ST_FUNC void put_extern_sym(Sym *sym, Section *section, addr_t value, unsigned long size);
1518−#if PTR_SIZE == 4
1519−ST_FUNC void greloc(Section *s, Sym *sym, unsigned long offset, int type);
1520−#endif
1521−ST_FUNC void greloca(Section *s, Sym *sym, unsigned long offset, int type, addr_t addend);
1522−
15231526 ST_FUNC int put_elf_str(Section *s, const char *sym);
15241527 ST_FUNC int put_elf_sym(Section *s, addr_t value, unsigned long size, int info, int other, int shndx, const char *name);
15251528 ST_FUNC int set_elf_sym(Section *s, addr_t value, unsigned long size, int info, int other, int shndx, const char *name);
tccgen.c+4−2
@@ -921,6 +921,8 @@ ST_FUNC void put_extern_sym2(Sym *sym, int sh_num, · 920 unmodified lines
921921 sym_type = STT_FUNC;
922922 } else if ((t & VT_BTYPE) == VT_VOID) {
923923 sym_type = STT_NOTYPE;
924+ if ((t & (VT_BTYPE|VT_ASM_FUNC)) == VT_ASM_FUNC)
925+ sym_type = STT_FUNC;
924926 } else {
925927 sym_type = STT_OBJECT;
926928 }
@@ -1440,7 +1442,7 @@ static void gen_test_zero(int op) · 513 unmodified lines
14401442
14411443 /* ------------------------------------------------------------------------- */
14421444 /* push a symbol value of TYPE */
1443−static inline void vpushsym(CType *type, Sym *sym)
1445+ST_FUNC void vpushsym(CType *type, Sym *sym)
14441446 {
14451447 CValue cval;
14461448 cval.i = 0;
@@ -1489,7 +1491,7 @@ ST_FUNC Sym *external_global_sym(int v, CType *type) · 42 unmodified lines
14891491 This avoids type conflicts if the symbol is used from C too */
14901492 ST_FUNC Sym *external_helper_sym(int v)
14911493 {
1492− CType ct = { VT_ASM, NULL };
1494+ CType ct = { VT_ASM_FUNC, NULL };
14931495 return external_global_sym(v, &ct);
14941496 }
14951497
tccmacho.c+8−8
@@ -384,8 +384,8 @@ static int check_symbols(TCCState *s1, struct macho *mo) · 383 unmodified lines
384384 unsigned bind = ELFW(ST_BIND)(sym->st_info);
385385 unsigned vis = ELFW(ST_VISIBILITY)(sym->st_other);
386386
387− dprintf("%4d (%4d): %09llx %4d %4d %4d %3d %s\n",
388− sym_index, elf_index, sym->st_value,
387+ dprintf("%4d (%4d): %09lx %4d %4d %4d %3d %s\n",
388+ sym_index, elf_index, (long)sym->st_value,
389389 type, bind, vis, sym->st_shndx, name);
390390 if (bind == STB_LOCAL) {
391391 if (mo->ilocal == -1)
@@ -680,14 +680,14 @@ static void collect_sections(TCCState *s1, struct macho *mo) · 288 unmodified lines
680680 for (s = mo->sk_to_sect[sk].s; s; s = s->prev) {
681681 al = s->sh_addralign;
682682 curaddr = (curaddr + al - 1) & -al;
683− dprintf("curaddr now 0x%llx\n", curaddr);
683+ dprintf("curaddr now 0x%lx\n", (long)curaddr);
684684 s->sh_addr = curaddr;
685685 curaddr += s->sh_size;
686686 if (s->sh_type != SHT_NOBITS) {
687687 fileofs = (fileofs + al - 1) & -al;
688688 s->sh_offset = fileofs;
689689 fileofs += s->sh_size;
690− dprintf("fileofs now %lld\n", fileofs);
690+ dprintf("fileofs now %ld\n", (long)fileofs);
691691 }
692692 if (sec)
693693 mo->elfsectomacho[s->sh_num] = numsec;
@@ -699,7 +699,7 @@ static void collect_sections(TCCState *s1, struct macho *mo) · 5 unmodified lines
699699 for (s = mo->sk_to_sect[sk].s; s; s = s->prev) {
700700 int type = s->sh_type;
701701 int flags = s->sh_flags;
702− printf("%d section %-16s %-10s %09llx %04x %02d %s,%s,%s\n",
702+ printf("%d section %-16s %-10s %09lx %04x %02d %s,%s,%s\n",
703703 sk,
704704 s->name,
705705 type == SHT_PROGBITS ? "progbits" :
@@ -709,7 +709,7 @@ static void collect_sections(TCCState *s1, struct macho *mo) · 3 unmodified lines
709709 type == SHT_INIT_ARRAY ? "init" :
710710 type == SHT_FINI_ARRAY ? "fini" :
711711 type == SHT_RELX ? "rel" : "???",
712− s->sh_addr,
712+ (long)s->sh_addr,
713713 (unsigned)s->data_offset,
714714 s->sh_addralign,
715715 flags & SHF_ALLOC ? "alloc" : "",
@@ -966,8 +966,8 @@ ST_FUNC int macho_load_dll(TCCState *s1, int fd, const char *filename, int lev) · 250 unmodified lines
966966 //for (i = 0; i < nsyms; i++) {
967967 for (i = iextdef; i < iextdef + nextdef; i++) {
968968 struct nlist_64 *sym = symtab + i;
969− dprintf("%5d: %3d %3d 0x%04x 0x%016llx %s\n",
970− i, sym->n_type, sym->n_sect, sym->n_desc, sym->n_value,
969+ dprintf("%5d: %3d %3d 0x%04x 0x%016lx %s\n",
970+ i, sym->n_type, sym->n_sect, sym->n_desc, (long)sym->n_value,
971971 strtab + sym->n_strx);
972972 set_elf_sym(s1->dynsymtab_section, 0, 0,
973973 ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE),
tccpe.c+14−2
@@ -35,6 +35,7 @@ · 34 unmodified lines
3535 # define REL_TYPE_DIRECT R_X86_64_64
3636 # define R_XXX_THUNKFIX R_X86_64_PC32
3737 # define R_XXX_RELATIVE R_X86_64_RELATIVE
38+# define R_XXX_FUNCCALL R_X86_64_PC32
3839 # define IMAGE_FILE_MACHINE 0x8664
3940 # define RSRC_RELTYPE 3
4041
@@ -44,6 +45,8 @@ · 3 unmodified lines
4445 # define REL_TYPE_DIRECT R_ARM_ABS32
4546 # define R_XXX_THUNKFIX R_ARM_ABS32
4647 # define R_XXX_RELATIVE R_ARM_RELATIVE
48+# define R_XXX_FUNCCALL R_ARM_PC24
49+# define R_XXX_FUNCCALL2 R_ARM_ABS32
4750 # define IMAGE_FILE_MACHINE 0x01C0
4851 # define RSRC_RELTYPE 7 /* ??? (not tested) */
4952
@@ -53,6 +56,7 @@ · 3 unmodified lines
5356 # define REL_TYPE_DIRECT R_386_32
5457 # define R_XXX_THUNKFIX R_386_32
5558 # define R_XXX_RELATIVE R_386_RELATIVE
59+# define R_XXX_FUNCCALL R_386_PC32
5660 # define IMAGE_FILE_MACHINE 0x014C
5761 # define RSRC_RELTYPE 7 /* DIR32NB */
5862
@@ -1217,13 +1221,21 @@ static int pe_isafunc(TCCState *s1, int sym_index) · 1158 unmodified lines
12171221 {
12181222 Section *sr = text_section->reloc;
12191223 ElfW_Rel *rel, *rel_end;
1220− Elf32_Word info = ELF32_R_INFO(sym_index, R_386_PC32);
1224+ ElfW(Addr)info = ELFW(R_INFO)(sym_index, R_XXX_FUNCCALL);
1225+#ifdef R_XXX_FUNCCALL2
1226+ ElfW(Addr)info2 = ELFW(R_INFO)(sym_index, R_XXX_FUNCCALL2);
1227+#endif
12211228 if (!sr)
12221229 return 0;
12231230 rel_end = (ElfW_Rel *)(sr->data + sr->data_offset);
1224− for (rel = (ElfW_Rel *)sr->data; rel < rel_end; rel++)
1231+ for (rel = (ElfW_Rel *)sr->data; rel < rel_end; rel++) {
12251232 if (rel->r_info == info)
12261233 return 1;
1234+#ifdef R_XXX_FUNCCALL2
1235+ if (rel->r_info == info2)
1236+ return 1;
1237+#endif
1238+ }
12271239 return 0;
12281240 }
12291241

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t