blob: 1dfb95e31dd2c9d63e67699c596aaf9a52ae92c0 [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7def get_musl_loader_arch(d):
8 import re
9 ldso_arch = "NotSupported"
10
11 targetarch = d.getVar("TARGET_ARCH")
12 if targetarch.startswith("microblaze"):
13 ldso_arch = "microblaze${@bb.utils.contains('TUNE_FEATURES', 'bigendian', '', 'el', d)}"
14 elif targetarch.startswith("mips"):
15 ldso_arch = "mips${ABIEXTENSION}${MIPSPKGSFX_BYTE}${MIPSPKGSFX_R6}${MIPSPKGSFX_ENDIAN}${@['', '-sf'][d.getVar('TARGET_FPU') == 'soft']}"
16 elif targetarch == "powerpc":
17 ldso_arch = "powerpc${@['', '-sf'][d.getVar('TARGET_FPU') == 'soft']}"
18 elif targetarch.startswith("powerpc64"):
19 ldso_arch = "powerpc64${@bb.utils.contains('TUNE_FEATURES', 'bigendian', '', 'le', d)}"
20 elif targetarch == "x86_64":
21 ldso_arch = "x86_64"
22 elif re.search("i.86", targetarch):
23 ldso_arch = "i386"
24 elif targetarch.startswith("arm"):
25 ldso_arch = "arm${ARMPKGSFX_ENDIAN}${ARMPKGSFX_EABI}"
26 elif targetarch.startswith("aarch64"):
27 ldso_arch = "aarch64${ARMPKGSFX_ENDIAN_64}"
28 elif targetarch.startswith("riscv64"):
29 ldso_arch = "riscv64${@['', '-sf'][d.getVar('TARGET_FPU') == 'soft']}"
30 elif targetarch.startswith("riscv32"):
31 ldso_arch = "riscv32${@['', '-sf'][d.getVar('TARGET_FPU') == 'soft']}"
32 return ldso_arch
33
34def get_musl_loader(d):
35 import re
36 return "/lib/ld-musl-" + get_musl_loader_arch(d) + ".so.1"
37
38def get_glibc_loader(d):
39 import re
40
41 dynamic_loader = "NotSupported"
42 targetarch = d.getVar("TARGET_ARCH")
43 if targetarch in ["powerpc", "microblaze"]:
44 dynamic_loader = "${base_libdir}/ld.so.1"
45 elif targetarch in ["mipsisa32r6el", "mipsisa32r6", "mipsisa64r6el", "mipsisa64r6"]:
46 dynamic_loader = "${base_libdir}/ld-linux-mipsn8.so.1"
47 elif targetarch.startswith("mips"):
48 dynamic_loader = "${base_libdir}/ld.so.1"
49 elif targetarch == "powerpc64le":
50 dynamic_loader = "${base_libdir}/ld64.so.2"
51 elif targetarch == "powerpc64":
52 dynamic_loader = "${base_libdir}/ld64.so.1"
53 elif targetarch == "x86_64":
54 dynamic_loader = "${base_libdir}/ld-linux-x86-64.so.2"
55 elif re.search("i.86", targetarch):
56 dynamic_loader = "${base_libdir}/ld-linux.so.2"
57 elif targetarch == "arm":
58 dynamic_loader = "${base_libdir}/ld-linux${@['-armhf', ''][d.getVar('TARGET_FPU') == 'soft']}.so.3"
59 elif targetarch.startswith("aarch64"):
60 dynamic_loader = "${base_libdir}/ld-linux-aarch64${ARMPKGSFX_ENDIAN_64}.so.1"
61 elif targetarch.startswith("riscv64"):
62 dynamic_loader = "${base_libdir}/ld-linux-riscv64-lp64${@['d', ''][d.getVar('TARGET_FPU') == 'soft']}.so.1"
63 elif targetarch.startswith("riscv32"):
64 dynamic_loader = "${base_libdir}/ld-linux-riscv32-ilp32${@['d', ''][d.getVar('TARGET_FPU') == 'soft']}.so.1"
65 return dynamic_loader
66
67def get_linuxloader(d):
68 overrides = d.getVar("OVERRIDES").split(":")
69
70 if "libc-baremetal" in overrides:
71 return "NotSupported"
72
73 if "libc-musl" in overrides:
74 dynamic_loader = get_musl_loader(d)
75 else:
76 dynamic_loader = get_glibc_loader(d)
77 return dynamic_loader
78
79get_linuxloader[vardepvalue] = "${@get_linuxloader(d)}"
80get_musl_loader[vardepvalue] = "${@get_musl_loader(d)}"
81get_musl_loader_arch[vardepvalue] = "${@get_musl_loader_arch(d)}"
82get_glibc_loader[vardepvalue] = "${@get_glibc_loader(d)}"