From 51611a92f42e240cd842cb26efe6c4d5a1282c00 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Sun, 28 Apr 2013 07:51:42 +0200 Subject: 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. --- module/system/vm/elf.scm | 24 ++++++++++++++++++++++-- 1 file 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 -- cgit v1.2.1