diff options
author | Andy Wingo <wingo@pobox.com> | 2013-04-28 07:51:42 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2013-04-28 09:16:49 +0200 |
commit | 00dedcad3b2b65946c0469aed66d3f5d67db3c31 (patch) | |
tree | 2a90dbe384a839c7dbcf10f04fb6e21fbb92e779 | |
parent | 25a0ab8cac64ea63a3be3246f551b1d24d35add5 (diff) | |
download | guile-00dedcad3b2b65946c0469aed66d3f5d67db3c31.tar.gz |
elf: add accessors for header members that might need relocation
* module/system/vm/elf.scm (elf-header-shoff-offset)
(elf-section-header-addr-offset, elf-section-header-offset-offset):
New accessors.
-rw-r--r-- | module/system/vm/elf.scm | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/module/system/vm/elf.scm b/module/system/vm/elf.scm index 9cf44fe83..2f4dee66c 100644 --- a/module/system/vm/elf.scm +++ b/module/system/vm/elf.scm @@ -47,7 +47,8 @@ elf-entry elf-phoff elf-shoff elf-flags elf-ehsize elf-phentsize elf-phnum elf-shentsize elf-shnum elf-shstrndx - elf-header-len write-elf-header + elf-header-len elf-header-shoff-offset + write-elf-header (make-elf-segment* . make-elf-segment) elf-segment? @@ -72,7 +73,9 @@ elf-section-link elf-section-info elf-section-addralign elf-section-entsize - elf-section-header-len write-elf-section-header + elf-section-header-len elf-section-header-addr-offset + elf-section-header-offset-offset + write-elf-section-header (make-elf-symbol* . make-elf-symbol) elf-symbol? @@ -152,6 +155,11 @@ ((4) elf32-header-len) ((8) elf64-header-len) (else (error "invalid word size" word-size)))) +(define (elf-header-shoff-offset word-size) + (case word-size + ((4) 32) + ((8) 40) + (else (error "bad word size" word-size)))) (define ELFCLASS32 1) ; 32-bit objects (define ELFCLASS64 2) ; 64-bit objects @@ -624,6 +632,18 @@ ((8) 64) (else (error "bad word size" word-size)))) +(define (elf-section-header-addr-offset word-size) + (case word-size + ((4) 12) + ((8) 16) + (else (error "bad word size" word-size)))) + +(define (elf-section-header-offset-offset word-size) + (case word-size + ((4) 16) + ((8) 24) + (else (error "bad word size" word-size)))) + (define (parse-elf64-section-header index bv offset byte-order) (if (<= (+ offset 64) (bytevector-length bv)) (make-elf-section index |