xref: /DragonOS/kernel/crates/rbpf/examples/disassemble.rs (revision fae6e9ade46a52976ad5d099643d51cc20876448)
1*fae6e9adSlinfeng // SPDX-License-Identifier: (Apache-2.0 OR MIT)
2*fae6e9adSlinfeng // Copyright 2017 6WIND S.A. <quentin.monnet@6wind.com>
3*fae6e9adSlinfeng 
4*fae6e9adSlinfeng extern crate rbpf;
5*fae6e9adSlinfeng use rbpf::disassembler;
6*fae6e9adSlinfeng 
7*fae6e9adSlinfeng // Simply disassemble a program into human-readable instructions.
main()8*fae6e9adSlinfeng fn main() {
9*fae6e9adSlinfeng     let prog = &[
10*fae6e9adSlinfeng         0xb7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79, 0x12, 0x50, 0x00, 0x00, 0x00, 0x00,
11*fae6e9adSlinfeng         0x00, 0x79, 0x11, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbf, 0x13, 0x00, 0x00, 0x00, 0x00,
12*fae6e9adSlinfeng         0x00, 0x00, 0x07, 0x03, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x2d, 0x23, 0x12, 0x00, 0x00,
13*fae6e9adSlinfeng         0x00, 0x00, 0x00, 0x69, 0x12, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x02, 0x10, 0x00,
14*fae6e9adSlinfeng         0x08, 0x00, 0x00, 0x00, 0x71, 0x12, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x02, 0x0e,
15*fae6e9adSlinfeng         0x00, 0x06, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
16*fae6e9adSlinfeng         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbf,
17*fae6e9adSlinfeng         0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x57, 0x02, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
18*fae6e9adSlinfeng         0x15, 0x02, 0x08, 0x00, 0x99, 0x99, 0x00, 0x00, 0x18, 0x02, 0x00, 0x00, 0x00, 0x00, 0xff,
19*fae6e9adSlinfeng         0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x21, 0x00, 0x00, 0x00, 0x00,
20*fae6e9adSlinfeng         0x00, 0x00, 0xb7, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x18, 0x02, 0x00, 0x00, 0x00,
21*fae6e9adSlinfeng         0x00, 0x99, 0x99, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x21, 0x01, 0x00,
22*fae6e9adSlinfeng         0x00, 0x00, 0x00, 0x00, 0xb7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x95, 0x00, 0x00,
23*fae6e9adSlinfeng         0x00, 0x00, 0x00, 0x00, 0x00,
24*fae6e9adSlinfeng     ];
25*fae6e9adSlinfeng     disassembler::disassemble(prog);
26*fae6e9adSlinfeng }
27