Message ID | 361437153966df06ce27e75c73f87acdbeb9515f.1385196868.git.Morten.ThunbergSvendsen@prevas.dk |
---|---|
State | Accepted |
Delegated to: | Esben Haabendal |
Headers | show |
Morten Thunberg Svendsen <Morten.ThunbergSvendsen@prevas.dk> writes: > Calling linker ld-linux on a ELF binary with no rpath will result in the use of > the hosts native libraies. Ld-linux will fail if libc is not the same verison > as used when creating it. > --- > classes/sdk-image.oeclass | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/classes/sdk-image.oeclass b/classes/sdk-image.oeclass > index 044ec9c..b23cb44 100644 > --- a/classes/sdk-image.oeclass > +++ b/classes/sdk-image.oeclass > @@ -25,6 +25,10 @@ IMAGE_PREPROCESS_NETFILTER = "" > IMAGE_PREPROCESS_NETFILTER:HOST_OS_mingw32 = "image_preprocess_linux_netfilter_headers" > IMAGE_PREPROCESS_FUNCS += "${IMAGE_PREPROCESS_NETFILTER}" > > +inherit rpath > +image_preprocess_elf_sowrap[import] = "chrpath_get_cmd" > +META_EMIT_PREFIX += "rstage:CHRPATH" > + > SDK_IMAGE_ELF_SOWRAP_DIRS ?= "${base_bindir} ${bindir}" > SDK_IMAGE_ELF_SOWRAP_LD_SO ?= "/lib/ld-linux*.so.2" > > @@ -50,6 +54,14 @@ def image_preprocess_elf_sowrap(d): > static_re = re.compile(".*statically.*") > return bool(static_re.match(filetype)) > > + def is_with_rpath(path): > + chrpath = chrpath_get_cmd(d,filemagic.file(path)) > + print chrpath I guess this debug information is not normally needed. > + cmd = [chrpath, '-l', path] > + rpath = oelite.util.shcmd(cmd, quiet=True, > + silent_errorcodes=[99]) > + return bool(rpath) > + > def sowrap_dir(dir, recursive=False): > if not os.path.exists(dir): > return True > @@ -72,6 +84,8 @@ def image_preprocess_elf_sowrap(d): > continue > if is_static(path): > continue > + if not is_with_rpath(path): > + continue > os.rename(path, dotpath) > with open(path, "w") as wrapper: > dirparts = len(os.path.dirname(path).split('/')) I removed the "print chrpath" line, and merged to master. /Esben
diff --git a/classes/sdk-image.oeclass b/classes/sdk-image.oeclass index 044ec9c..b23cb44 100644 --- a/classes/sdk-image.oeclass +++ b/classes/sdk-image.oeclass @@ -25,6 +25,10 @@ IMAGE_PREPROCESS_NETFILTER = "" IMAGE_PREPROCESS_NETFILTER:HOST_OS_mingw32 = "image_preprocess_linux_netfilter_headers" IMAGE_PREPROCESS_FUNCS += "${IMAGE_PREPROCESS_NETFILTER}" +inherit rpath +image_preprocess_elf_sowrap[import] = "chrpath_get_cmd" +META_EMIT_PREFIX += "rstage:CHRPATH" + SDK_IMAGE_ELF_SOWRAP_DIRS ?= "${base_bindir} ${bindir}" SDK_IMAGE_ELF_SOWRAP_LD_SO ?= "/lib/ld-linux*.so.2" @@ -50,6 +54,14 @@ def image_preprocess_elf_sowrap(d): static_re = re.compile(".*statically.*") return bool(static_re.match(filetype)) + def is_with_rpath(path): + chrpath = chrpath_get_cmd(d,filemagic.file(path)) + print chrpath + cmd = [chrpath, '-l', path] + rpath = oelite.util.shcmd(cmd, quiet=True, + silent_errorcodes=[99]) + return bool(rpath) + def sowrap_dir(dir, recursive=False): if not os.path.exists(dir): return True @@ -72,6 +84,8 @@ def image_preprocess_elf_sowrap(d): continue if is_static(path): continue + if not is_with_rpath(path): + continue os.rename(path, dotpath) with open(path, "w") as wrapper: dirparts = len(os.path.dirname(path).split('/'))