From 812c83d48b38240d4c6c61c3ba89ea67a44efd42 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Tue, 10 Dec 2013 20:03:59 +0100 Subject: [PATCH] Fix section table writing for non-loadable sections * module/system/vm/linker.scm (add-elf-objects): Don't fill in the sh_addr field if the section is not loadable. --- module/system/vm/linker.scm | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/module/system/vm/linker.scm b/module/system/vm/linker.scm index cc68ca58e..5449e8634 100644 --- a/module/system/vm/linker.scm +++ b/module/system/vm/linker.scm @@ -517,17 +517,23 @@ list of objects, augmented with objects for the special ELF sections." (write-elf-section-header bv offset endianness word-size section) (if (= (elf-section-type section) SHT_NULL) relocs - (cons* (make-linker-reloc - reloc-kind - (+ offset (elf-section-header-addr-offset word-size)) - 0 - section-label) - (make-linker-reloc - reloc-kind - (+ offset (elf-section-header-offset-offset word-size)) - 0 - section-label) - relocs)))) + (let ((relocs + (cons (make-linker-reloc + reloc-kind + (+ offset + (elf-section-header-offset-offset word-size)) + 0 + section-label) + relocs))) + (if (zero? (logand SHF_ALLOC (elf-section-flags section))) + relocs + (cons (make-linker-reloc + reloc-kind + (+ offset + (elf-section-header-addr-offset word-size)) + 0 + section-label) + relocs)))))) (let ((relocs (fold-values (lambda (object relocs) (write-and-reloc