Message ID | 1424390606-1288-1-git-send-email-sellcey@imgtec.com |
---|---|
State | Accepted |
Commit | 409f14d9b5e47513d5c939120a33965997c8ceb2 |
Headers | show |
On February 20, 2015 1:03:26 AM GMT+01:00, Steve Ellcey <sellcey@imgtec.com> wrote: >This option will modify ldso so that it will use the executables >RPATH/RUNPATH to find to find libraries even though this behavour >is not standard. Setting this option causes the uclibc dynamic linker >behavour to match the glibc dynamic linker. Isn't RUNPATH a separate entry? Thanks, > >Signed-off-by: Steve Ellcey <sellcey@imgtec.com> >--- > extra/Configs/Config.in | 9 +++++++++ > ldso/ldso/dl-elf.c | 12 ++++++++++++ > 2 files changed, 21 insertions(+) > >diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in >index 8e603b2..a235c3d 100644 >--- a/extra/Configs/Config.in >+++ b/extra/Configs/Config.in >@@ -418,6 +418,15 @@ config LDSO_RUNPATH > Usage of RUNPATH tags is not too common, so disabling this feature > should be safe for most people. > >+config LDSO_RUNPATH_OF_EXECUTABLE >+ bool "Use executables RPATH/RUNPATH when searching for libraries." >+ depends on LDSO_RUNPATH >+ default n >+ help >+ Use the executables RPATH/RUNPATH to find to find libraries even >+ though this behavour is not standard. Setting this option causes >+ the uclibc dynamic linker behavour to match the glibc dynamic >linker. >+ > config LDSO_SAFE_RUNPATH > bool "Allow only RUNPATH beginning with /" > depends on LDSO_RUNPATH >diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c >index 54501d1..56076b6 100644 >--- a/ldso/ldso/dl-elf.c >+++ b/ldso/ldso/dl-elf.c >@@ -237,6 +237,18 @@ struct elf_resolve >*_dl_load_shared_library(unsigned rflags, struct dyn_elf **rp > if ((tpnt1 = search_for_named_library(libname, rflags, pnt, rpnt)) != >NULL) > return tpnt1; > } >+#ifdef __LDSO_RUNPATH_OF_EXECUTABLE__ >+ /* >+ * Try the DT_RPATH of the executable itself. >+ */ >+ pnt = (char *) _dl_loaded_modules->dynamic_info[DT_RPATH]; >+ if (pnt) { >+ pnt += (unsigned long) >_dl_loaded_modules->dynamic_info[DT_STRTAB]; >+ _dl_if_debug_dprint("\tsearching exe's RPATH='%s'\n", >pnt); >+ if ((tpnt1 = search_for_named_library(libname, rflags, >pnt, rpnt)) != NULL) >+ return tpnt1; >+ } >+#endif > #endif > > #ifdef __LDSO_LD_LIBRARY_PATH__
On 20 February 2015 at 08:32, Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> wrote: > On February 20, 2015 1:03:26 AM GMT+01:00, Steve Ellcey <sellcey@imgtec.com> wrote: >>This option will modify ldso so that it will use the executables >>RPATH/RUNPATH to find to find libraries even though this behavour >>is not standard. Setting this option causes the uclibc dynamic linker >>behavour to match the glibc dynamic linker. > > Isn't RUNPATH a separate entry? I applied something very similar to master now. Thanks for your persistance :) cheers,
On February 20, 2015 3:44:34 PM GMT+01:00, Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> wrote: >On 20 February 2015 at 08:32, Bernhard Reutner-Fischer ><rep.dot.nop@gmail.com> wrote: >> On February 20, 2015 1:03:26 AM GMT+01:00, Steve Ellcey ><sellcey@imgtec.com> wrote: >>>This option will modify ldso so that it will use the executables >>>RPATH/RUNPATH to find to find libraries even though this behavour >>>is not standard. Setting this option causes the uclibc dynamic >linker >>>behavour to match the glibc dynamic linker. >> >> Isn't RUNPATH a separate entry? > >I applied something very similar to master now. > >Thanks for your persistance :) Thinking about $ORIGIN support, the above, too, should of course be conditional on not being SUID. I'll fix that up ASAP. As said, the whole workaround is really a bad idea.. Thanks, >cheers,
diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in index 8e603b2..a235c3d 100644 --- a/extra/Configs/Config.in +++ b/extra/Configs/Config.in @@ -418,6 +418,15 @@ config LDSO_RUNPATH Usage of RUNPATH tags is not too common, so disabling this feature should be safe for most people. +config LDSO_RUNPATH_OF_EXECUTABLE + bool "Use executables RPATH/RUNPATH when searching for libraries." + depends on LDSO_RUNPATH + default n + help + Use the executables RPATH/RUNPATH to find to find libraries even + though this behavour is not standard. Setting this option causes + the uclibc dynamic linker behavour to match the glibc dynamic linker. + config LDSO_SAFE_RUNPATH bool "Allow only RUNPATH beginning with /" depends on LDSO_RUNPATH diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c index 54501d1..56076b6 100644 --- a/ldso/ldso/dl-elf.c +++ b/ldso/ldso/dl-elf.c @@ -237,6 +237,18 @@ struct elf_resolve *_dl_load_shared_library(unsigned rflags, struct dyn_elf **rp if ((tpnt1 = search_for_named_library(libname, rflags, pnt, rpnt)) != NULL) return tpnt1; } +#ifdef __LDSO_RUNPATH_OF_EXECUTABLE__ + /* + * Try the DT_RPATH of the executable itself. + */ + pnt = (char *) _dl_loaded_modules->dynamic_info[DT_RPATH]; + if (pnt) { + pnt += (unsigned long) _dl_loaded_modules->dynamic_info[DT_STRTAB]; + _dl_if_debug_dprint("\tsearching exe's RPATH='%s'\n", pnt); + if ((tpnt1 = search_for_named_library(libname, rflags, pnt, rpnt)) != NULL) + return tpnt1; + } +#endif #endif #ifdef __LDSO_LD_LIBRARY_PATH__
This option will modify ldso so that it will use the executables RPATH/RUNPATH to find to find libraries even though this behavour is not standard. Setting this option causes the uclibc dynamic linker behavour to match the glibc dynamic linker. Signed-off-by: Steve Ellcey <sellcey@imgtec.com> --- extra/Configs/Config.in | 9 +++++++++ ldso/ldso/dl-elf.c | 12 ++++++++++++ 2 files changed, 21 insertions(+)