Skip to content

Commit

Permalink
image-analyzer: reject compressed image
Browse files Browse the repository at this point in the history
prepare for future support
  • Loading branch information
nomennescio committed May 16, 2024
1 parent 6336b93 commit aa51b2c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion extra/tools/image-analyzer/image-analyzer.factor
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,17 @@ TUPLE: image header heap ;
pick code-relocation-base>> (adjust-addresses)
swap data-relocation-base>> (adjust-addresses) ;

ERROR: unsupported-image-format ;

: compressed-data? ( header -- ? ) [ data-heap-size ] [ compressed-data-size>> ] bi [ dup ] when-zero = not ;
: compressed-code? ( header -- ? ) [ code-size>> ] [ compressed-code-size>> ] bi [ dup ] when-zero = not ;

: check-uncompressed ( header -- header/* )
[ [ compressed-data? ] [ compressed-code? ] bi or [ unsupported-image-format ] when ] keep ;

: load-image ( image-file -- image )
binary [
image-header read-struct dup [
image-header read-struct check-uncompressed dup [
[ data-relocation-base>> ] [ data-heap-size read ] bi
data-heap>objects
]
Expand Down

0 comments on commit aa51b2c

Please sign in to comment.