blob: ec0e0556dd859defe221b8db1001d762933418cc [file] [log] [blame]
Andrew Geissler82c905d2020-04-13 13:39:40 -05001def get_musl_loader_arch(d):
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08002 import re
Andrew Geissler82c905d2020-04-13 13:39:40 -05003 ldso_arch = None
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05004
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08005 targetarch = d.getVar("TARGET_ARCH")
6 if targetarch.startswith("microblaze"):
Andrew Geissler82c905d2020-04-13 13:39:40 -05007 ldso_arch = "microblaze${@bb.utils.contains('TUNE_FEATURES', 'bigendian', '', 'el' ,d)}"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08008 elif targetarch.startswith("mips"):
Andrew Geissler82c905d2020-04-13 13:39:40 -05009 ldso_arch = "mips${ABIEXTENSION}${MIPSPKGSFX_BYTE}${MIPSPKGSFX_R6}${MIPSPKGSFX_ENDIAN}${@['', '-sf'][d.getVar('TARGET_FPU') == 'soft']}"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080010 elif targetarch == "powerpc":
Andrew Geissler82c905d2020-04-13 13:39:40 -050011 ldso_arch = "powerpc${@['', '-sf'][d.getVar('TARGET_FPU') == 'soft']}"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080012 elif targetarch == "powerpc64":
Andrew Geissler82c905d2020-04-13 13:39:40 -050013 ldso_arch = "powerpc64"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080014 elif targetarch == "x86_64":
Andrew Geissler82c905d2020-04-13 13:39:40 -050015 ldso_arch = "x86_64"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080016 elif re.search("i.86", targetarch):
Andrew Geissler82c905d2020-04-13 13:39:40 -050017 ldso_arch = "i386"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080018 elif targetarch.startswith("arm"):
Andrew Geissler82c905d2020-04-13 13:39:40 -050019 ldso_arch = "arm${ARMPKGSFX_ENDIAN}${ARMPKGSFX_EABI}"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080020 elif targetarch.startswith("aarch64"):
Andrew Geissler82c905d2020-04-13 13:39:40 -050021 ldso_arch = "aarch64${ARMPKGSFX_ENDIAN_64}"
Brad Bishop08902b02019-08-20 09:16:51 -040022 elif targetarch.startswith("riscv64"):
Andrew Geissler82c905d2020-04-13 13:39:40 -050023 ldso_arch = "riscv64${@['', '-sf'][d.getVar('TARGET_FPU') == 'soft']}"
24 return ldso_arch
25
26def get_musl_loader(d):
27 import re
28 return "/lib/ld-musl-" + get_musl_loader_arch(d) + ".so.1"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050029
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080030def get_glibc_loader(d):
31 import re
Brad Bishopd7bf8c12018-02-25 22:55:05 -050032
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080033 dynamic_loader = None
34 targetarch = d.getVar("TARGET_ARCH")
35 if targetarch in ["powerpc", "microblaze"]:
36 dynamic_loader = "${base_libdir}/ld.so.1"
37 elif targetarch in ["mipsisa32r6el", "mipsisa32r6", "mipsisa64r6el", "mipsisa64r6"]:
38 dynamic_loader = "${base_libdir}/ld-linux-mipsn8.so.1"
39 elif targetarch.startswith("mips"):
40 dynamic_loader = "${base_libdir}/ld.so.1"
41 elif targetarch == "powerpc64":
42 dynamic_loader = "${base_libdir}/ld64.so.1"
43 elif targetarch == "x86_64":
44 dynamic_loader = "${base_libdir}/ld-linux-x86-64.so.2"
45 elif re.search("i.86", targetarch):
46 dynamic_loader = "${base_libdir}/ld-linux.so.2"
47 elif targetarch == "arm":
Andrew Geissler82c905d2020-04-13 13:39:40 -050048 dynamic_loader = "${base_libdir}/ld-linux${@['-armhf', ''][d.getVar('TARGET_FPU') == 'soft']}.so.3"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080049 elif targetarch.startswith("aarch64"):
50 dynamic_loader = "${base_libdir}/ld-linux-aarch64${ARMPKGSFX_ENDIAN_64}.so.1"
Brad Bishop08902b02019-08-20 09:16:51 -040051 elif targetarch.startswith("riscv64"):
52 dynamic_loader = "${base_libdir}/ld-linux-riscv64-lp64${@['d', ''][d.getVar('TARGET_FPU') == 'soft']}.so.1"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080053 return dynamic_loader
54
55def get_linuxloader(d):
56 overrides = d.getVar("OVERRIDES").split(":")
57
58 if "libc-baremetal" in overrides:
59 return None
60
61 if "libc-musl" in overrides:
62 dynamic_loader = get_musl_loader(d)
63 else:
64 dynamic_loader = get_glibc_loader(d)
65 return dynamic_loader
66
67get_linuxloader[vardepvalue] = "${@get_linuxloader(d)}"
68get_musl_loader[vardepvalue] = "${@get_musl_loader(d)}"
Andrew Geissler82c905d2020-04-13 13:39:40 -050069get_musl_loader_arch[vardepvalue] = "${@get_musl_loader_arch(d)}"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080070get_glibc_loader[vardepvalue] = "${@get_glibc_loader(d)}"