History

Code simplification in relocate_syms

Thomas Preud'homme committed 10 years ago

Commit c4bec031 parent 25927df1 file · +4 −7Browse files

Unified · Split

tccelf.c+4−7
@@ -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_PE667#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_RELOC671#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#endif673#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. Their684 /* 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;

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