DWARF4

DWARF 4

Dwarf 栈操作

  • DW_OP_dup:复制栈顶值

The DW_OP_dup operation duplicates the value at the top of the stack.

  • DW_OP_drop:栈顶值出栈

The DW_OP_drop operation pops the value at the top of the stack. 

  • DW_OP_pick :带一个操作数,指定将要被压栈的1个字节下标(0-255)

The single operand of the DW_OP_pick operation provides a 1-byte index. A copy of the 
stack entry with the specified index (0 through 255, inclusive) is pushed onto the stack.  

  • DW_OP_over :同DW_OP_pick,只不过下标规定为1.

The DW_OP_over operation duplicates the entry currently second in the stack at the top of 
the stack. This is equivalent to a DW_OP_pick operation, with index 1.  

  • DW_OP_swap:交换栈顶的两个元素  

The DW_OP_swap operation swaps the top two stack entries. The entry at the top of the 
stack becomes the second stack entry, and the second entry becomes e top of the stack. 

  • DW_OP_rot:循环交换栈前三个元素 

The DW_OP_rot operation rotates the first three stack entries. The entry at the top of the 
stack becomes the third stack entry, the second entry becomes the top of the stack, and the 
third entry becomes the second entry. 

  • DW_OP_deref :  栈顶元素出栈,并将其视作一个地址。该地址指向的内容压栈

The DW_OP_deref operation pops the top stack entry and treats it as an address . The value 
retrieved from that address is pushed. The size of the data retrieved from the dereferenced 
address is the size of an address on the target machine. 

  • DW_OP_deref_size   :带有一个操作数指定地址指向数据的大小。若实际数据小于该数据,则零扩展。

The DW_OP_deref_size operation behaves like the DW_OP_deref operation: it pops the top 
stack entry and treats it as an address. The value retrieved from that address is pushed. In the 
DW_OP_deref_size operation, however, the size in bytes of the data retrieved from the 
dereferenced address is specified by the single operand. This operand is a 1-byte unsigned 
integral constant whose value may not be larger than the size of an address  on the target 
machine. The data retrieved is zero extended to the size of an address on the target machine 
before being pushed onto the expression stack.

  • DW_OP_xderef :类似上一个操作,这里栈中前两个元素出栈,且第二个元素当做地址空间描述。

The DW_OP_xderef operation provides an extended dereference mechanism. The entry at 
the top of the stack is treated as an address. The second stack entry is treated as an ―address 
space identifier‖ for those architectures that support multiple address spaces. The top two 
stack elements are popped, and a data item is retrieved through an implementation-defined 
address calculation and pushed as the new stack top. The size of the d ata retrieved from the 
dereferenced address is the size of an address on the target machine. 

Examples:

Before         Operation        After 
 
0     17       DW_OP_dup        0     17 
1     29                        1     17 
2   1000                        2     29 
                                3   1000 
 
0     17       DW_OP_drop       0     29 
1     29                        1   1000 
2   1000 
 
0     17       DW_OP_pick 2     0   1000 
1     29                        1     17 
2   1000                        2     29 
                                3   1000 
 
0     17       DW_OP_over       0     29 
1     29                        1     17 
2   1000                        2     29 
                                3   1000 
 
0     17       DW_OP_swap       0     29 
1     29                        1     17 
2   1000                        2   1000 
 
0     17       DW_OP_rot        0     29 
1     29                        1   1000 
2   1000                        2     17

猜你喜欢

转载自blog.csdn.net/qq_34272143/article/details/81904697
4
今日推荐