2017-01-12 17 views
3

: 각 DIE 항목의 시작 부분에서DWARF의 맨 왼쪽 숫자 의미는 readelf에서 무엇을 의미합니까? 예를 들어

<0><b>: Abbrev Number: 1 (DW_TAG_compile_unit) 
    <c> DW_AT_producer : (indirect string, offset: 0xe): GNU C1 
1 5.4.0 20160609 -masm=intel -m32 -mtune=generic -march=i686 -g -fst 
ack-protector-strong 
    <10> DW_AT_language : 12  (ANSI C99) 
    <11> DW_AT_name  : (indirect string, offset: 0xbe): hell 
o.c 
    <15> DW_AT_comp_dir : (indirect string, offset: 0x97): /tmp 
    <19> DW_AT_low_pc  : 0x804840b 
    <1d> DW_AT_high_pc  : 0x2e 
    <21> DW_AT_stmt_list : 0x0 
<1><25>: Abbrev Number: 2 (DW_TAG_base_type) 
    <26> DW_AT_byte_size : 4 
    <27> DW_AT_encoding : 7  (unsigned) 
    <28> DW_AT_name  : (indirect string, offset: 0x77): unsi 
gned int 
<1><2c>: Abbrev Number: 2 (DW_TAG_base_type) 
    <2d> DW_AT_byte_size : 1 
    <2e> DW_AT_encoding : 8  (unsigned char) 
    <2f> DW_AT_name  : (indirect string, offset: 0x84): unsi 
gned char 
<1><33>: Abbrev Number: 2 (DW_TAG_base_type) 
    <34> DW_AT_byte_size : 2 
    <35> DW_AT_encoding : 7  (unsigned) 
    <36> DW_AT_name  : (indirect string, offset: 0xa1): shor 
t unsigned int 

은,이 숫자와 같은 <0>, <1> 등 ...이 숫자가 무엇을 의미합니까? 동일한 숫자가 동일한 DWARF 유형을 나타내는 것으로 보입니다. <1>이라는 항목은 모두 (DW_TAG_base_type)입니다.

답변

5

DWARF DIE는 트리로 배열됩니다. 가장 왼쪽 숫자는 DIE의 깊이를 알려줍니다. 당신의 예에서 :

<0><b>: Abbrev Number: 1 (DW_TAG_compile_unit) 

<0>이 DIE는 가장 바깥 쪽 수준에 나타나는 것을 의미한다. 이것은 컴파일 또는 타입 단위 DIE에만 발생합니다. 그런 다음

:

<1><25>: Abbrev Number: 2 (DW_TAG_base_type) 

이 DIE는 컴파일 단위의 DIE의 자식입니다.

더 깊숙한 중첩을 얻을 수 있습니다. 예를 들어, 함수의 지역 변수는 함수의 블록 구조에 따라 상당히 깊게 중첩 될 수 있습니다. 네임 스페이스의 항목도 중첩 될 수 있습니다.