Skip to content

Commit 71a85fb

Browse files
committed
Merge bitcoin/bitcoin#23148: build: Fix guix linker-loader path and add check_ELF_interpreter
1527b7e symbol-check: Check requested ELF interpreter (Carl Dong) b96adcb guix: Fix powerpc64(le) dynamic linker name (Carl Dong) Pull request description: Fixes bitcoin/bitcoin#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 1527b7e Tree-SHA512: bc520c35f72a9d4a3804b53d211138724560bd2405bf2f592ef755d19073e72f114fc4b8a3747e0c8724ac46a60b6ca86ea7766d66acb88eed1ebe2abc2678b8
2 parents da13c7b + 1527b7e commit 71a85fb

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

contrib/devtools/symbol-check.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
find ../path/to/binaries -type f -executable | xargs python3 contrib/devtools/symbol-check.py
1212
'''
1313
import sys
14-
from typing import List
14+
from typing import List, Dict
1515

1616
import lief
1717

@@ -63,6 +63,30 @@
6363
'environ', '_environ', '__environ',
6464
}
6565

66+
# Expected linker-loader names can be found here:
67+
# https://sourceware.org/glibc/wiki/ABIList?action=recall&rev=16
68+
ELF_INTERPRETER_NAMES: Dict[lief.ELF.ARCH, Dict[lief.ENDIANNESS, str]] = {
69+
lief.ELF.ARCH.i386: {
70+
lief.ENDIANNESS.LITTLE: "/lib/ld-linux.so.2",
71+
},
72+
lief.ELF.ARCH.x86_64: {
73+
lief.ENDIANNESS.LITTLE: "/lib64/ld-linux-x86-64.so.2",
74+
},
75+
lief.ELF.ARCH.ARM: {
76+
lief.ENDIANNESS.LITTLE: "/lib/ld-linux-armhf.so.3",
77+
},
78+
lief.ELF.ARCH.AARCH64: {
79+
lief.ENDIANNESS.LITTLE: "/lib/ld-linux-aarch64.so.1",
80+
},
81+
lief.ELF.ARCH.PPC64: {
82+
lief.ENDIANNESS.BIG: "/lib64/ld64.so.1",
83+
lief.ENDIANNESS.LITTLE: "/lib64/ld64.so.2",
84+
},
85+
LIEF_ELF_ARCH_RISCV: {
86+
lief.ENDIANNESS.LITTLE: "/lib/ld-linux-riscv64-lp64d.so.1",
87+
},
88+
}
89+
6690
# Allowed NEEDED libraries
6791
ELF_ALLOWED_LIBRARIES = {
6892
# bitcoind and bitcoin-qt
@@ -215,11 +239,17 @@ def check_PE_subsystem_version(binary) -> bool:
215239
return True
216240
return False
217241

242+
def check_ELF_interpreter(binary) -> bool:
243+
expected_interpreter = ELF_INTERPRETER_NAMES[binary.header.machine_type][binary.abstract.header.endianness]
244+
245+
return binary.concrete.interpreter == expected_interpreter
246+
218247
CHECKS = {
219248
'ELF': [
220249
('IMPORTED_SYMBOLS', check_imported_symbols),
221250
('EXPORTED_SYMBOLS', check_exported_symbols),
222-
('LIBRARY_DEPENDENCIES', check_ELF_libraries)
251+
('LIBRARY_DEPENDENCIES', check_ELF_libraries),
252+
('INTERPRETER_NAME', check_ELF_interpreter),
223253
],
224254
'MACHO': [
225255
('DYNAMIC_LIBRARIES', check_MACHO_libraries),

contrib/guix/libexec/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ case "$HOST" in
169169
arm-linux-gnueabihf) echo /lib/ld-linux-armhf.so.3 ;;
170170
aarch64-linux-gnu) echo /lib/ld-linux-aarch64.so.1 ;;
171171
riscv64-linux-gnu) echo /lib/ld-linux-riscv64-lp64d.so.1 ;;
172-
powerpc64-linux-gnu) echo /lib/ld64.so.1;;
173-
powerpc64le-linux-gnu) echo /lib/ld64.so.2;;
172+
powerpc64-linux-gnu) echo /lib64/ld64.so.1;;
173+
powerpc64le-linux-gnu) echo /lib64/ld64.so.2;;
174174
*) exit 1 ;;
175175
esac
176176
)

0 commit comments

Comments
 (0)