diff options
author | Yuteng Zhong <zonyitoo@qq.com> | 2022-10-09 22:53:27 +0800 |
---|---|---|
committer | Daniel Golle <daniel@makrotopia.org> | 2022-11-10 20:30:42 +0000 |
commit | 93b2c2d5ed4ca369a9ea48163024125b958212b5 (patch) | |
tree | b5082680273c690ef7dc48bd3d7ea43c879edd3b | |
parent | 24f6bc4322754a753e4e3e413659d542fa798c7b (diff) | |
download | procd-93b2c2d5ed4ca369a9ea48163024125b958212b5.tar.gz |
jail: ignore missing .dynamic sect
A static-linked binary doesn't have a .dynamic section, but when
starting ujail with -r or -w will automatically search for PT_DYNAMIC in
ELF and exit with failure if it is not found.
github issue: https://github.com/openwrt/openwrt/issues/10933
Signed-off-by: Yuteng Zhong <zonyitoo@qq.com>
-rw-r--r-- | jail/elf.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -236,18 +236,18 @@ int elf_load_deps(const char *path, const char *map) unsigned long load_offset, load_vaddr; unsigned long interp_offset; - 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; + if (elf_find_section(map, PT_INTERP, &interp_offset, NULL, NULL) == 0) { + add_path_and_deps(map+interp_offset, 1, -1, 0); } - if (elf_find_section(map, PT_DYNAMIC, &dyn_offset, &dyn_size, NULL)) { - ERROR("failed to load the .dynamic section from %s\n", path); - return -1; + if (elf_find_section(map, PT_LOAD, &load_offset, NULL, &load_vaddr)) { + DEBUG("failed to load the .load section from %s\n", path); + return 0; } - if (elf_find_section(map, PT_INTERP, &interp_offset, NULL, NULL) == 0) { - add_path_and_deps(map+interp_offset, 1, -1, 0); + if (elf_find_section(map, PT_DYNAMIC, &dyn_offset, &dyn_size, NULL)) { + DEBUG("failed to load the .dynamic section from %s\n", path); + return 0; } int clazz = map[EI_CLASS]; |