Dwarf format parsing

Source: Internet
Author: User

Debug_line contains the relationship between the address and the source file line

What I want to figure out today is the relationship between the C code of the file and the assembly code:

It has been a blur before, and the problem has been found to have seriously affected the location of the bug.

Before I felt that C and the Assembly could not correspond, but too vague! What is not a single correspondence, in the end is C can correspond to a certain part of the Assembly, or the assembly can correspond to a certain part of C, can you speak clearly?

Hope to see a phenomenon is: can be seen from the dwarf, said this part of the assembly code is the corresponding C language in the first few lines to the first line!~

The addr2line seems to answer my doubts.

Addr2line Enter a virtual address, and Addr2line will report according to this address. What is the virtual address of this address?

[Wonder: What about the functions of inline?]

Specific usage:

An accurate picture of the source program

X29 in arm64 is the stack frame register

Found no stack frame at all!

ARM64 's RET instruction will change the register.

B and ret, the jump instruction will change the register, and the RET instruction will also change the register. But the change is all x30 registers, right? Also includes a status register!

It is possible that the CPU

ARM64 the processing specification is: Caller all the variables to be ready, according to X0 to X7 way ready [], if more than 8 parameters, will put the parameters on the stack, what exactly is the stack frame?

The following code examines the stack frame of the arm64: (The code is simple, but contains a complex set of parameters, including more than 8 formal parameters, when the register is not enough to use the case. And it involves a large return value)

STP X29,X30,[SP, 0x8]! Change the value of the register first, and then do
#include <stdio.h> #include <string.h> #include <stdlib.h>struct big{    char buf[64];    int i;}; int func (int a, int b, int c, int d, int e,          int f, int g, int h, int i, int j) {    return a+b+c+d+e+f+g+h+i+j;} struct Big Funb () {    struct big big_buf;    BIG_BUF.I = func (1,2,3,4,5,6,7,8,9,10);    return big_buf;} int Funa (int a) {    return a+1;} int fun (int a) {    int b, C;    b = a+2;    c = Funa (1);    return a+b+c;} int main () {    int i;    struct big big_buf;    Big_buf = Funb ();    i = BIG_BUF.I;    return fun (i);}   

Dwarf format parsing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.