From d578151f8c739766b92d49b4f117e68316e7d1c0 Mon Sep 17 00:00:00 2001 From: herman ten brugge Date: Fri, 18 Nov 2022 01:51:36 -0600 Subject: [PATCH] Fix weak support apple --- tccmacho.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tccmacho.c b/tccmacho.c index 6611e2d7..7dff5ce9 100644 --- a/tccmacho.c +++ b/tccmacho.c @@ -1004,13 +1004,13 @@ static void do_bind_rebase(TCCState *s1, struct macho *mo) } for (i = 0; i < mo->n_bind; i++) { int sym_index = ELFW(R_SYM)(mo->bind[i].rel.r_info); - sym = &((ElfW(Sym) *)symtab_section->data)[sym_index]; Section *s = s1->sections[mo->bind[i].section]; - Section *binding = ELFW(ST_BIND)(sym->st_info) == STB_WEAK - ? mo->weak_binding : mo->binding; + Section *binding; sym = &((ElfW(Sym) *)symtab_section->data)[sym_index]; name = (char *) symtab_section->link->data + sym->st_name; + binding = ELFW(ST_BIND)(sym->st_info) == STB_WEAK + ? mo->weak_binding : mo->binding; ptr = section_ptr_add(binding, 5 + strlen(name)); *ptr++ = BIND_OPCODE_SET_DYLIB_SPECIAL_IMM | (BIND_SPECIAL_DYLIB_FLAT_LOOKUP & 0xf);