1 ; vim
: set filetype
=fasm foldmethod
=marker commentstring
=;
%s colorcolumn
=101 :
2 strtbl
: namespace strtbl
5 TRACE
'PBF:BLK:PRIMBLK:STRTBL:INIT_ONCE'
12 mov rdx
, 0x1 or 0x2 ; PROT_READ | PROT_WRITE
13 mov
r10, 0x20 or 0x02 ; MAP_ANONYMOUS | MAP_PRIVATE
18 cmp rax
, linux.errno.last
19 jae
.err_strtbl_idx_mmap_failed
21 TRACE
'PBF:BLK:PRIMBLK:STRTBL:IDX:INIT_ONCE:string table index mmaped at %p', rax
25 .err_strtbl_idx_mmap_failed: ; in: rax = error code
27 lea rsi
, [idx.msg.mmap_failed
]
29 call qword
[libc.dprintf
]
33 ;
---------------------------------------------------------------------------------------------------
34 ; we create an idx for fast look-up
35 ; scratch
: rax rcx rdx
39 ;define primblk_p_finish
r12
41 ;define primgrp_p_finish
r14
50 mov idx_p
, idx_start_p
53 je primblk.parse.next_key
54 inc p ; skip the msg field num
/type since it is always num
= 1/type
= 2 namely
0x0a
55 mov
[idx_p
], p ; idx_p
= ptr on current byte
56 varint_load rdx
, p ;
= str_sz
58 add idx_p
, 8 ; points on next str ptr
60 ;
---------------------------------------------------------------------------------------------------
62 ;purge primblk_p_finish
64 ;purge primgrp_p_finish
70 end namespace ; strtbl