From 4d636ea593d1bc2d532da28944b8d3186266bd97 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Sun, 6 Aug 2023 08:20:12 +0800 Subject: [PATCH] Upgrade to LLD 14 Previous linker versions had inserted some zero padding bytes between the ELF headers and the first section, but LLD 14 does not anymore. Hard-coding the offset of the first section in ksupport.elf manually isn't ideal; we should probably parse the ELF program headers instead when first setting up the kernel CPU. --- artiq/firmware/ksupport/glue.c | 2 +- artiq/firmware/libproto_artiq/kernel_proto.rs | 5 ++++- flake.nix | 14 +++++++------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/artiq/firmware/ksupport/glue.c b/artiq/firmware/ksupport/glue.c index a15491689..d43388769 100644 --- a/artiq/firmware/ksupport/glue.c +++ b/artiq/firmware/ksupport/glue.c @@ -17,7 +17,7 @@ void send_to_rtio_log(struct slice data); #define KERNELCPU_EXEC_ADDRESS 0x45000000 #define KERNELCPU_PAYLOAD_ADDRESS 0x45060000 #define KERNELCPU_LAST_ADDRESS 0x4fffffff -#define KSUPPORT_HEADER_SIZE 0x80 +#define KSUPPORT_HEADER_SIZE 0x74 FILE *stderr; diff --git a/artiq/firmware/libproto_artiq/kernel_proto.rs b/artiq/firmware/libproto_artiq/kernel_proto.rs index cc17147cd..2ecb39c3b 100644 --- a/artiq/firmware/libproto_artiq/kernel_proto.rs +++ b/artiq/firmware/libproto_artiq/kernel_proto.rs @@ -5,7 +5,10 @@ use dyld; pub const KERNELCPU_EXEC_ADDRESS: usize = 0x45000000; pub const KERNELCPU_PAYLOAD_ADDRESS: usize = 0x45060000; pub const KERNELCPU_LAST_ADDRESS: usize = 0x4fffffff; -pub const KSUPPORT_HEADER_SIZE: usize = 0x80; + +// Must match the offset of the first (starting at KERNELCPU_EXEC_ADDRESS) +// section in ksupport.elf. +pub const KSUPPORT_HEADER_SIZE: usize = 0x74; #[derive(Debug)] pub enum Message<'a> { diff --git a/flake.nix b/flake.nix index 33b5df443..edcee7540 100644 --- a/flake.nix +++ b/flake.nix @@ -124,7 +124,7 @@ nativeBuildInputs = [ pkgs.qt5.wrapQtAppsHook ]; # keep llvm_x and lld_x in sync with llvmlite - propagatedBuildInputs = [ pkgs.llvm_11 pkgs.lld_11 sipyco.packages.x86_64-linux.sipyco pythonparser pkgs.qt5.qtsvg artiq-comtools.packages.x86_64-linux.artiq-comtools ] + propagatedBuildInputs = [ pkgs.llvm_11 pkgs.lld_14 sipyco.packages.x86_64-linux.sipyco pythonparser pkgs.qt5.qtsvg artiq-comtools.packages.x86_64-linux.artiq-comtools ] ++ (with pkgs.python3Packages; [ llvmlite pyqtgraph pygit2 numpy dateutil scipy prettytable pyserial levenshtein h5py pyqt5 qasync tqdm lmdb jsonschema ]); dontWrapQtApps = true; @@ -147,10 +147,10 @@ "--set FONTCONFIG_FILE ${pkgs.fontconfig.out}/etc/fonts/fonts.conf" ]; - # FIXME: automatically propagate lld_11 llvm_11 dependencies + # FIXME: automatically propagate lld_14 llvm_11 dependencies # cacert is required in the check stage only, as certificates are to be # obtained from system elsewhere - nativeCheckInputs = [ pkgs.lld_11 pkgs.llvm_11 libartiq-support pkgs.lit outputcheck pkgs.cacert ]; + nativeCheckInputs = [ pkgs.lld_14 pkgs.llvm_11 libartiq-support pkgs.lit outputcheck pkgs.cacert ]; checkPhase = '' python -m unittest discover -v artiq.test @@ -229,7 +229,7 @@ pkgs.cargo-xbuild pkgs.llvmPackages_11.clang-unwrapped pkgs.llvm_11 - pkgs.lld_11 + pkgs.lld_14 vivado rustPlatform.cargoSetupHook ]; @@ -392,7 +392,7 @@ pkgs.cargo-xbuild pkgs.llvmPackages_11.clang-unwrapped pkgs.llvm_11 - pkgs.lld_11 + pkgs.lld_14 # To manually run compiler tests: pkgs.lit outputcheck @@ -420,7 +420,7 @@ pkgs.cargo-xbuild pkgs.llvmPackages_11.clang-unwrapped pkgs.llvm_11 - pkgs.lld_11 + pkgs.lld_14 packages.x86_64-linux.vivado packages.x86_64-linux.openocd-bscanspi ]; @@ -454,7 +454,7 @@ buildInputs = [ (pkgs.python3.withPackages(ps: with packages.x86_64-linux; [ artiq ps.paramiko ])) pkgs.llvm_11 - pkgs.lld_11 + pkgs.lld_14 pkgs.openssh packages.x86_64-linux.openocd-bscanspi # for the bscanspi bitstreams ];