From 667f36a2e7654e2ba6240de0648e11ea22db6d76 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sun, 29 May 2022 08:43:25 +0800 Subject: [PATCH 01/11] gui: fix Python 3.10 PyQt float/int issues. Closes #1887 --- artiq/browser/files.py | 2 +- artiq/gui/scanwidget.py | 18 +++++++++--------- artiq/gui/waitingspinnerwidget.py | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/artiq/browser/files.py b/artiq/browser/files.py index 339c12d34..46bf10b3f 100644 --- a/artiq/browser/files.py +++ b/artiq/browser/files.py @@ -71,7 +71,7 @@ class ZoomIconView(QtWidgets.QListView): self._char_width = QtGui.QFontMetrics(self.font()).averageCharWidth() self.setViewMode(self.IconMode) w = self._char_width*self.default_size - self.setIconSize(QtCore.QSize(w, w*self.aspect)) + self.setIconSize(QtCore.QSize(w, int(w*self.aspect))) self.setFlow(self.LeftToRight) self.setResizeMode(self.Adjust) self.setWrapping(True) diff --git a/artiq/gui/scanwidget.py b/artiq/gui/scanwidget.py index 20e161d97..e3231c6ab 100644 --- a/artiq/gui/scanwidget.py +++ b/artiq/gui/scanwidget.py @@ -49,7 +49,7 @@ class ScanWidget(QtWidgets.QWidget): return self.minimumSizeHint() def minimumSizeHint(self): - return QtCore.QSize(2.5*3*self._labelSize.width(), + return QtCore.QSize(int(2.5*3*self._labelSize.width()), 4*self._labelSize.height()) def _axisToPixel(self, val): @@ -214,7 +214,7 @@ class ScanWidget(QtWidgets.QWidget): self._setView(left, scale) def wheelEvent(self, ev): - y = ev.angleDelta().y()/120. + y = round(ev.angleDelta().y()/120.) if not y: return if ev.modifiers() & QtCore.Qt.ShiftModifier: @@ -252,22 +252,22 @@ class ScanWidget(QtWidgets.QWidget): for t, l in zip(ticks, labels): t = self._axisToPixel(t) - painter.drawText(t - len(l)/2*avgCharWidth, 0, l) - painter.drawLine(t, descent, t, lineSpacing/2) - painter.translate(0, lineSpacing/2) + painter.drawText(int(t - len(l)/2*avgCharWidth), 0, l) + painter.drawLine(int(t), descent, int(t), int(lineSpacing/2)) + painter.translate(0, int(lineSpacing/2)) painter.drawLine(0, 0, self.width(), 0) for p in np.linspace(self._axisToPixel(self._start), self._axisToPixel(self._stop), self._num): - painter.drawLine(p, 0, p, lineSpacing/2) - painter.translate(0, lineSpacing/2) + painter.drawLine(int(p), 0, int(p), int(lineSpacing/2)) + painter.translate(0, int(lineSpacing/2)) for x, c in (self._start, QtCore.Qt.blue), (self._stop, QtCore.Qt.red): x = self._axisToPixel(x) painter.setPen(c) painter.setBrush(c) painter.drawPolygon(*(QtCore.QPointF(*i) for i in [ - (x, 0), (x - lineSpacing/2, lineSpacing), - (x + lineSpacing/2, lineSpacing)])) + (int(x), 0), (int(x - lineSpacing/2), lineSpacing), + (int(x + lineSpacing/2), lineSpacing)])) diff --git a/artiq/gui/waitingspinnerwidget.py b/artiq/gui/waitingspinnerwidget.py index 6771bdbfe..6967e6dea 100644 --- a/artiq/gui/waitingspinnerwidget.py +++ b/artiq/gui/waitingspinnerwidget.py @@ -75,7 +75,7 @@ class QtWaitingSpinner(QWidget): color = self.currentLineColor(distance, self._numberOfLines, self._trailFadePercentage, self._minimumTrailOpacity, self._color) painter.setBrush(color) - painter.drawRoundedRect(QRect(0, -self._lineWidth / 2, self._lineLength, self._lineWidth), self._roundness, + painter.drawRoundedRect(QRect(0, int(-self._lineWidth / 2), self._lineLength, self._lineWidth), self._roundness, self._roundness, Qt.RelativeSize) painter.restore() @@ -160,7 +160,7 @@ class QtWaitingSpinner(QWidget): self.setFixedSize(self.size, self.size) def updateTimer(self): - self._timer.setInterval(1000 / (self._numberOfLines * self._revolutionsPerSecond)) + self._timer.setInterval(int(1000 / (self._numberOfLines * self._revolutionsPerSecond))) def lineCountDistanceFromPrimary(self, current, primary, totalNrOfLines): distance = primary - current From a5b7e958f88c78ba446a4b20de4645b25b0691e3 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 31 May 2022 18:24:47 +0800 Subject: [PATCH 02/11] flake: update dependencies --- flake.lock | 8 ++++---- flake.nix | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index cdc6e364d..512bfebb1 100644 --- a/flake.lock +++ b/flake.lock @@ -41,16 +41,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1653229824, - "narHash": "sha256-klSCYMpR4TqWYoTD/xZ2qM9UIPRFC6pK+S/kJuVLbFw=", + "lastModified": 1653920503, + "narHash": "sha256-BBeCZwZImtjP3oYy4WogkQYy5OxNyfNciVSc1AfZgLQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "06db2e2197401b74fcf82d4e84be15b0b5851c7b", + "rev": "a634c8f6c1fbf9b9730e01764999666f3436f10a", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-21.11", + "ref": "nixos-22.05", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index 3449f54bb..ee2eddc81 100644 --- a/flake.nix +++ b/flake.nix @@ -1,7 +1,7 @@ { description = "A leading-edge control system for quantum information experiments"; - inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-21.11; + inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-22.05; inputs.mozilla-overlay = { url = github:mozilla/nixpkgs-mozilla; flake = false; }; inputs.sipyco.url = github:m-labs/sipyco; inputs.sipyco.inputs.nixpkgs.follows = "nixpkgs"; @@ -331,7 +331,7 @@ sha256 = "sha256-YgUsl4/FohfsOncM4uiz/3c6g2ZN4oZ0y5vV/2Skwqg="; fetchSubmodules = true; }; - patches = oa.patches or [] ++ [ + patches = [ (pkgs.fetchurl { url = "https://git.m-labs.hk/M-Labs/nix-scripts/raw/commit/575ef05cd554c239e4cc8cb97ae4611db458a80d/artiq-fast/pkgs/openocd-jtagspi.diff"; sha256 = "0g3crk8gby42gm661yxdcgapdi8sp050l5pb2d0yjfic7ns9cw81"; From 6d46c886d79849433e25efe909b38889c24e2e0b Mon Sep 17 00:00:00 2001 From: occheung Date: Tue, 31 May 2022 16:45:11 +0800 Subject: [PATCH 03/11] ld.lld: translate TARGET2 reloc to relative --- artiq/compiler/targets.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/artiq/compiler/targets.py b/artiq/compiler/targets.py index 20543b6a6..f25d8f77d 100644 --- a/artiq/compiler/targets.py +++ b/artiq/compiler/targets.py @@ -74,6 +74,8 @@ class Target: LLVM target data layout, e.g. ``"E-m:e-p:32:32-i64:32-f64:32-v64:32-v128:32-a:0:32-n32"`` :var features: (list of string) LLVM target CPU features, e.g. ``["mul", "div", "ffl1"]`` + :var additional_linker_options: (list of string) + Linker options for the target in addition to the target-independent ones, e.g. ``["--target2=rel"]`` :var print_function: (string) Name of a formatted print functions (with the signature of ``printf``) provided by the target, e.g. ``"printf"``. @@ -83,6 +85,7 @@ class Target: triple = "unknown" data_layout = "" features = [] + additional_linker_options = [] print_function = "printf" now_pinning = True @@ -181,6 +184,7 @@ class Target: def link(self, objects): """Link the relocatable objects into a shared library for this target.""" with RunTool([self.tool_ld, "-shared", "--eh-frame-hdr"] + + self.additional_linker_options + ["-T" + os.path.join(os.path.dirname(__file__), "kernel.ld")] + ["{{obj{}}}".format(index) for index in range(len(objects))] + ["-x"] + @@ -265,6 +269,7 @@ class RV32IMATarget(Target): triple = "riscv32-unknown-linux" data_layout = "e-m:e-p:32:32-i64:64-n32-S128" features = ["m", "a"] + additional_linker_options = [] print_function = "core_log" now_pinning = True @@ -277,6 +282,7 @@ class RV32GTarget(Target): triple = "riscv32-unknown-linux" data_layout = "e-m:e-p:32:32-i64:64-n32-S128" features = ["m", "a", "f", "d"] + additional_linker_options = [] print_function = "core_log" now_pinning = True @@ -289,6 +295,7 @@ class CortexA9Target(Target): triple = "armv7-unknown-linux-gnueabihf" data_layout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" features = ["dsp", "fp16", "neon", "vfp3"] + additional_linker_options = ["--target2=rel"] print_function = "core_log" now_pinning = False From 8bf6bc4d1fdc92065b866d5f15e7593cf21a3ab3 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 31 May 2022 20:59:21 +0800 Subject: [PATCH 04/11] flake: update dependencies --- flake.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index 512bfebb1..08de34c19 100644 --- a/flake.lock +++ b/flake.lock @@ -10,11 +10,11 @@ ] }, "locked": { - "lastModified": 1653635602, - "narHash": "sha256-8Osaeuo5/Yq4sU4mhsIXwmy7ZX3iDBbAAZF3lu1+KdQ=", + "lastModified": 1654001815, + "narHash": "sha256-wMVXlnMh64cWfG0LNpDExAGL5iHNoCstmVkOVr31NSE=", "owner": "m-labs", "repo": "artiq-comtools", - "rev": "accc6dd0ca1c1c240b906b14c5cb13098a14906b", + "rev": "2b4899ecddfaac160f92341377262ac61d6329b7", "type": "github" }, "original": { @@ -73,11 +73,11 @@ ] }, "locked": { - "lastModified": 1653633179, - "narHash": "sha256-xyHQ77RXI9Zq9is+9laArq1HnlyubozL+Ht9BEQGXow=", + "lastModified": 1654001788, + "narHash": "sha256-vUSep33N66pcvy7ojnBLSmyyVfN20+WZvP/c4b0T2CI=", "owner": "m-labs", "repo": "sipyco", - "rev": "438f649864c58fa2eb213030a336864bba3a18a8", + "rev": "951de4cf198419712ea3f52991d8f9293f3d9d15", "type": "github" }, "original": { From ca614a3eea94233d23c30882be0366efe21f74ba Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 31 May 2022 22:25:43 +0800 Subject: [PATCH 05/11] use asyncio get/new_event_loop as recommended --- artiq/frontend/aqctl_corelog.py | 3 ++- artiq/frontend/aqctl_moninj_proxy.py | 3 ++- artiq/frontend/artiq_client.py | 3 ++- artiq/frontend/artiq_master.py | 3 ++- artiq/frontend/artiq_rtiomon.py | 3 ++- artiq/test/coredevice/test_moninj.py | 3 ++- flake.lock | 12 ++++++------ 7 files changed, 18 insertions(+), 12 deletions(-) diff --git a/artiq/frontend/aqctl_corelog.py b/artiq/frontend/aqctl_corelog.py index c86c276d5..ca0827585 100755 --- a/artiq/frontend/aqctl_corelog.py +++ b/artiq/frontend/aqctl_corelog.py @@ -76,7 +76,8 @@ def main(): args = get_argparser().parse_args() common_args.init_logger_from_args(args) - loop = asyncio.get_event_loop() + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) try: signal_handler = SignalHandler() signal_handler.setup() diff --git a/artiq/frontend/aqctl_moninj_proxy.py b/artiq/frontend/aqctl_moninj_proxy.py index 5d7aca2a3..54d8d0833 100755 --- a/artiq/frontend/aqctl_moninj_proxy.py +++ b/artiq/frontend/aqctl_moninj_proxy.py @@ -196,7 +196,8 @@ def main(): bind_address = common_args.bind_address_from_args(args) - loop = asyncio.get_event_loop() + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) try: signal_handler = SignalHandler() signal_handler.setup() diff --git a/artiq/frontend/artiq_client.py b/artiq/frontend/artiq_client.py index 993fe0ee4..8601fed77 100755 --- a/artiq/frontend/artiq_client.py +++ b/artiq/frontend/artiq_client.py @@ -245,7 +245,8 @@ def _show_datasets(datasets): def _run_subscriber(host, port, subscriber): - loop = asyncio.get_event_loop() + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) try: loop.run_until_complete(subscriber.connect(host, port)) try: diff --git a/artiq/frontend/artiq_master.py b/artiq/frontend/artiq_master.py index 2b8893d07..42a7a0a98 100755 --- a/artiq/frontend/artiq_master.py +++ b/artiq/frontend/artiq_master.py @@ -74,7 +74,8 @@ class MasterConfig: def main(): args = get_argparser().parse_args() log_forwarder = init_log(args) - loop = asyncio.get_event_loop() + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) atexit.register(loop.close) signal_handler = SignalHandler() signal_handler.setup() diff --git a/artiq/frontend/artiq_rtiomon.py b/artiq/frontend/artiq_rtiomon.py index 8649f8d5f..653063ce1 100755 --- a/artiq/frontend/artiq_rtiomon.py +++ b/artiq/frontend/artiq_rtiomon.py @@ -21,7 +21,8 @@ def get_argparser(): def main(): args = get_argparser().parse_args() - loop = asyncio.get_event_loop() + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) try: signal_handler = SignalHandler() signal_handler.setup() diff --git a/artiq/test/coredevice/test_moninj.py b/artiq/test/coredevice/test_moninj.py index 83786a8a1..092f3f7d6 100644 --- a/artiq/test/coredevice/test_moninj.py +++ b/artiq/test/coredevice/test_moninj.py @@ -28,7 +28,8 @@ class MonInjTest(ExperimentCase): def injection_status_cb(channel, override, value): injection_statuses.append((channel, override, value)) - loop = asyncio.get_event_loop() + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) try: moninj_comm = CommMonInj(monitor_cb, injection_status_cb) loop.run_until_complete(moninj_comm.connect(core_host)) diff --git a/flake.lock b/flake.lock index 08de34c19..4a5d51030 100644 --- a/flake.lock +++ b/flake.lock @@ -10,11 +10,11 @@ ] }, "locked": { - "lastModified": 1654001815, - "narHash": "sha256-wMVXlnMh64cWfG0LNpDExAGL5iHNoCstmVkOVr31NSE=", + "lastModified": 1654007592, + "narHash": "sha256-vaDFhE1ItjqtIcinC/6RAJGbj44pxxMUEeQUa3FtgEE=", "owner": "m-labs", "repo": "artiq-comtools", - "rev": "2b4899ecddfaac160f92341377262ac61d6329b7", + "rev": "cb73281154656ee8f74db1866859e31bf42755cd", "type": "github" }, "original": { @@ -73,11 +73,11 @@ ] }, "locked": { - "lastModified": 1654001788, - "narHash": "sha256-vUSep33N66pcvy7ojnBLSmyyVfN20+WZvP/c4b0T2CI=", + "lastModified": 1654006751, + "narHash": "sha256-OWAnoTCutvTQcYdtdtLQuL6uRtG+7Jz7sbRhcScv8bo=", "owner": "m-labs", "repo": "sipyco", - "rev": "951de4cf198419712ea3f52991d8f9293f3d9d15", + "rev": "b3d03a94c751a24769c54a61a0dbe9d6af52dade", "type": "github" }, "original": { From 50495097e5d7798b84e42f0222dec7bc533cdfd0 Mon Sep 17 00:00:00 2001 From: occheung Date: Wed, 1 Jun 2022 12:23:29 +0800 Subject: [PATCH 06/11] dyld: rename pltrel to jmprel nac3ld will not generate PLT & its relocation section. There might not be a pltrel in that case. On the other hand, rebinding will not be limited to the symbols in the PLT when linked with nac3ld. Thus the renaming. --- artiq/firmware/libdyld/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/artiq/firmware/libdyld/lib.rs b/artiq/firmware/libdyld/lib.rs index 1d89edaee..9d906034f 100644 --- a/artiq/firmware/libdyld/lib.rs +++ b/artiq/firmware/libdyld/lib.rs @@ -86,7 +86,7 @@ pub struct Library<'a> { image_sz: usize, strtab: &'a [u8], symtab: &'a [Elf32_Sym], - pltrel: &'a [Elf32_Rela], + jmprel: &'a [Elf32_Rela], hash_bucket: &'a [Elf32_Word], hash_chain: &'a [Elf32_Word], } @@ -136,9 +136,9 @@ impl<'a> Library<'a> { Ok(unsafe { *ptr = value }) } - // This is unsafe because it mutates global data (the PLT). + // This is unsafe because it mutates global data (instructions). pub unsafe fn rebind(&self, name: &[u8], addr: Elf32_Word) -> Result<(), Error<'a>> { - for rela in self.pltrel.iter() { + for rela in self.jmprel.iter() { match ELF32_R_TYPE(rela.r_info) { R_RISCV_32 | R_RISCV_JUMP_SLOT => { let sym = self.symtab.get(ELF32_R_SYM(rela.r_info) as usize) @@ -328,7 +328,7 @@ impl<'a> Library<'a> { image_sz: image.len(), strtab: strtab, symtab: symtab, - pltrel: pltrel, + jmprel: if pltrel.is_empty() { rela } else { pltrel }, hash_bucket: &hash[..nbucket], hash_chain: &hash[nbucket..nbucket + nchain], }; From 872f8f039f307908fe482018c05f509e739a6a86 Mon Sep 17 00:00:00 2001 From: occheung Date: Wed, 1 Jun 2022 12:30:56 +0800 Subject: [PATCH 07/11] dyld: support additional RV32 reloc types The support of LO12 type requires the runtime linker to find the corresponding HI20 symbol. resolve_rela needs the entire relocation section for that. --- artiq/firmware/libdyld/lib.rs | 100 +++++++++++++++++++++++++--------- 1 file changed, 75 insertions(+), 25 deletions(-) diff --git a/artiq/firmware/libdyld/lib.rs b/artiq/firmware/libdyld/lib.rs index 9d906034f..9ace28ed4 100644 --- a/artiq/firmware/libdyld/lib.rs +++ b/artiq/firmware/libdyld/lib.rs @@ -133,7 +133,36 @@ impl<'a> Library<'a> { } let ptr = (self.image_off + rela.r_offset) as *mut Elf32_Addr; - Ok(unsafe { *ptr = value }) + + match ELF32_R_TYPE(rela.r_info) { + R_RISCV_RELATIVE | R_RISCV_32 | R_RISCV_JUMP_SLOT => Ok(unsafe { *ptr = value }), + + R_RISCV_CALL_PLT => { + Ok(unsafe { + *ptr = (*ptr & 0xFFF) | ((value + 0x800) & 0xFFFFF000); + *(ptr.offset(1)) = (*(ptr.offset(1)) & 0xFFFFF) | ((value & 0xFFF) << 20); + }) + } + + R_RISCV_GOT_HI20 => { + Ok(unsafe { + *ptr = (*ptr & 0xFFF) | ((value + 0x800) & 0xFFFFF000) + }) + } + + // We will not use indirect addressing here + // So, just put in the direct address instead of the GOT + // The lower instruction must be changed to addi (typically from lw) + // to make the value treated as the direct address + // Hex encoding of addi (opcode/funct3): 0x13/0 + R_RISCV_PCREL_LO12_I => { + Ok(unsafe { + *ptr = (*ptr & 0xF8F80) | 0x13 | ((value & 0xFFF) << 20); + }) + } + + _ => Err(Error::Parsing("Unsupported relocation")) + } } // This is unsafe because it mutates global data (instructions). @@ -157,35 +186,28 @@ impl<'a> Library<'a> { Ok(()) } - fn resolve_rela(&self, rela: &Elf32_Rela, resolve: &dyn Fn(&[u8]) -> Option) + fn resolve_rela(&self, relas: &[Elf32_Rela], resolve: &dyn Fn(&[u8]) -> Option) -> Result<(), Error<'a>> { - let sym; - if ELF32_R_SYM(rela.r_info) == 0 { - sym = None; - } else { - sym = Some(self.symtab.get(ELF32_R_SYM(rela.r_info) as usize) - .ok_or("symbol out of bounds of symbol table")?) - } + for rela in relas { + let sym; + if ELF32_R_SYM(rela.r_info) == 0 { + sym = None; + } else { + sym = Some(self.symtab.get(ELF32_R_SYM(rela.r_info) as usize) + .ok_or("symbol out of bounds of symbol table")?) + } - let value; - match ELF32_R_TYPE(rela.r_info) { - R_RISCV_NONE => - return Ok(()), - - R_RISCV_RELATIVE => - value = self.image_off + rela.r_addend as Elf32_Word, - - R_RISCV_32 | R_RISCV_JUMP_SLOT => { + let get_symbol_value = |sym: Option<&Elf32_Sym>| { let sym = sym.ok_or("relocation requires an associated symbol")?; let sym_name = self.name_starting_at(sym.st_name as usize)?; // First, try to resolve against itself. match self.lookup(sym_name) { - Some(addr) => value = addr, + Some(addr) => Ok(addr), None => { // Second, call the user-provided function. match resolve(sym_name) { - Some(addr) => value = addr, + Some(addr) => Ok(addr), None => { // We couldn't find it anywhere. return Err(Error::Lookup(sym_name)) @@ -193,12 +215,40 @@ impl<'a> Library<'a> { } } } - } + }; - _ => return Err("unsupported relocation type")? + let value = match ELF32_R_TYPE(rela.r_info) { + R_RISCV_NONE => + return Ok(()), + + R_RISCV_RELATIVE => + self.image_off + rela.r_addend as Elf32_Word, + + R_RISCV_32 | R_RISCV_JUMP_SLOT => { + get_symbol_value(sym)? + } + + R_RISCV_CALL_PLT | R_RISCV_GOT_HI20 => { + let reloc_value = get_symbol_value(sym)?; + reloc_value + rela.r_addend as Elf32_Word - (self.image_off + rela.r_offset) + } + + R_RISCV_PCREL_LO12_I => { + let hi20_reloc_addr = get_symbol_value(sym)?; + let hi20_rela = relas.iter().find(|rela| rela.r_offset == (hi20_reloc_addr - self.image_off)) + .ok_or("corresponding HI20 relocation not found")?; + + let hi20_sym = self.symtab.get(ELF32_R_SYM(hi20_rela.r_info) as usize); + get_symbol_value(hi20_sym)? - hi20_reloc_addr + } + + _ => return Err("unsupported relocation type")? + }; + + self.update_rela(rela, value)?; } - self.update_rela(rela, value) + Ok(()) } pub fn load(data: &[u8], image: &'a mut [u8], resolve: &dyn Fn(&[u8]) -> Option) @@ -343,8 +393,8 @@ impl<'a> Library<'a> { // we never write to the memory they refer to, so it's safe. mem::drop(image); - for r in rela { library.resolve_rela(r, resolve)? } - for r in pltrel { library.resolve_rela(r, resolve)? } + library.resolve_rela(rela, resolve)?; + library.resolve_rela(pltrel, resolve)?; Ok(library) } From f79f7db3a288f589e0da6f8461765980e0b738db Mon Sep 17 00:00:00 2001 From: occheung Date: Wed, 1 Jun 2022 12:33:40 +0800 Subject: [PATCH 08/11] dyld: handle rebind on symbols relocated by CALL_PLT --- artiq/firmware/libdyld/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/artiq/firmware/libdyld/lib.rs b/artiq/firmware/libdyld/lib.rs index 9ace28ed4..15bbe2548 100644 --- a/artiq/firmware/libdyld/lib.rs +++ b/artiq/firmware/libdyld/lib.rs @@ -179,6 +179,16 @@ impl<'a> Library<'a> { } } + R_RISCV_CALL_PLT => { + let sym = self.symtab.get(ELF32_R_SYM(rela.r_info) as usize) + .ok_or("symbol out of bounds of symbol table")?; + let sym_name = self.name_starting_at(sym.st_name as usize)?; + + if sym_name == name { + self.update_rela(rela, addr - (self.image_off + rela.r_offset))? + } + } + // No associated symbols for other relocation types. _ => () } From 71a37bb408122b4386fe18f7edb2532339b84037 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 1 Jun 2022 20:45:49 +0800 Subject: [PATCH 09/11] doc: switch to wavedrompy --- doc/manual/conf.py | 1 + flake.nix | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/manual/conf.py b/doc/manual/conf.py index d6e6f9a6c..d6c1ae1bf 100644 --- a/doc/manual/conf.py +++ b/doc/manual/conf.py @@ -311,3 +311,4 @@ texinfo_documents = [ # -- Options for sphinxcontrib-wavedrom ----------------------------------- offline_skin_js_path = '_static/default.js' offline_wavedrom_js_path = '_static/WaveDrom.js' +render_using_wavedrompy = True diff --git a/flake.nix b/flake.nix index ee2eddc81..3da033d47 100644 --- a/flake.nix +++ b/flake.nix @@ -352,7 +352,7 @@ sha256 = "sha256-ukZd3ajt0Sx3LByof4R80S31F5t1yo+L8QUADrMMm2A="; }; buildInputs = [ pkgs.python3Packages.setuptools_scm ]; - propagatedBuildInputs = [ pkgs.nodejs pkgs.nodePackages.wavedrom-cli ] ++ (with pkgs.python3Packages; [ wavedrom sphinx xcffib cairosvg ]); + propagatedBuildInputs = (with pkgs.python3Packages; [ wavedrom sphinx xcffib cairosvg ]); }; latex-artiq-manual = pkgs.texlive.combine { inherit (pkgs.texlive) From 68ef0073ea66fe9c7f7c178979ecb8c681c47caa Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 1 Jun 2022 20:46:16 +0800 Subject: [PATCH 10/11] doc: mock sipyco.keepalive. Closes #1900 --- doc/manual/conf.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/manual/conf.py b/doc/manual/conf.py index d6c1ae1bf..03a6dc105 100644 --- a/doc/manual/conf.py +++ b/doc/manual/conf.py @@ -40,7 +40,8 @@ mock_modules = ["artiq.gui.waitingspinnerwidget", "llvmlite", "Levenshtein", "pythonparser", "sipyco", "sipyco.pc_rpc", "sipyco.sync_struct", "sipyco.asyncio_tools", "sipyco.logging_tools", - "sipyco.broadcast", "sipyco.packed_exceptions"] + "sipyco.broadcast", "sipyco.packed_exceptions", + "sipyco.keepalive"] for module in mock_modules: sys.modules[module] = Mock() From e7026247200edf1b2ec6c06128914354a33dac39 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 4 Jun 2022 10:32:02 +0800 Subject: [PATCH 11/11] flake: do not use __impure (breaks hydra) --- flake.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 3da033d47..1ab9d10af 100644 --- a/flake.nix +++ b/flake.nix @@ -449,7 +449,8 @@ name = "kc705-hitl"; __networked = true; # compatibility with old patched Nix - __impure = true; # Nix 2.8+ + # breaks hydra, https://github.com/NixOS/hydra/issues/1216 + #__impure = true; # Nix 2.8+ buildInputs = [ (pkgs.python3.withPackages(ps: with packages.x86_64-linux; [ artiq ps.paramiko ]))