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
|
sh-offset sh-esize sh-ecount
|
||||||
class format sh-str-index)
|
class format sh-str-index)
|
||||||
#:transparent)
|
#:transparent)
|
||||||
(struct section (name-offset addr offset size type)
|
(struct section (name-offset addr offset size type alloc?)
|
||||||
#:transparent)
|
#:transparent)
|
||||||
(struct program (offset vaddr paddr size)
|
(struct program (offset vaddr paddr size)
|
||||||
#:transparent)
|
#:transparent)
|
||||||
|
@ -206,7 +206,8 @@
|
||||||
[info (read-word)]
|
[info (read-word)]
|
||||||
[align (read-xword)]
|
[align (read-xword)]
|
||||||
[esize (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 ------------------------
|
;; Read program headers ------------------------
|
||||||
(let ([programs
|
(let ([programs
|
||||||
(for/list ([i (in-range ph-ecount)])
|
(for/list ([i (in-range ph-ecount)])
|
||||||
|
@ -253,7 +254,8 @@
|
||||||
|
|
||||||
(define (find-section-by-offset offset sections)
|
(define (find-section-by-offset offset sections)
|
||||||
(for/or ([s (in-list sections)])
|
(for/or ([s (in-list sections)])
|
||||||
(and (offset . >= . (section-offset s))
|
(and (section-alloc? s)
|
||||||
|
(offset . >= . (section-offset s))
|
||||||
(offset . < . (+ (section-offset s)
|
(offset . < . (+ (section-offset s)
|
||||||
(section-size s)))
|
(section-size s)))
|
||||||
s)))
|
s)))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user