使用gcc生成sso双端代码矮化问题
您好,我正在尝试使用gcc的sso endianity属性为biendian代码生成dwarf信息使用gcc生成sso双端代码矮化问题,gcc,dwarf,Gcc,Dwarf,您好,我正在尝试使用gcc的sso endianity属性为biendian代码生成dwarf信息 struct __attribute__((scalar_storage_order("big-endian"))) ms1 { int a; }; struct __attribute__((scalar_storage_order("little-endian"))) ms2 { int b; }; struct ms1 a; struct ms2 b; 在对象文件中生成
struct __attribute__((scalar_storage_order("big-endian"))) ms1 {
int a;
};
struct __attribute__((scalar_storage_order("little-endian"))) ms2 {
int b;
};
struct ms1 a;
struct ms2 b;
在对象文件中生成的dwarf信息为
./test.o: file format elf64-x86-64
Contents of the .debug_info section:
Compilation Unit @ offset 0x0:
Length: 0x76 (32-bit)
Version: 4
Abbrev Offset: 0x0
Pointer Size: 8
<0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
<c> DW_AT_producer : (indirect string, offset: 0x1e): GNU C11 7.3.0 -mtune=generic -march=x86-64 -g -fstack-protector-strong
<10> DW_AT_language : 12 (ANSI C99)
<11> DW_AT_name : (indirect string, offset: 0x17): test.c
<15> DW_AT_comp_dir : (indirect string, offset: 0x0): /home/neo/Desktop/test
<19> DW_AT_stmt_list : 0x0
<1><1d>: Abbrev Number: 2 (DW_TAG_structure_type)
<1e> DW_AT_name : ms1
<22> DW_AT_byte_size : 4
<23> DW_AT_decl_file : 1
<24> DW_AT_decl_line : 1
<25> DW_AT_sibling : <0x34>
<2><29>: Abbrev Number: 3 (DW_TAG_member)
<2a> DW_AT_name : a
<2c> DW_AT_decl_file : 1
<2d> DW_AT_decl_line : 2
<2e> DW_AT_type : <0x34>
<32> DW_AT_data_member_location: 0
<2><33>: Abbrev Number: 0
<1><34>: Abbrev Number: 4 (DW_TAG_base_type)
<35> DW_AT_byte_size : 4
<36> DW_AT_encoding : 5 (signed)
<37> DW_AT_endianity : 1 (big)
<38> DW_AT_name : int
<1><3c>: Abbrev Number: 2 (DW_TAG_structure_type)
<3d> DW_AT_name : ms2
<41> DW_AT_byte_size : 4
<42> DW_AT_decl_file : 1
<43> DW_AT_decl_line : 5
<44> DW_AT_sibling : <0x53>
<2><48>: Abbrev Number: 3 (DW_TAG_member)
<49> DW_AT_name : b
<4b> DW_AT_decl_file : 1
<4c> DW_AT_decl_line : 6
<4d> DW_AT_type : <0x34>
<51> DW_AT_data_member_location: 0
<2><52>: Abbrev Number: 0
<1><53>: Abbrev Number: 5 (DW_TAG_variable)
<54> DW_AT_name : a
<56> DW_AT_decl_file : 1
<57> DW_AT_decl_line : 9
<58> DW_AT_type : <0x1d>
<5c> DW_AT_external : 1
<5c> DW_AT_location : 9 byte block: 3 0 0 0 0 0 0 0 0 (DW_OP_addr: 0)
<1><66>: Abbrev Number: 5 (DW_TAG_variable)
<67> DW_AT_name : b
<69> DW_AT_decl_file : 1
<6a> DW_AT_decl_line : 10
<6b> DW_AT_type : <0x3c>
<6f> DW_AT_external : 1
<6f> DW_AT_location : 9 byte block: 3 0 0 0 0 0 0 0 0 (DW_OP_addr: 0)
<1><79>: Abbrev Number: 0
/test.o:文件格式elf64-x86-64
.debug_info部分的内容:
偏移量0x0处的编译单位:
长度:0x76(32位)
版本:4
Abbrev偏移量:0x0
指针大小:8
:Abbrev编号:1(DW_标记_编译_单元)
DW_AT_producer:(间接字符串,偏移量:0x1e):GNU C117.3.0-mtune=generic-march=x86-64-g-fstack-strong
DW_AT_语言:12(ANSI C99)
DW_AT_name:(间接字符串,偏移量:0x17):test.c
DW_AT_comp_dir:(间接字符串,偏移量:0x0):/home/neo/Desktop/test
DW_AT_stmt_列表:0x0
:缩写编号:2(DW_标签结构类型)
DW_AT_名称:ms1
字节大小为4的数据仓库
DW_AT_decl_文件:1
德克卢线DW卢:1
DW_在_同级:
:缩写编号:3(DW_标签_成员)
DW_AT_名称:a
DW_AT_decl_文件:1
德克卢线DW卢:2
DW_AT_类型:
DW_位于_数据_成员_位置:0
:Abbrev编号:0
:缩写编号:4(DW_标签_基础_类型)
字节大小为4的数据仓库
DW_AT_编码:5(签名)
德沃埃迪安尼度:1(大)
DW_AT_名称:int
:缩写编号:2(DW_标签结构类型)
DW_AT_名称:ms2
字节大小为4的数据仓库
DW_AT_decl_文件:1
德克卢线的德瓦卢:5
DW_在_同级:
:缩写编号:3(DW_标签_成员)
DW_AT_名称:b
DW_AT_decl_文件:1
德克卢线的德瓦卢:6
DW_AT_类型:
DW_位于_数据_成员_位置:0
:Abbrev编号:0
:Abbrev编号:5(DW_标记_变量)
DW_AT_名称:a
DW_AT_decl_文件:1
德克卢线的德瓦卢:9
DW_AT_类型:
DW_在_外部:1
位于位置的DW_:9字节块:3 0 0(DW_OP_addr:0)
:Abbrev编号:5(DW_标记_变量)
DW_AT_名称:b
DW_AT_decl_文件:1
德克卢线的德瓦卢:10
DW_AT_类型:
DW_在_外部:1
位于位置的DW_:9字节块:3 0 0(DW_OP_addr:0)
:Abbrev编号:0
这里,ms1是带有标记基类型的大端数,ms2是带有标记基类型的小端数(显式),命名为b
但是矮树看起来很奇怪,因为没有标记为b的条目。
所以我的问题是,这是gcc的错误,它排除了使标记节点唯一的可选参数,还是我测试错误了
使用的gcc版本,
gcc(Ubuntu 7.3.0-16ubuntu3)7.3.0
使用的objdump版本,
GNU objdump(用于Ubuntu的GNU Binutils)2.30是的,这看起来像是一个gcc错误。如果gcc要在数据成员的类型上发出endianity,那么这个场景中的两个成员必须有不同的类型。谢谢,这个错误似乎在gcc(gcc)9.0.0 20180803(实验)和gcc(Ubuntu 7.3.0-16ubuntu3)7.3.0之间的某个地方得到了解决。