+ generate .debug_aranges sections for dwarf debug info: enables faster address to debug info translation

git-svn-id: trunk@33454 -
This commit is contained in:
florian 2016-04-08 20:19:59 +00:00
parent 897547b115
commit 90b284e169
12 changed files with 81 additions and 17 deletions

View File

@ -103,6 +103,8 @@ interface
sec_debug_info, sec_debug_info,
sec_debug_line, sec_debug_line,
sec_debug_abbrev, sec_debug_abbrev,
sec_debug_aranges,
sec_debug_ranges,
{ Yury: "sec_fpc is intended for storing fpc specific data { Yury: "sec_fpc is intended for storing fpc specific data
which must be recognized and processed specially by linker. which must be recognized and processed specially by linker.
Currently fpc version string, dummy links to stab sections Currently fpc version string, dummy links to stab sections

View File

@ -62,6 +62,8 @@ interface
al_dwarf_info, al_dwarf_info,
al_dwarf_abbrev, al_dwarf_abbrev,
al_dwarf_line, al_dwarf_line,
al_dwarf_aranges,
al_dwarf_ranges,
al_picdata, al_picdata,
al_indirectpicdata, al_indirectpicdata,
al_resourcestrings, al_resourcestrings,
@ -114,6 +116,8 @@ interface
'al_dwarf_info', 'al_dwarf_info',
'al_dwarf_abbrev', 'al_dwarf_abbrev',
'al_dwarf_line', 'al_dwarf_line',
'al_dwarf_aranges',
'al_dwarf_ranges',
'al_picdata', 'al_picdata',
'al_indirectpicdata', 'al_indirectpicdata',
'al_resourcestrings', 'al_resourcestrings',

View File

@ -232,7 +232,7 @@ implementation
'.stabstr', '.stabstr',
'.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata', '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
'.eh_frame', '.eh_frame',
'.debug_frame','.debug_info','.debug_line','.debug_abbrev', '.debug_frame','.debug_info','.debug_line','.debug_abbrev','.debug_aranges','.debug_ranges',
'.fpc', '.fpc',
'.toc', '.toc',
'.init', '.init',
@ -291,7 +291,7 @@ implementation
'.stabstr', '.stabstr',
'.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata', '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
'.eh_frame', '.eh_frame',
'.debug_frame','.debug_info','.debug_line','.debug_abbrev', '.debug_frame','.debug_info','.debug_line','.debug_abbrev','.debug_aranges','.debug_ranges',
'.fpc', '.fpc',
'.toc', '.toc',
'.init', '.init',
@ -416,7 +416,7 @@ implementation
result:='r'; result:='r';
sec_stab,sec_stabstr, sec_stab,sec_stabstr,
sec_debug_frame,sec_debug_info,sec_debug_line,sec_debug_abbrev: sec_debug_frame,sec_debug_info,sec_debug_line,sec_debug_abbrev,sec_debug_aranges,sec_debug_ranges:
result:='n'; result:='n';
else else
result:=''; { defaults to data+load } result:=''; { defaults to data+load }
@ -1631,6 +1631,16 @@ implementation
result := '.section __DWARF,__debug_abbrev,regular,debug'; result := '.section __DWARF,__debug_abbrev,regular,debug';
exit; exit;
end; end;
sec_debug_aranges:
begin
result := '.section __DWARF,__debug_aranges,regular,debug';
exit;
end;
sec_debug_ranges:
begin
result := '.section __DWARF,__debug_ranges,regular,debug';
exit;
end;
sec_rodata: sec_rodata:
begin begin
result := '.const_data'; result := '.const_data';
@ -1744,6 +1754,8 @@ implementation
sec_debug_info, sec_debug_info,
sec_debug_line, sec_debug_line,
sec_debug_abbrev, sec_debug_abbrev,
sec_debug_aranges,
sec_debug_ranges,
{ ELF resources (+ references to stabs debug information sections) } { ELF resources (+ references to stabs debug information sections) }
sec_code (* sec_fpc *), sec_code (* sec_fpc *),
{ Table of contents section } { Table of contents section }

View File

@ -2231,6 +2231,11 @@ implementation
append_labelentry(DW_AT_low_pc,current_asmdata.RefAsmSymbol(procentry)); append_labelentry(DW_AT_low_pc,current_asmdata.RefAsmSymbol(procentry));
append_labelentry(DW_AT_high_pc,procendlabel); append_labelentry(DW_AT_high_pc,procendlabel);
current_asmdata.asmlists[al_dwarf_aranges].Concat(
tai_const.create_type_sym(aitconst_ptr_unaligned,current_asmdata.RefAsmSymbol(procentry)));
current_asmdata.asmlists[al_dwarf_aranges].Concat(
tai_const.Create_rel_sym(aitconst_ptr_unaligned,current_asmdata.RefAsmSymbol(procentry),procendlabel));
end; end;
{ Don't write the funcretsym explicitly, it's also in the { Don't write the funcretsym explicitly, it's also in the
@ -3152,7 +3157,7 @@ implementation
var var
storefilepos : tfileposinfo; storefilepos : tfileposinfo;
lenstartlabel : tasmlabel; lenstartlabel,arangestartlabel: tasmlabel;
i : longint; i : longint;
def: tdef; def: tdef;
dbgname: string; dbgname: string;
@ -3192,6 +3197,36 @@ implementation
{ start abbrev section } { start abbrev section }
new_section(current_asmdata.asmlists[al_dwarf_abbrev],sec_debug_abbrev,'',0); new_section(current_asmdata.asmlists[al_dwarf_abbrev],sec_debug_abbrev,'',0);
{ start aranges section }
new_section(current_asmdata.asmlists[al_dwarf_aranges],sec_debug_aranges,'',0);
current_asmdata.getlabel(arangestartlabel,alt_dbgfile);
if use_64bit_headers then
current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_32bit_unaligned(longint($FFFFFFFF)));
current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_rel_sym(offsetreltype,
arangestartlabel,current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'earanges0',AB_LOCAL,AT_DATA)));
current_asmdata.asmlists[al_dwarf_aranges].concat(tai_label.create(arangestartlabel));
current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_16bit_unaligned(2));
if not(tf_dwarf_relative_addresses in target_info.flags) then
current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_type_sym(offsetabstype,
current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_info0',AB_LOCAL,AT_DATA)))
else
current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_rel_sym(offsetreltype,
current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_infosection0',AB_LOCAL,AT_DATA),
current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_info0',AB_LOCAL,AT_DATA)));
current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_8bit(sizeof(pint)));
current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_8bit(0));
{ alignment }
current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_32bit_unaligned(0));
{ start ranges section }
new_section(current_asmdata.asmlists[al_dwarf_ranges],sec_debug_ranges,'',0);
{ debug info header } { debug info header }
current_asmdata.getlabel(lenstartlabel,alt_dbgfile); current_asmdata.getlabel(lenstartlabel,alt_dbgfile);
{ size } { size }
@ -3286,6 +3321,11 @@ implementation
{ end of abbrev table } { end of abbrev table }
current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_8bit(0)); current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_8bit(0));
{ end of aranges table }
current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.Create_aint(0));
current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.Create_aint(0));
current_asmdata.asmlists[al_dwarf_aranges].concat(tai_symbol.createname(target_asm.labelprefix+'earanges0',AT_DATA,0));
{ reset all def debug states } { reset all def debug states }
for i:=0 to defnumberlist.count-1 do for i:=0 to defnumberlist.count-1 do
begin begin

View File

@ -1169,6 +1169,8 @@ implementation
{debug_info} [oso_Data,oso_debug], {debug_info} [oso_Data,oso_debug],
{debug_line} [oso_Data,oso_debug], {debug_line} [oso_Data,oso_debug],
{debug_abbrev} [oso_Data,oso_debug], {debug_abbrev} [oso_Data,oso_debug],
{debug_aranges} [oso_Data,oso_debug],
{debug_ranges} [oso_Data,oso_debug],
{fpc} [oso_Data,oso_load,oso_write], {fpc} [oso_Data,oso_load,oso_write],
{toc} [oso_Data,oso_load], {toc} [oso_Data,oso_load],
{init} [oso_Data,oso_load,oso_executable], {init} [oso_Data,oso_load,oso_executable],
@ -1218,7 +1220,7 @@ implementation
function TObjData.sectiontype2align(atype:TAsmSectiontype):shortint; function TObjData.sectiontype2align(atype:TAsmSectiontype):shortint;
begin begin
case atype of case atype of
sec_stabstr,sec_debug_info,sec_debug_line,sec_debug_abbrev: sec_stabstr,sec_debug_info,sec_debug_line,sec_debug_abbrev,sec_debug_aranges,sec_debug_ranges:
result:=1; result:=1;
sec_code, sec_code,
sec_bss, sec_bss,

View File

@ -507,7 +507,7 @@ implementation
'.stab','.stabstr', '.stab','.stabstr',
'.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata', '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
'.eh_frame', '.eh_frame',
'.debug_frame','.debug_info','.debug_line','.debug_abbrev', '.debug_frame','.debug_info','.debug_line','.debug_abbrev','.debug_aranges','.debug_ranges',
'.fpc', '.fpc',
'', '',
'.init', '.init',

View File

@ -759,7 +759,7 @@ implementation
'.stab','.stabstr', '.stab','.stabstr',
'.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata', '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
'.eh_frame', '.eh_frame',
'.debug_frame','.debug_info','.debug_line','.debug_abbrev', '.debug_frame','.debug_info','.debug_line','.debug_abbrev','.debug_aranges','.debug_ranges',
'.fpc', '.fpc',
'.toc', '.toc',
'.init', '.init',

View File

@ -180,8 +180,8 @@ uses
function TmachoObjData.sectionname(atype: TAsmSectiontype; const aname: string; aorder: TAsmSectionOrder): string; function TmachoObjData.sectionname(atype: TAsmSectiontype; const aname: string; aorder: TAsmSectionOrder): string;
const const
DwarfSect : array [sec_debug_frame..sec_debug_abbrev] of string DwarfSect : array [sec_debug_frame..sec_debug_ranges] of string
= ('sec_debug_frame','__debug_info','__debug_line','__debug_abbrev'); = ('sec_debug_frame','__debug_info','__debug_line','__debug_abbrev','__debug_aranges','__debug_ranges');
begin begin
case atype of case atype of
sec_user: Result:=aname; sec_user: Result:=aname;
@ -243,7 +243,9 @@ uses
sec_debug_frame, sec_debug_frame,
sec_debug_info, sec_debug_info,
sec_debug_line, sec_debug_line,
sec_debug_abbrev: sec_debug_abbrev,
sec_debug_aranges,
sec_debug_ranges:
Result:=MakeSectionName(seg_DWARF, DwarfSect[atype]) Result:=MakeSectionName(seg_DWARF, DwarfSect[atype])
else else

View File

@ -549,7 +549,7 @@ implementation
TOmfObjSection(Result).FClassName:=sectiontype2class(atype); TOmfObjSection(Result).FClassName:=sectiontype2class(atype);
if atype=sec_stack then if atype=sec_stack then
TOmfObjSection(Result).FCombination:=scStack TOmfObjSection(Result).FCombination:=scStack
else if atype in [sec_debug_frame,sec_debug_info,sec_debug_line,sec_debug_abbrev] then else if atype in [sec_debug_frame,sec_debug_info,sec_debug_line,sec_debug_abbrev,sec_debug_aranges,sec_debug_ranges] then
TOmfObjSection(Result).FUse:=suUse32; TOmfObjSection(Result).FUse:=suUse32;
if section_belongs_to_dgroup(atype) then if section_belongs_to_dgroup(atype) then
TOmfObjSection(Result).FPrimaryGroup:='DGROUP'; TOmfObjSection(Result).FPrimaryGroup:='DGROUP';

View File

@ -46,7 +46,7 @@ interface
'stabstr', 'stabstr',
'idata2','idata4','idata5','idata6','idata7','edata', 'idata2','idata4','idata5','idata6','idata7','edata',
'eh_frame', 'eh_frame',
'debug_frame','debug_info','debug_line','debug_abbrev', 'debug_frame','debug_info','debug_line','debug_abbrev','debug_aranges','debug_ranges',
'fpc', 'fpc',
'', '',
'init', 'init',
@ -2250,6 +2250,8 @@ implementation
{debug_info} 'DWARF', {debug_info} 'DWARF',
{debug_line} 'DWARF', {debug_line} 'DWARF',
{debug_abbrev} 'DWARF', {debug_abbrev} 'DWARF',
{debug_aranges} 'DWARF',
{debug_ranges} 'DWARF',
{fpc} 'DATA', {fpc} 'DATA',
{toc} 'DATA', {toc} 'DATA',
{init} 'CODE', {init} 'CODE',
@ -2320,7 +2322,7 @@ implementation
be packed without gaps. } be packed without gaps. }
sec_idata2,sec_idata4,sec_idata5,sec_idata6,sec_idata7,sec_pdata: sec_idata2,sec_idata4,sec_idata5,sec_idata6,sec_idata7,sec_pdata:
result:=4; result:=4;
sec_debug_frame,sec_debug_info,sec_debug_line,sec_debug_abbrev: sec_debug_frame,sec_debug_info,sec_debug_line,sec_debug_abbrev,sec_debug_aranges,sec_debug_ranges:
result:=4; result:=4;
sec_stack, sec_stack,
sec_heap: sec_heap:

View File

@ -68,7 +68,7 @@ implementation
'', '',
'', '',
'', '',
'','','','', '','','','','','',
'', '',
'', '',
'', '',
@ -120,7 +120,7 @@ implementation
'', '',
'', '',
'', '',
'','','','', '','','','','','',
'', '',
'', '',
'', '',

View File

@ -523,7 +523,7 @@ interface
'.stabstr', '.stabstr',
'.idata2','.idata4','.idata5','.idata6','.idata7','.edata', '.idata2','.idata4','.idata5','.idata6','.idata7','.edata',
'.eh_frame', '.eh_frame',
'.debug_frame','.debug_info','.debug_line','.debug_abbrev', '.debug_frame','.debug_info','.debug_line','.debug_abbrev','.debug_aranges','.debug_ranges',
'.fpc', '.fpc',
'', '',
'.init', '.init',
@ -596,7 +596,7 @@ interface
{ yes -> write the section attributes as well } { yes -> write the section attributes as well }
if atype=sec_stack then if atype=sec_stack then
writer.AsmWrite(' stack'); writer.AsmWrite(' stack');
if atype in [sec_debug_frame,sec_debug_info,sec_debug_line,sec_debug_abbrev] then if atype in [sec_debug_frame,sec_debug_info,sec_debug_line,sec_debug_abbrev,sec_debug_aranges,sec_debug_ranges] then
writer.AsmWrite(' use32') writer.AsmWrite(' use32')
else else
writer.AsmWrite(' use16'); writer.AsmWrite(' use16');