diff options
author | Andy Wingo <wingo@pobox.com> | 2013-12-10 19:49:24 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2013-12-10 19:49:56 +0100 |
commit | a236867dc1e0bc0f486dcc72d3e7f20df67d316f (patch) | |
tree | f7a7ec863083005f5e4b6a44505b0ee543388199 | |
parent | 58b23156573ef66eb7bc5b9ec697786abc817fb5 (diff) | |
download | guile-a236867dc1e0bc0f486dcc72d3e7f20df67d316f.tar.gz |
Non-loadable sections should not have an sh_addr field set
* module/system/vm/linker.scm (relocate-section-header):
(write-linker-object): Sections that are not loadable should not have
their sh_addr fields set. Fix.
-rw-r--r-- | module/system/vm/linker.scm | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/module/system/vm/linker.scm b/module/system/vm/linker.scm index 9a5177857..cc68ca58e 100644 --- a/module/system/vm/linker.scm +++ b/module/system/vm/linker.scm @@ -301,15 +301,18 @@ segment, the order of the linker objects is preserved." (+ address (modulo (- alignment (modulo address alignment)) alignment)))) -(define (relocate-section-header sec addr) +(define (relocate-section-header sec offset) "Return a new section header, just like @var{sec} but with its -@code{addr} and @code{offset} set to @var{addr}." +@code{offset} (and @code{addr} if it is loadable) set to @var{offset}." (make-elf-section #:index (elf-section-index sec) #:name (elf-section-name sec) #:type (elf-section-type sec) #:flags (elf-section-flags sec) - #:addr addr - #:offset addr + #:addr (if (zero? (logand SHF_ALLOC + (elf-section-flags sec))) + 0 + offset) + #:offset offset #:size (elf-section-size sec) #:link (elf-section-link sec) #:info (elf-section-info sec) @@ -417,8 +420,11 @@ locations, as given in @var{symtab}." (len (elf-section-size section)) (bytes (linker-object-bv o)) (relocs (linker-object-relocs o))) - (unless (= offset (elf-section-addr section)) - (error "offset != addr" section)) + (if (zero? (logand SHF_ALLOC (elf-section-flags section))) + (unless (zero? (elf-section-addr section)) + (error "non-loadable section has non-zero addr" section)) + (unless (= offset (elf-section-addr section)) + (error "loadable section has offset != addr" section))) (if (not (= (elf-section-type section) SHT_NOBITS)) (begin (if (not (= len (bytevector-length bytes))) |