Unified · Split
| @@ -665,11 +665,9 @@ ST_FUNC void relocate_syms(TCCState *s1, int do_resolve) · 664 unmodified lines | |||
| 665 | /* Use ld.so to resolve symbol for us (for tcc -run) */ | 665 | /* Use ld.so to resolve symbol for us (for tcc -run) */ |
| 666 | if (do_resolve) { | 666 | if (do_resolve) { |
| 667 | #if defined TCC_IS_NATIVE && !defined TCC_TARGET_PE | 667 | #if defined TCC_IS_NATIVE && !defined TCC_TARGET_PE |
| 668 | void *addr; | 668 | void *addr = dlsym(RTLD_DEFAULT, name); |
| 669 | name = (char *) symtab_section->link->data + sym->st_name; | ||
| 670 | addr = dlsym(RTLD_DEFAULT, name); | ||
| 671 | if (addr) { | 669 | if (addr) { |
| 672 | sym->st_value = (addr_t)addr; | 670 | sym->st_value = (addr_t) addr; |
| 673 | #ifdef DEBUG_RELOC | 671 | #ifdef DEBUG_RELOC |
| 674 | printf ("relocate_sym: %s -> 0x%lx\n", name, sym->st_value); | 672 | printf ("relocate_sym: %s -> 0x%lx\n", name, sym->st_value); |
| 675 | #endif | 673 | #endif |
| @@ -686,11 +684,10 @@ ST_FUNC void relocate_syms(TCCState *s1, int do_resolve) · 10 unmodified lines | |||
| 686 | /* only weak symbols are accepted to be undefined. Their | 684 | /* only weak symbols are accepted to be undefined. Their |
| 687 | value is zero */ | 685 | value is zero */ |
| 688 | sym_bind = ELFW(ST_BIND)(sym->st_info); | 686 | sym_bind = ELFW(ST_BIND)(sym->st_info); |
| 689 | if (sym_bind == STB_WEAK) { | 687 | if (sym_bind == STB_WEAK) |
| 690 | sym->st_value = 0; | 688 | sym->st_value = 0; |
| 691 | } else { | 689 | else |
| 692 | tcc_error_noabort("undefined symbol '%s'", name); | 690 | tcc_error_noabort("undefined symbol '%s'", name); |
| 693 | } | ||
| 694 | } else if (sh_num < SHN_LORESERVE) { | 691 | } else if (sh_num < SHN_LORESERVE) { |
| 695 | /* add section base */ | 692 | /* add section base */ |
| 696 | sym->st_value += s1->sections[sym->st_shndx]->sh_addr; | 693 | sym->st_value += s1->sections[sym->st_shndx]->sh_addr; |