[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/6] elf: add accessors for header members that might need reloca
From: |
Andy Wingo |
Subject: |
[PATCH 3/6] elf: add accessors for header members that might need relocation |
Date: |
Sat, 18 May 2013 17:05:37 +0200 |
* 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 efa9782..b59970c 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
--
1.7.10.4
- Re: [PATCH 2/6] ELF refactor and consequent linker simplifications, (continued)
[PATCH 6/6] add (find-mapped-elf-image) procedure to (system vm objcode) module, Andy Wingo, 2013/05/18
[PATCH 5/6] refactor and simplify ELF loader in objcodes.c, Andy Wingo, 2013/05/18
[PATCH 3/6] elf: add accessors for header members that might need relocation,
Andy Wingo <=
[PATCH 4/6] refactor linker to lay out ELF files and memory in the same way, Andy Wingo, 2013/05/18
[PATCH 1/6] split linker out of elf module, Andy Wingo, 2013/05/18
Re: wip-linker: Refactor ELF linker and loader, Ludovic Courtès, 2013/05/22