mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-22 20:40:29 +02:00
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.
This commit is contained in:
parent
58b2315657
commit
a236867dc1
1 changed files with 12 additions and 6 deletions
|
@ -301,15 +301,18 @@ segment, the order of the linker objects is preserved."
|
||||||
(+ address
|
(+ address
|
||||||
(modulo (- alignment (modulo address alignment)) alignment))))
|
(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
|
"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)
|
(make-elf-section #:index (elf-section-index sec)
|
||||||
#:name (elf-section-name sec)
|
#:name (elf-section-name sec)
|
||||||
#:type (elf-section-type sec)
|
#:type (elf-section-type sec)
|
||||||
#:flags (elf-section-flags sec)
|
#:flags (elf-section-flags sec)
|
||||||
#:addr addr
|
#:addr (if (zero? (logand SHF_ALLOC
|
||||||
#:offset addr
|
(elf-section-flags sec)))
|
||||||
|
0
|
||||||
|
offset)
|
||||||
|
#:offset offset
|
||||||
#:size (elf-section-size sec)
|
#:size (elf-section-size sec)
|
||||||
#:link (elf-section-link sec)
|
#:link (elf-section-link sec)
|
||||||
#:info (elf-section-info sec)
|
#:info (elf-section-info sec)
|
||||||
|
@ -417,8 +420,11 @@ locations, as given in @var{symtab}."
|
||||||
(len (elf-section-size section))
|
(len (elf-section-size section))
|
||||||
(bytes (linker-object-bv o))
|
(bytes (linker-object-bv o))
|
||||||
(relocs (linker-object-relocs o)))
|
(relocs (linker-object-relocs o)))
|
||||||
(unless (= offset (elf-section-addr section))
|
(if (zero? (logand SHF_ALLOC (elf-section-flags section)))
|
||||||
(error "offset != addr" 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))
|
(if (not (= (elf-section-type section) SHT_NOBITS))
|
||||||
(begin
|
(begin
|
||||||
(if (not (= len (bytevector-length bytes)))
|
(if (not (= len (bytevector-length bytes)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue