1 From 2136969e3e196b9cf7f4788340efa4b1d9b39565 Mon Sep 17 00:00:00 2001
2 From: Robert Yang <liezhi.yang@windriver.com>
3 Date: Thu, 11 Oct 2018 10:05:52 +0800
4 Subject: [PATCH] src/arch-mips.c: check info->resolvetls before use its member
6 The info->resolvetls might be NULL according to src/prelink.c:
8 /* Dynamic linker does not depend on any other library,
9 all symbols resolve to themselves with the exception
10 of SHN_UNDEF symbols which resolve to 0. */
11 if (info->symtab[r_sym].st_shndx == SHN_UNDEF)
13 info->resolveent = NULL;
14 info->resolvetls = NULL;
17 So we must check it before use its members, otherwise, there might be
18 Segmentation fault error.
22 IMAGE_INSTALL_append = " qemu"
23 $ bitbake core-image-minimal
25 | /path/to/qemumips-poky-linux/core-image-minimal/1.0-r0/temp/run.prelink_image.1000: line 111: 1010 Segmentation fault (core dumped)
28 Upstream-Status: Submitted [https://lists.yoctoproject.org/pipermail/yocto/2018-October/042812.html]
30 Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
32 src/arch-mips.c | 3 ++-
33 1 file changed, 2 insertions(+), 1 deletion(-)
35 diff --git a/src/arch-mips.c b/src/arch-mips.c
36 index ccb1834..02c608f 100644
39 @@ -567,7 +567,8 @@ mips_prelink_reloc (struct prelink_info *info, GElf_Addr r_offset,
40 if (dso->ehdr.e_type == ET_EXEC)
42 value = info->resolve (info, r_sym, r_type);
43 - value += info->resolvetls->offset - TLS_TP_OFFSET;
44 + if (info->resolvetls != NULL)
45 + value += info->resolvetls->offset - TLS_TP_OFFSET;
46 if (r_type == R_MIPS_TLS_TPREL32)
47 mips_prelink_32bit_reloc (dso, rela, value);