diff options
author | Andy Wingo <wingo@pobox.com> | 2013-04-28 07:51:42 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2013-05-23 11:02:14 +0200 |
commit | 51611a92f42e240cd842cb26efe6c4d5a1282c00 (patch) | |
tree | c9f38bb05c181abfc27186d01c1bc88b9359acb2 | |
parent | 6756d265ed53d7b107d31746e8455f10e2ecebdd (diff) | |
download | guile-51611a92f42e240cd842cb26efe6c4d5a1282c00.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 efa978256..b59970c8d 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 elf-symbol? elf-symbol-name elf-symbol-value elf-symbol-size @@ -149,6 +152,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 @@ -621,6 +629,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 |