diff options
author | W. J. van der Laan <laanwj@protonmail.com> | 2021-10-13 14:40:37 +0200 |
---|---|---|
committer | W. J. van der Laan <laanwj@protonmail.com> | 2021-10-13 15:01:34 +0200 |
commit | 71a85fbd09b5a450edc53a8ba4131f32e7136ca7 (patch) | |
tree | 4e552eefddd56f2a0a6ef5c8725f2e99223dccb3 | |
parent | da13c7b18afca274aedddc64e211241becc4b38e (diff) | |
parent | 1527b7e8a1339705a48d4d1ed108230fc4953c18 (diff) |
Merge bitcoin/bitcoin#23148: build: Fix guix linker-loader path and add check_ELF_interpreter
1527b7e8a1339705a48d4d1ed108230fc4953c18 symbol-check: Check requested ELF interpreter (Carl Dong)
b96adcbfae90b3e041754f11624cac04c1999e8c guix: Fix powerpc64(le) dynamic linker name (Carl Dong)
Pull request description:
Fixes https://github.com/bitcoin/bitcoin/issues/23111
It would seem that I got the wrong default glibc-dynamic-linker path for PowerPC platforms. This means that for our currently released v22.0 binaries to be run on powerpc platforms, users would have to either:
1. Move `/lib64/ld64.so.?` to `/lib`, or
2. Invoke their linker-loader directly to start our binaries, e.g. `/lib64/ld64.so.? bitcoind`
This is my bad.
I've fixed the paths in this patchset, and also added a test to `symbol-check.py` so that this does not ever slip past our checks again.
ACKs for top commit:
laanwj:
Code review ACK 1527b7e8a1339705a48d4d1ed108230fc4953c18
Tree-SHA512: bc520c35f72a9d4a3804b53d211138724560bd2405bf2f592ef755d19073e72f114fc4b8a3747e0c8724ac46a60b6ca86ea7766d66acb88eed1ebe2abc2678b8
-rwxr-xr-x | contrib/devtools/symbol-check.py | 34 | ||||
-rwxr-xr-x | contrib/guix/libexec/build.sh | 4 |
2 files changed, 34 insertions, 4 deletions
diff --git a/contrib/devtools/symbol-check.py b/contrib/devtools/symbol-check.py index c8703c53ba..158b6fa0ff 100755 --- a/contrib/devtools/symbol-check.py +++ b/contrib/devtools/symbol-check.py @@ -11,7 +11,7 @@ Example usage: find ../path/to/binaries -type f -executable | xargs python3 contrib/devtools/symbol-check.py ''' import sys -from typing import List +from typing import List, Dict import lief @@ -63,6 +63,30 @@ IGNORE_EXPORTS = { 'environ', '_environ', '__environ', } +# Expected linker-loader names can be found here: +# https://sourceware.org/glibc/wiki/ABIList?action=recall&rev=16 +ELF_INTERPRETER_NAMES: Dict[lief.ELF.ARCH, Dict[lief.ENDIANNESS, str]] = { + lief.ELF.ARCH.i386: { + lief.ENDIANNESS.LITTLE: "/lib/ld-linux.so.2", + }, + lief.ELF.ARCH.x86_64: { + lief.ENDIANNESS.LITTLE: "/lib64/ld-linux-x86-64.so.2", + }, + lief.ELF.ARCH.ARM: { + lief.ENDIANNESS.LITTLE: "/lib/ld-linux-armhf.so.3", + }, + lief.ELF.ARCH.AARCH64: { + lief.ENDIANNESS.LITTLE: "/lib/ld-linux-aarch64.so.1", + }, + lief.ELF.ARCH.PPC64: { + lief.ENDIANNESS.BIG: "/lib64/ld64.so.1", + lief.ENDIANNESS.LITTLE: "/lib64/ld64.so.2", + }, + LIEF_ELF_ARCH_RISCV: { + lief.ENDIANNESS.LITTLE: "/lib/ld-linux-riscv64-lp64d.so.1", + }, +} + # Allowed NEEDED libraries ELF_ALLOWED_LIBRARIES = { # bitcoind and bitcoin-qt @@ -215,11 +239,17 @@ def check_PE_subsystem_version(binary) -> bool: return True return False +def check_ELF_interpreter(binary) -> bool: + expected_interpreter = ELF_INTERPRETER_NAMES[binary.header.machine_type][binary.abstract.header.endianness] + + return binary.concrete.interpreter == expected_interpreter + CHECKS = { 'ELF': [ ('IMPORTED_SYMBOLS', check_imported_symbols), ('EXPORTED_SYMBOLS', check_exported_symbols), - ('LIBRARY_DEPENDENCIES', check_ELF_libraries) + ('LIBRARY_DEPENDENCIES', check_ELF_libraries), + ('INTERPRETER_NAME', check_ELF_interpreter), ], 'MACHO': [ ('DYNAMIC_LIBRARIES', check_MACHO_libraries), diff --git a/contrib/guix/libexec/build.sh b/contrib/guix/libexec/build.sh index 93526f8c45..93476d5f30 100755 --- a/contrib/guix/libexec/build.sh +++ b/contrib/guix/libexec/build.sh @@ -169,8 +169,8 @@ case "$HOST" in arm-linux-gnueabihf) echo /lib/ld-linux-armhf.so.3 ;; aarch64-linux-gnu) echo /lib/ld-linux-aarch64.so.1 ;; riscv64-linux-gnu) echo /lib/ld-linux-riscv64-lp64d.so.1 ;; - powerpc64-linux-gnu) echo /lib/ld64.so.1;; - powerpc64le-linux-gnu) echo /lib/ld64.so.2;; + powerpc64-linux-gnu) echo /lib64/ld64.so.1;; + powerpc64le-linux-gnu) echo /lib64/ld64.so.2;; *) exit 1 ;; esac ) |