blob: 2ea1b62254c9e691d9aedd59ac79c237791cc7b1 [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"
Patrick Williamsb542dec2023-06-09 01:26:37 -050049 elif targetarch.startswith("loongarch64"):
50 dynamic_loader = "${base_libdir}/ld-linux-loongarch-lp64d.so.1"
Patrick Williams92b42cb2022-09-03 06:53:57 -050051 elif targetarch == "powerpc64le":
52 dynamic_loader = "${base_libdir}/ld64.so.2"
53 elif targetarch == "powerpc64":
54 dynamic_loader = "${base_libdir}/ld64.so.1"
55 elif targetarch == "x86_64":
56 dynamic_loader = "${base_libdir}/ld-linux-x86-64.so.2"
57 elif re.search("i.86", targetarch):
58 dynamic_loader = "${base_libdir}/ld-linux.so.2"
59 elif targetarch == "arm":
60 dynamic_loader = "${base_libdir}/ld-linux${@['-armhf', ''][d.getVar('TARGET_FPU') == 'soft']}.so.3"
61 elif targetarch.startswith("aarch64"):
62 dynamic_loader = "${base_libdir}/ld-linux-aarch64${ARMPKGSFX_ENDIAN_64}.so.1"
63 elif targetarch.startswith("riscv64"):
64 dynamic_loader = "${base_libdir}/ld-linux-riscv64-lp64${@['d', ''][d.getVar('TARGET_FPU') == 'soft']}.so.1"
65 elif targetarch.startswith("riscv32"):
66 dynamic_loader = "${base_libdir}/ld-linux-riscv32-ilp32${@['d', ''][d.getVar('TARGET_FPU') == 'soft']}.so.1"
67 return dynamic_loader
68
69def get_linuxloader(d):
70 overrides = d.getVar("OVERRIDES").split(":")
71
72 if "libc-baremetal" in overrides:
73 return "NotSupported"
74
75 if "libc-musl" in overrides:
76 dynamic_loader = get_musl_loader(d)
77 else:
78 dynamic_loader = get_glibc_loader(d)
79 return dynamic_loader
80
81get_linuxloader[vardepvalue] = "${@get_linuxloader(d)}"
82get_musl_loader[vardepvalue] = "${@get_musl_loader(d)}"
83get_musl_loader_arch[vardepvalue] = "${@get_musl_loader_arch(d)}"
84get_glibc_loader[vardepvalue] = "${@get_glibc_loader(d)}"