From 4a0c2433d97be9d995b3be74d90bc074d8efb5a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Mon, 15 Apr 2024 15:58:30 +0200 Subject: [PATCH] linker: Create sparse files for padding. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since ‘*lcm-page-size*’ is 64 KiB, this saves disk space for small ‘.go’ files. * module/system/vm/linker.scm (link-elf)[write-padding]: Rewrite in terms of ‘seek’. --- module/system/vm/linker.scm | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/module/system/vm/linker.scm b/module/system/vm/linker.scm index cf213323e..952e85c30 100644 --- a/module/system/vm/linker.scm +++ b/module/system/vm/linker.scm @@ -769,16 +769,10 @@ Returns a bytevector." objects) bv) (lambda (port) - (define write-padding - (let ((blank (make-bytevector 4096 0))) - (lambda (port size) - ;; Write SIZE bytes of padding to PORT. - (let loop ((size size)) - (unless (zero? size) - (let ((count (min size - (bytevector-length blank)))) - (put-bytevector port blank 0 count) - (loop (- size count)))))))) + (define (write-padding port size) + ;; Write SIZE bytes of padding to PORT. Use 'seek' to + ;; create a sparse file. + (seek port size SEEK_CUR)) (define (compute-padding objects) ;; Return the list of padding in between OBJECTS--the list