Initial Commit
This commit is contained in:
33 files changed
+7500
No files matched your search
@@ -0,0 +1,142 @@
|
||||
#! @file dwarf.sakura
|
||||
#! @author John Christman (sorakatadzuma@gmail.com)
|
||||
#! @copyright Malunal Studios, LLC.
|
||||
#! @license MIT
|
||||
#!
|
||||
#! Contains the numbers of DWARF 5, as its standard names them: the tags of
|
||||
#! entries, their attributes and the forms those are written in, the encodings
|
||||
#! of base types, the operations of expressions, the entries of lists of
|
||||
#! locations and ranges, the instructions of frames and of line programs, and
|
||||
#! how x86-64's registers are numbered, as its System V ABI numbers them.
|
||||
|
||||
import std;
|
||||
module binary::dwarf;
|
||||
|
||||
|
||||
# Tags.
|
||||
pub const dw_tag_array_type: u64 = 0x01;
|
||||
pub const dw_tag_enumeration_type: u64 = 0x04;
|
||||
pub const dw_tag_formal_parameter: u64 = 0x05;
|
||||
pub const dw_tag_lexical_block: u64 = 0x0b;
|
||||
pub const dw_tag_member: u64 = 0x0d;
|
||||
pub const dw_tag_pointer_type: u64 = 0x0f;
|
||||
pub const dw_tag_reference_type: u64 = 0x10;
|
||||
pub const dw_tag_compile_unit: u64 = 0x11;
|
||||
pub const dw_tag_structure_type: u64 = 0x13;
|
||||
pub const dw_tag_union_type: u64 = 0x17;
|
||||
pub const dw_tag_inlined_subroutine: u64 = 0x1d;
|
||||
pub const dw_tag_subrange_type: u64 = 0x21;
|
||||
pub const dw_tag_base_type: u64 = 0x24;
|
||||
pub const dw_tag_enumerator: u64 = 0x28;
|
||||
pub const dw_tag_subprogram: u64 = 0x2e;
|
||||
pub const dw_tag_variable: u64 = 0x34;
|
||||
pub const dw_tag_unspecified_type: u64 = 0x3b;
|
||||
|
||||
# Attributes.
|
||||
pub const dw_at_location: u64 = 0x02;
|
||||
pub const dw_at_name: u64 = 0x03;
|
||||
pub const dw_at_byte_size: u64 = 0x0b;
|
||||
pub const dw_at_stmt_list: u64 = 0x10;
|
||||
pub const dw_at_low_pc: u64 = 0x11;
|
||||
pub const dw_at_high_pc: u64 = 0x12;
|
||||
pub const dw_at_language: u64 = 0x13;
|
||||
pub const dw_at_comp_dir: u64 = 0x1b;
|
||||
pub const dw_at_const_value: u64 = 0x1c;
|
||||
pub const dw_at_inline: u64 = 0x20;
|
||||
pub const dw_at_producer: u64 = 0x25;
|
||||
pub const dw_at_abstract_origin: u64 = 0x31;
|
||||
pub const dw_at_calling_convention: u64 = 0x36;
|
||||
pub const dw_at_count: u64 = 0x37;
|
||||
pub const dw_at_data_member_location: u64 = 0x38;
|
||||
pub const dw_at_decl_file: u64 = 0x3a;
|
||||
pub const dw_at_decl_line: u64 = 0x3b;
|
||||
pub const dw_at_encoding: u64 = 0x3e;
|
||||
pub const dw_at_external: u64 = 0x3f;
|
||||
pub const dw_at_frame_base: u64 = 0x40;
|
||||
pub const dw_at_type: u64 = 0x49;
|
||||
pub const dw_at_ranges: u64 = 0x55;
|
||||
pub const dw_at_call_column: u64 = 0x57;
|
||||
pub const dw_at_call_file: u64 = 0x58;
|
||||
pub const dw_at_call_line: u64 = 0x59;
|
||||
|
||||
# Forms.
|
||||
pub const dw_form_addr: u64 = 0x01;
|
||||
pub const dw_form_data2: u64 = 0x05;
|
||||
pub const dw_form_data8: u64 = 0x07;
|
||||
pub const dw_form_data1: u64 = 0x0b;
|
||||
pub const dw_form_sdata: u64 = 0x0d;
|
||||
pub const dw_form_strp: u64 = 0x0e;
|
||||
pub const dw_form_udata: u64 = 0x0f;
|
||||
pub const dw_form_ref4: u64 = 0x13;
|
||||
pub const dw_form_sec_offset: u64 = 0x17;
|
||||
pub const dw_form_exprloc: u64 = 0x18;
|
||||
pub const dw_form_flag_present: u64 = 0x19;
|
||||
pub const dw_form_line_strp: u64 = 0x1f;
|
||||
|
||||
# Encodings of base types.
|
||||
pub const dw_ate_boolean: u8 = 0x02;
|
||||
pub const dw_ate_float: u8 = 0x04;
|
||||
pub const dw_ate_signed: u8 = 0x05;
|
||||
pub const dw_ate_unsigned: u8 = 0x07;
|
||||
|
||||
# Operations of expressions.
|
||||
pub const dw_op_deref: u8 = 0x06;
|
||||
pub const dw_op_constu: u8 = 0x10;
|
||||
pub const dw_op_reg0: u8 = 0x50;
|
||||
pub const dw_op_breg0: u8 = 0x70;
|
||||
pub const dw_op_fbreg: u8 = 0x91;
|
||||
pub const dw_op_piece: u8 = 0x93;
|
||||
pub const dw_op_call_frame_cfa: u8 = 0x9c;
|
||||
pub const dw_op_implicit_value: u8 = 0x9e;
|
||||
pub const dw_op_stack_value: u8 = 0x9f;
|
||||
|
||||
# Entries of lists of locations.
|
||||
pub const dw_lle_end_of_list: u8 = 0x00;
|
||||
pub const dw_lle_start_length: u8 = 0x08;
|
||||
|
||||
# Instructions of frames.
|
||||
pub const dw_cfa_advance_loc: u8 = 0x40;
|
||||
pub const dw_cfa_offset: u8 = 0x80;
|
||||
pub const dw_cfa_advance_loc1: u8 = 0x02;
|
||||
pub const dw_cfa_advance_loc2: u8 = 0x03;
|
||||
pub const dw_cfa_advance_loc4: u8 = 0x04;
|
||||
pub const dw_cfa_same_value: u8 = 0x08;
|
||||
pub const dw_cfa_remember_state: u8 = 0x0a;
|
||||
pub const dw_cfa_restore_state: u8 = 0x0b;
|
||||
pub const dw_cfa_def_cfa: u8 = 0x0c;
|
||||
pub const dw_cfa_def_cfa_register: u8 = 0x0d;
|
||||
pub const dw_cfa_def_cfa_offset: u8 = 0x0e;
|
||||
|
||||
# Instructions of line programs.
|
||||
pub const dw_lns_copy: u8 = 0x01;
|
||||
pub const dw_lns_advance_pc: u8 = 0x02;
|
||||
pub const dw_lns_advance_line: u8 = 0x03;
|
||||
pub const dw_lns_set_file: u8 = 0x04;
|
||||
pub const dw_lns_set_column: u8 = 0x05;
|
||||
pub const dw_lns_set_prologue_end: u8 = 0x0a;
|
||||
pub const dw_lne_end_sequence: u8 = 0x01;
|
||||
pub const dw_lne_set_address: u8 = 0x02;
|
||||
|
||||
# Entries of lists of ranges.
|
||||
pub const dw_rle_end_of_list: u8 = 0x00;
|
||||
pub const dw_rle_start_length: u8 = 0x07;
|
||||
|
||||
# Languages, calling conventions, inlining, and units.
|
||||
pub const dw_lang_c_plus_plus_14: u64 = 0x21;
|
||||
pub const dw_cc_nocall: u8 = 0x03;
|
||||
pub const dw_inl_inlined: u8 = 0x01;
|
||||
pub const dw_ut_compile: u8 = 0x01;
|
||||
|
||||
# Registers, as x86-64's System V ABI numbers them for DWARF.
|
||||
|
||||
#! The number of each general register, by how x86-64 encodes it: `rax`, `rcx`,
|
||||
#! `rdx`, `rbx`, `rsp`, `rbp`, `rsi`, `rdi`, then `r8` to `r15`.
|
||||
pub const amd64_registers: u8[16] = [0, 2, 1, 3, 7, 6, 4, 5, 8, 9, 10, 11, 12, 13, 14, 15];
|
||||
|
||||
#! The number of `xmm0`, which the other SSE registers follow.
|
||||
pub const amd64_xmm0: u8 = 17;
|
||||
|
||||
#! The numbers of `rbp` and `rsp`, and of the column of the return address.
|
||||
pub const amd64_rbp: u64 = 6;
|
||||
pub const amd64_rsp: u64 = 7;
|
||||
pub const amd64_return_address: u64 = 16;
|
||||
Reference in new issue
Block a user