Fix error logic for undefined reference in library
Prior to this patch, an error would only be given when a library has an unresolved undefined symbol if there is no undefined reference for the same symbol in the executable itself. This patch changes the logic to check both that the executable has the symbol in its static symbol table *and* that it is defined to decide if the error path should be followed.
This commit is contained in:
parent
ccf9ed7d54
commit
bf692af31b
1 changed files with 7 additions and 8 deletions
15
tccelf.c
15
tccelf.c
|
@ -2077,14 +2077,13 @@ static void bind_libs_dynsyms(TCCState *s1)
|
||||||
for_each_elem(s1->dynsymtab_section, 1, esym, ElfW(Sym)) {
|
for_each_elem(s1->dynsymtab_section, 1, esym, ElfW(Sym)) {
|
||||||
name = (char *) s1->dynsymtab_section->link->data + esym->st_name;
|
name = (char *) s1->dynsymtab_section->link->data + esym->st_name;
|
||||||
sym_index = find_elf_sym(symtab_section, name);
|
sym_index = find_elf_sym(symtab_section, name);
|
||||||
if (sym_index) {
|
/* XXX: avoid adding a symbol if already present because of
|
||||||
/* XXX: avoid adding a symbol if already present because of
|
-rdynamic ? */
|
||||||
-rdynamic ? */
|
sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
|
||||||
sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
|
if (sym_index && sym->st_shndx != SHN_UNDEF)
|
||||||
if (sym->st_shndx != SHN_UNDEF)
|
put_elf_sym(s1->dynsym, sym->st_value, sym->st_size, sym->st_info,
|
||||||
put_elf_sym(s1->dynsym, sym->st_value, sym->st_size,
|
0, sym->st_shndx, name);
|
||||||
sym->st_info, 0, sym->st_shndx, name);
|
else if (esym->st_shndx == SHN_UNDEF) {
|
||||||
} else if (esym->st_shndx == SHN_UNDEF) {
|
|
||||||
/* weak symbols can stay undefined */
|
/* weak symbols can stay undefined */
|
||||||
if (ELFW(ST_BIND)(esym->st_info) != STB_WEAK)
|
if (ELFW(ST_BIND)(esym->st_info) != STB_WEAK)
|
||||||
tcc_warning("undefined dynamic symbol '%s'", name);
|
tcc_warning("undefined dynamic symbol '%s'", name);
|
||||||
|
|
Loading…
Reference in a new issue