]> gitweb.factorcode.org Git - factor.git/blob - extra/tools/image-analyzer/relocations/relocations.factor
tools.image-analyzer: now relocation pointers are decoded too -> nicer graphs
[factor.git] / extra / tools / image-analyzer / relocations / relocations.factor
1 USING: alien.c-types alien.data assocs combinators.smart kernel math
2 sequences ;
3 IN: tools.image-analyzer.relocations
4
5 CONSTANT: rel-params {
6     { 9 1 }
7     { 0 2 } { 13 2 }
8 }
9
10 : rel-type ( uint -- type )
11     -28 shift 0xf bitand ;
12
13 : rel-class ( uint -- class )
14     -24 shift 0xf bitand ;
15
16 : rel-offset ( uint -- offset )
17     0xffffff bitand ;
18
19 : rel-nr-params ( uint -- n )
20     rel-params at 0 or ;
21
22 : uint>relocation ( uint -- relocation )
23     { [ rel-type ] [ rel-class ] [ rel-offset ] [ rel-nr-params ] }
24     cleave>array ;
25
26 : byte-array>relocations ( byte-array -- relocations )
27     uint cast-array [ uint>relocation ] { } map-as ;
28
29 : load-relative-value ( byte-array relocation -- value )
30     third [ [ 4 - ] keep rot subseq int cast-array first ] keep + ;