ELF tools: don't treat non-allocated section as allocated
For example, don't fail in shifting file offsets by misinterpreting an unallocated section's null address as requiring a shift of virtual addresses.
This commit is contained in:
parent
a4704f861c
commit
82d5b46819
|
@ -48,7 +48,7 @@
|
|||
sh-offset sh-esize sh-ecount
|
||||
class format sh-str-index)
|
||||
#:transparent)
|
||||
(struct section (name-offset addr offset size type)
|
||||
(struct section (name-offset addr offset size type alloc?)
|
||||
#:transparent)
|
||||
(struct program (offset vaddr paddr size)
|
||||
#:transparent)
|
||||
|
@ -206,7 +206,8 @@
|
|||
[info (read-word)]
|
||||
[align (read-xword)]
|
||||
[esize (read-xword)])
|
||||
(section name-offset addr offset size type)))])
|
||||
(define alloc? (bitwise-bit-set? flags 1))
|
||||
(section name-offset addr offset size type alloc?)))])
|
||||
;; Read program headers ------------------------
|
||||
(let ([programs
|
||||
(for/list ([i (in-range ph-ecount)])
|
||||
|
@ -253,7 +254,8 @@
|
|||
|
||||
(define (find-section-by-offset offset sections)
|
||||
(for/or ([s (in-list sections)])
|
||||
(and (offset . >= . (section-offset s))
|
||||
(and (section-alloc? s)
|
||||
(offset . >= . (section-offset s))
|
||||
(offset . < . (+ (section-offset s)
|
||||
(section-size s)))
|
||||
s)))
|
||||
|
|
Loading…
Reference in New Issue
Block a user