mirror of
https://github.com/frida/releng.git
synced 2026-11-07 09:36:02 -10:00
Make bare addressing an explicit config tag
Read the config as a set of tags, thus a bare flavor says in its name whether its code is position-independent: softfloat becomes softfloat_nopic, and softfloat_msabi becomes softfloat_pic_msabi. This also gives x86 a position-independent flavor, which it had no way to name before. A bare target is soft-float in each case now, thus remove the newlib path that the other targets took.
This commit is contained in:
1 parent
de9af916dc
commit
0cb8c69c7c
3 files changed
+26
-29
No files matched your search
@@ -27,9 +27,8 @@ dependencies = [
|
||||
]
|
||||
|
||||
[picolibc]
|
||||
# The C library for the soft-float bare-metal target. The plain none-arm64 SDK gets
|
||||
# newlib from its GCC toolchain, but newlib has no soft-float build for arm64, and
|
||||
# this flavour is -mabi=aapcs-soft throughout.
|
||||
# The C library for the bare-metal targets. They are all soft-float, and newlib has
|
||||
# no soft-float build for arm64, where the flavor is -mabi=aapcs-soft throughout.
|
||||
when = "machine.os == 'none' and machine.config_is_softfloat"
|
||||
name = "picolibc"
|
||||
version = "d755323372f4abd92a622fd2d80edf1d1c45c548"
|
||||
|
||||
+11
-22
@@ -40,7 +40,7 @@ def init_machine_config(machine: MachineSpec,
|
||||
options["b_lundef"] = str(not allow_undefined_symbols).lower()
|
||||
softfloat = machine.config_is_softfloat
|
||||
if softfloat:
|
||||
options["b_staticpic"] = "false"
|
||||
options["b_staticpic"] = str(machine.config_is_pic).lower()
|
||||
|
||||
binaries = config["binaries"]
|
||||
cc = None
|
||||
@@ -228,15 +228,17 @@ def init_machine_config(machine: MachineSpec,
|
||||
common_flags += ARCH_COMMON_FLAGS_UNIX.get(machine.arch, [])
|
||||
if not softfloat:
|
||||
c_like_flags += ARCH_C_LIKE_FLAGS_UNIX.get(machine.arch, [])
|
||||
bare_softfloat = machine.os == "none" and softfloat
|
||||
bare = machine.os == "none"
|
||||
if softfloat:
|
||||
common_flags += ARCH_SOFTFLOAT_FLAGS_UNIX.get(machine.arch, [])
|
||||
common_flags += BARE_ADDRESSING[machine.config]
|
||||
model = BARE_CODE_MODELS.get(machine.config)
|
||||
if machine.arch == "x86_64" and model is not None:
|
||||
common_flags += [f"-mcmodel={model}"]
|
||||
common_flags += ["-fPIC"] if machine.config_is_pic else ["-fno-pic"]
|
||||
# A Linux module is mapped into the top 2GB and is built absolute, the kernel
|
||||
# code model saying so. A position-independent image goes where the host puts
|
||||
# it, thus it keeps the default model.
|
||||
if machine.arch == "x86_64" and not machine.config_is_pic:
|
||||
common_flags += ["-mcmodel=kernel"]
|
||||
|
||||
if bare_softfloat:
|
||||
if bare:
|
||||
target_arch = BARE_TARGET_ARCHS.get(machine.arch, machine.cpu_family)
|
||||
common_flags += [f"--target={target_arch}-none-elf"]
|
||||
# picolibc is a package like any other here, so the libc lives in the
|
||||
@@ -260,7 +262,7 @@ def init_machine_config(machine: MachineSpec,
|
||||
"-fdata-sections",
|
||||
]
|
||||
|
||||
if bare_softfloat:
|
||||
if bare:
|
||||
# The host's GNU ld cannot be told to target this. Name the runtime
|
||||
# ourselves too: clang would look for its own copy beside the compiler,
|
||||
# and the one that matches this ABI is the one in the sysroot.
|
||||
@@ -288,17 +290,13 @@ def init_machine_config(machine: MachineSpec,
|
||||
|
||||
if linker_flavor == "apple":
|
||||
linker_flags += ["-Wl,-dead_strip"]
|
||||
elif not bare_softfloat:
|
||||
elif not bare:
|
||||
# Would leave a link with no entry point holding on to nothing at all,
|
||||
# and every configure check that links would then trivially pass.
|
||||
linker_flags += ["-Wl,--gc-sections"]
|
||||
if linker_flavor == "gnu-gold":
|
||||
linker_flags += ["-Wl,--icf=all"]
|
||||
|
||||
# newlib's syscall stubs; the soft-float flavour brings picolibc instead.
|
||||
if machine.os == "none" and not softfloat:
|
||||
linker_flags += ["-specs=nosys.specs"]
|
||||
|
||||
constants = config["constants"]
|
||||
constants["common_flags"] = strv_to_meson(common_flags)
|
||||
constants["c_like_flags"] = strv_to_meson(c_like_flags)
|
||||
@@ -472,15 +470,6 @@ ARCH_SOFTFLOAT_FLAGS_UNIX = {
|
||||
],
|
||||
}
|
||||
|
||||
BARE_ADDRESSING = {
|
||||
"softfloat": ["-fno-pic"],
|
||||
"softfloat_msabi": ["-fPIC"],
|
||||
}
|
||||
|
||||
BARE_CODE_MODELS = {
|
||||
"softfloat": "kernel",
|
||||
}
|
||||
|
||||
BARE_TARGET_ARCHS = {
|
||||
"x86": "i686",
|
||||
}
|
||||
|
||||
+13
-4
@@ -3,7 +3,7 @@ from dataclasses import dataclass
|
||||
import platform
|
||||
import re
|
||||
import subprocess
|
||||
from typing import List, Optional
|
||||
from typing import FrozenSet, List, Optional
|
||||
|
||||
if platform.system() == "Windows":
|
||||
import ctypes
|
||||
@@ -141,13 +141,23 @@ class MachineSpec:
|
||||
parts += [self.config]
|
||||
return "-".join(parts)
|
||||
|
||||
@property
|
||||
def config_tags(self) -> FrozenSet[str]:
|
||||
if self.config is None:
|
||||
return frozenset()
|
||||
return frozenset(self.config.split("_"))
|
||||
|
||||
@property
|
||||
def config_is_softfloat(self) -> bool:
|
||||
return self.config in SOFTFLOAT_CONFIGS
|
||||
return "softfloat" in self.config_tags
|
||||
|
||||
@property
|
||||
def config_is_pic(self) -> bool:
|
||||
return "pic" in self.config_tags
|
||||
|
||||
@property
|
||||
def config_is_msabi(self) -> bool:
|
||||
return self.config == "softfloat_msabi"
|
||||
return "msabi" in self.config_tags
|
||||
|
||||
@property
|
||||
def config_is_optimized(self) -> bool:
|
||||
@@ -416,4 +426,3 @@ PROCESSOR_ARCHITECTURE_ARM64 = 12
|
||||
IMAGE_FILE_MACHINE_AMD64 = 0x8664
|
||||
IMAGE_FILE_MACHINE_ARM64 = 0xAA64
|
||||
|
||||
SOFTFLOAT_CONFIGS = {"softfloat", "softfloat_msabi"}
|
||||
Reference in new issue
Block a user