]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
prelink: use ehdr.e_shstrndx as index rather than ehdr.e_shnum
authorRobert Yang <liezhi.yang@windriver.com>
Thu, 16 Aug 2018 02:25:46 +0000 (10:25 +0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 16 Aug 2018 21:40:27 +0000 (22:40 +0100)
[YOCTO #12791]

According to struct elf32_hd, the e_shnum is section header number, and the
index is e_shstrndx, not e_shnum.

This can fix segmention fault when handle libqb.so.0.18.2 from libqb_1.0.3.
It fails to handle libqb.so.0.18.2 and get errors:
Symbol section index outside of section numbers

Then segmentation fault, this is because the e_shnum is 34, while e_shstrndx is
27 (it would be 33 when no errors), I've checked several elf files to confirm
that the ones after e_shstrndx is NULL, so use e_shstrndx should be correct.

Fixed:
MACHINE="qemux86-64"
IMAGE_INSTALL_append = " libqb" #libqp is from meta-openembedded
$ bitbake core-image-minimal
Segmention fault

(From OE-Core rev: b7c291ee6532cba845ee6bfbbaa21076a2b2cbe5)

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-devtools/prelink/prelink/0001-src-dso.c-use-ehdr.e_shstrndx-as-index.patch [new file with mode: 0644]
meta/recipes-devtools/prelink/prelink_git.bb

diff --git a/meta/recipes-devtools/prelink/prelink/0001-src-dso.c-use-ehdr.e_shstrndx-as-index.patch b/meta/recipes-devtools/prelink/prelink/0001-src-dso.c-use-ehdr.e_shstrndx-as-index.patch
new file mode 100644 (file)
index 0000000..d2cd1a7
--- /dev/null
@@ -0,0 +1,39 @@
+From 107290910ff846532d944ddb78edda436bb6ae63 Mon Sep 17 00:00:00 2001
+From: Robert Yang <liezhi.yang@windriver.com>
+Date: Wed, 15 Aug 2018 17:53:43 +0800
+Subject: [PATCH] src/dso.c: use ehdr.e_shstrndx as index
+
+According to struct elf32_hd, the e_shnum is section header number, and the
+index is e_shstrndx, not e_shnum.
+
+This can fix segmention fault when handle libqb.so.0.18.2 from libqb_1.0.3.
+It fails to handle libqb.so.0.18.2 and get errors:
+Symbol section index outside of section numbers
+
+Then segmentation fault, this is because the e_shnum is 34, while e_shstrndx is
+27 (it would be 33 when no errors), I've checked several elf files to confirm
+that the ones after e_shstrndx is NULL, so use e_shstrndx should be correct.
+
+Upstream-Status: Submitted [https://lists.yoctoproject.org/pipermail/yocto/2018-August/042240.html]
+
+Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
+---
+ src/dso.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/dso.c b/src/dso.c
+index ae5e04d..c59d81f 100644
+--- a/src/dso.c
++++ b/src/dso.c
+@@ -1659,7 +1659,7 @@ close_dso_1 (DSO *dso)
+     {
+       int i;
+-      for (i = 1; i < dso->ehdr.e_shnum; ++i)
++      for (i = 1; i < dso->ehdr.e_shstrndx; ++i)
+       {
+         Elf_Scn *scn = dso->scn[i];
+         Elf_Data *data = NULL;
+-- 
+2.7.4
+
index 0f6d16e00561784d4b0575b43d3ff500b0f1ea9a..c5eaedd4d9d01b6fd518ca56a4356e784ff26425 100644 (file)
@@ -31,7 +31,9 @@ SRC_URI = "git://git.yoctoproject.org/prelink-cross.git;branch=cross_prelink \
            file://prelink.conf \
            file://prelink.cron.daily \
            file://prelink.default \
-          file://macros.prelink"
+           file://macros.prelink \
+           file://0001-src-dso.c-use-ehdr.e_shstrndx-as-index.patch \
+"
 UPSTREAM_CHECK_COMMITS = "1"
 
 TARGET_OS_ORIG := "${TARGET_OS}"