rtld_next broke?

Florian Fainelli florian at openwrt.org
Thu Nov 8 13:50:52 UTC 2012


On Friday 02 November 2012 08:52:39 Timo Teras wrote:
> On Thu, 1 Nov 2012 21:13:32 +0200 Timo Teras <timo.teras at iki.fi> wrote:
> > I noticed that dlsym(RTLD_NEXT) seems to be broken under certain
> > conditions. I also noticed that Floarian observed this earlier too
> > [1], but no solution seems to have been provided.
> > 
> > It appears this is related closely to the linking order of the final
> > executable.
> >[snip]
> > 
> > Appears that we need to add some sort of for loop iterating through
> > all the following modules.
> > 
> > Will try to patch tomorrow. Or does someone have a better solution for
> > this?
> 
> I'm now playing with the following patch. Fixes my trivial test case.

Works for me as well. It would be good to have someone confirm this is the
proper solution and get this fixed and pushed back to stable branches.

Thanks Timo!

> 
> --- a/ldso/libdl/libdl.c
> +++ b/ldso/libdl/libdl.c
> @@ -671,7 +671,7 @@
>  {
>  	struct elf_resolve *tpnt, *tfrom;
>  	struct dyn_elf *handle;
> -	ElfW(Addr) from;
> +	ElfW(Addr) from = 0;
>  	struct dyn_elf *rpnt;
>  	void *ret;
>  	struct symbol_ref sym_ref = { NULL, NULL };
> @@ -729,7 +729,13 @@
>  	tpnt = NULL;
>  	if (handle == _dl_symbol_tables)
>  		tpnt = handle->dyn; /* Only search RTLD_GLOBAL objs if global object */
> -	ret = _dl_find_hash(name2, &handle->dyn->symbol_scope, tpnt, ELF_RTYPE_CLASS_DLSYM, &sym_ref);
> +
> +	do {
> +		ret = _dl_find_hash(name2, &handle->dyn->symbol_scope, tpnt, ELF_RTYPE_CLASS_DLSYM, &sym_ref);
> +		if (ret != NULL)
> +			break;
> +		handle = handle->next;
> +	} while (from && handle);
>  
>  #if defined(USE_TLS) && USE_TLS && defined SHARED
>  	if (sym_ref.sym && (ELF_ST_TYPE(sym_ref.sym->st_info) == STT_TLS) && (sym_ref.tpnt)) {
> 
> _______________________________________________
> uClibc mailing list
> uClibc at uclibc.org
> http://lists.busybox.net/mailman/listinfo/uclibc


More information about the uClibc mailing list