diff options
| author | Daniel Golle | 2020-10-22 21:59:14 +0000 |
|---|---|---|
| committer | Daniel Golle | 2020-10-23 12:36:45 +0000 |
| commit | 33b799b94c38fd2d3961b465a8114e384573a6d6 (patch) | |
| tree | 934c880a247d5e2fdac3c0799124c29be1c5c55d | |
| parent | ec461ffea89001b4c12196aa64c8235bbb8dfcc4 (diff) | |
| download | procd-33b799b94c38fd2d3961b465a8114e384573a6d6.tar.gz | |
ujail: elf: work around GCC bug on MIPS64
Work-around gcc bug which leads to segfault parsing ELF on MIPS64.
The codepath added in this commit gets triggered when parsing
/lib/ld-musl-mips64-sf.so.1 (a symlink to /lib/libc.so) on MIPS64
(built with gcc-8.4.0 and musl 1.1.24) in qemu-system-mips64 on the
malta/be64 target.
Include work-around outputting an error message, but preventing
segfault when building for MIPS64.
Tested-by: Roman Kuzmitskii <damex.pp@icloud.com>
[tested on edgerouter 4 and edgerouter lite]
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
| -rw-r--r-- | jail/elf.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -235,7 +235,11 @@ int elf_load_deps(const char *path, const char *map) unsigned int dyn_offset, dyn_size; unsigned int load_offset, load_vaddr; unsigned int interp_offset; +#if defined(__mips__) && (__mips == 64) + static int gcc_mips64_bug_work_around; + gcc_mips64_bug_work_around = 1; +#endif if (elf_find_section(map, PT_LOAD, &load_offset, NULL, &load_vaddr)) { ERROR("failed to load the .load section from %s\n", path); return -1; @@ -252,6 +256,14 @@ int elf_load_deps(const char *path, const char *map) int clazz = map[EI_CLASS]; +#if defined(__mips__) && (__mips == 64) + if (gcc_mips64_bug_work_around != 1) { + ERROR("compiler bug: GCC for MIPS64 should be fixed!\n"); + return -1; + } + gcc_mips64_bug_work_around = 0; +#endif + if (clazz == ELFCLASS32) return elf32_scan_dynamic(map, dyn_offset, dyn_size, load_vaddr - load_offset); else if (clazz == ELFCLASS64) |