mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
linker: Create a sparse file only when writing to a file port.
Fixes a regression introduced in
4a0c2433d9
: the strategy wouldn’t work
when writing to, say, a bytevector output port.
* module/system/vm/linker.scm (link-elf)[write-padding]: Reintroduce
loop for when PORT is not a file port. Remove first argument.
This commit is contained in:
parent
696acfc9e5
commit
112b617f59
1 changed files with 16 additions and 5 deletions
|
@ -769,10 +769,21 @@ Returns a bytevector."
|
|||
objects)
|
||||
bv)
|
||||
(lambda (port)
|
||||
(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 write-padding
|
||||
;; Write SIZE bytes of padding to PORT.
|
||||
(if (file-port? port)
|
||||
(lambda (size)
|
||||
;; Use 'seek' to create a sparse file.
|
||||
(seek port size SEEK_CUR))
|
||||
(let ((blank (make-bytevector 4096 0)))
|
||||
(lambda (size)
|
||||
;; Write SIZE zeros.
|
||||
(let loop ((size size))
|
||||
(unless (zero? size)
|
||||
(let ((count (min size
|
||||
(bytevector-length blank))))
|
||||
(put-bytevector port blank 0 count)
|
||||
(loop (- size count)))))))))
|
||||
|
||||
(define (compute-padding objects)
|
||||
;; Return the list of padding in between OBJECTS--the list
|
||||
|
@ -796,7 +807,7 @@ Returns a bytevector."
|
|||
(for-each
|
||||
(lambda (object padding)
|
||||
(let ((bv (make-bytevector (linker-object-size object) 0)))
|
||||
(write-padding port padding)
|
||||
(write-padding padding)
|
||||
(write-linker-object bv object symtab endianness)
|
||||
(put-bytevector port bv)))
|
||||
objects
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue