[PATCH]mips: ldso: dlopen with flag RTLD_NOW should look up the symbols
Andrew Bennett
Andrew.Bennett at imgtec.com
Sat Mar 21 09:40:52 UTC 2015
> struct symbol_ref sym_ref;
> + ElfW(Sym) *psym = NULL;
> /* Now parse the relocation information */
> rel_size = rel_size / sizeof(ElfW(Rel));
> rpnt = (ELF_RELOC *) rel_addr;
> @@ -170,6 +171,33 @@ int _dl_parse_relocation_information(struct dyn_elf *xpnt,
> strtab = (char *) tpnt->dynamic_info[DT_STRTAB];
> got = (unsigned long *) tpnt->dynamic_info[DT_PLTGOT];
>
> + i = tpnt->dynamic_info[DT_MIPS_SYMTABNO_IDX] -
> + tpnt->dynamic_info[DT_MIPS_GOTSYM_IDX];
> + psym = symtab + tpnt->dynamic_info[DT_MIPS_GOTSYM_IDX];
> + for (; i != 0; --i, ++psym) {
> + if (psym->st_name == 0) {
> + continue;
> + }
> +
> + if (psym->st_shndx != SHN_UNDEF
> + || ELF_ST_BIND(psym->st_info) != STB_GLOBAL
> + || (ELF_ST_TYPE(psym->st_info) != STT_FUNC
> + && ELF_ST_TYPE(psym->st_info) != STT_OBJECT)) {
> + continue;
> + }
> + symname = strtab + psym->st_name;
> +
> + sym_ref.tpnt = NULL;
> + sym_ref.sym = psym;
> + symbol_addr = (unsigned long)_dl_find_hash(symname,
> + scope,
> + tpnt,
> + ELF_RTYPE_CLASS_PLT, &sym_ref);
> + if (symbol_addr == 0) {
> + _dl_dprintf (2, "%s: undefined symbol: %s\n",tpnt->libname, symname);
> + return 1;
> + }
> + }
>
> for (i = 0; i < rel_size; i++, rpnt++) {
> reloc_addr = (unsigned long *) (tpnt->loadaddr +
Just realised I top-posted my last comment. My comment is now correctly
bottom-posted below.
Many thanks for the patch. If my reading of your patch is correct it looks as if it
will not respect lazy function binding, as it always resolves the function entries. You
will therefore need to predicate this to happen only if RTLD_NOW is used.
Having saying this I am not sure if the fix is in the correct place. The issue here
is about how the dynamic loader loads different types of ELF files and then deals with
resolving the ELF's symbols. I would therefore be happier if the fix was made to the
core dynamic loader code to handle this case.
Finally, it would be good if your testcase could be added to the tests in tests/dlopen
so that we can check for this issue in the future.
Many thanks,
Andrew
More information about the uClibc
mailing list