From c073362928049cf8ff1607e8355cd21ef3160f20 Mon Sep 17 00:00:00 2001 From: nickysn Date: Thu, 4 Feb 2021 10:07:17 +0000 Subject: [PATCH] - don't emit DEBUGSTART and DEBUGEND symbols for WebAssembly. See https://bugs.llvm.org/show_bug.cgi?id=48971 git-svn-id: branches/wasm@48509 - --- compiler/dbgdwarf.pas | 79 ++++++++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 34 deletions(-) diff --git a/compiler/dbgdwarf.pas b/compiler/dbgdwarf.pas index 28d83b43ec..9629546dc2 100644 --- a/compiler/dbgdwarf.pas +++ b/compiler/dbgdwarf.pas @@ -3257,30 +3257,33 @@ implementation flist : TFPList; dbgname : String; begin - { insert DEBUGSTART and DEBUGEND labels } - dbgname:=make_mangledname('DEBUGSTART',current_module.localsymtable,''); - { Darwin's linker does not like two global labels both pointing to the - end of a section, which can happen in case of units without code -> - make them local; we don't need the debugtable stuff there either, - so it doesn't matter that they are not global. - } - if (target_info.system in systems_darwin) then - dbgname:='L'+dbgname; - new_section(current_asmdata.asmlists[al_start],sec_code,dbgname,0,secorder_begin); - if not(target_info.system in systems_darwin) then - current_asmdata.asmlists[al_start].concat(tai_symbol.Createname_global(dbgname,AT_METADATA,0,voidpointertype)) - else - current_asmdata.asmlists[al_start].concat(tai_symbol.Createname(dbgname,AT_METADATA,0,voidpointertype)); + if not (target_info.system in systems_wasm) then + begin + { insert DEBUGSTART and DEBUGEND labels } + dbgname:=make_mangledname('DEBUGSTART',current_module.localsymtable,''); + { Darwin's linker does not like two global labels both pointing to the + end of a section, which can happen in case of units without code -> + make them local; we don't need the debugtable stuff there either, + so it doesn't matter that they are not global. + } + if (target_info.system in systems_darwin) then + dbgname:='L'+dbgname; + new_section(current_asmdata.asmlists[al_start],sec_code,dbgname,0,secorder_begin); + if not(target_info.system in systems_darwin) then + current_asmdata.asmlists[al_start].concat(tai_symbol.Createname_global(dbgname,AT_METADATA,0,voidpointertype)) + else + current_asmdata.asmlists[al_start].concat(tai_symbol.Createname(dbgname,AT_METADATA,0,voidpointertype)); - dbgname:=make_mangledname('DEBUGEND',current_module.localsymtable,''); - { See above. } - if (target_info.system in systems_darwin) then - dbgname:='L'+dbgname; - new_section(current_asmdata.asmlists[al_end],sec_code,dbgname,0,secorder_end); - if not(target_info.system in systems_darwin) then - current_asmdata.asmlists[al_end].concat(tai_symbol.Createname_global(dbgname,AT_METADATA,0,voidpointertype)) - else - current_asmdata.asmlists[al_end].concat(tai_symbol.Createname(dbgname,AT_METADATA,0,voidpointertype)); + dbgname:=make_mangledname('DEBUGEND',current_module.localsymtable,''); + { See above. } + if (target_info.system in systems_darwin) then + dbgname:='L'+dbgname; + new_section(current_asmdata.asmlists[al_end],sec_code,dbgname,0,secorder_end); + if not(target_info.system in systems_darwin) then + current_asmdata.asmlists[al_end].concat(tai_symbol.Createname_global(dbgname,AT_METADATA,0,voidpointertype)) + else + current_asmdata.asmlists[al_end].concat(tai_symbol.Createname(dbgname,AT_METADATA,0,voidpointertype)); + end; { insert .Ldebug_abbrev0 label } templist:=TAsmList.create; @@ -3575,19 +3578,27 @@ implementation if (m_objectivec1 in current_settings.modeswitches) then append_attribute(DW_AT_APPLE_major_runtime_vers,DW_FORM_data1,[1]); - dbgname:=make_mangledname('DEBUGSTART',current_module.localsymtable,''); - if (target_info.system in systems_darwin) then + if target_info.system in systems_wasm then begin - bind:=AB_LOCAL; - dbgname:='L'+dbgname; + append_attribute(DW_AT_low_pc,DW_FORM_data4,[0]); + { todo: append DW_AT_ranges } end else - bind:=AB_GLOBAL; - append_labelentry(DW_AT_low_pc,current_asmdata.DefineAsmSymbol(dbgname,bind,AT_METADATA,voidpointertype)); - dbgname:=make_mangledname('DEBUGEND',current_module.localsymtable,''); - if (target_info.system in systems_darwin) then - dbgname:='L'+dbgname; - append_labelentry(DW_AT_high_pc,current_asmdata.DefineAsmSymbol(dbgname,bind,AT_METADATA,voidpointertype)); + begin + dbgname:=make_mangledname('DEBUGSTART',current_module.localsymtable,''); + if (target_info.system in systems_darwin) then + begin + bind:=AB_LOCAL; + dbgname:='L'+dbgname; + end + else + bind:=AB_GLOBAL; + append_labelentry(DW_AT_low_pc,current_asmdata.DefineAsmSymbol(dbgname,bind,AT_METADATA,voidpointertype)); + dbgname:=make_mangledname('DEBUGEND',current_module.localsymtable,''); + if (target_info.system in systems_darwin) then + dbgname:='L'+dbgname; + append_labelentry(DW_AT_high_pc,current_asmdata.DefineAsmSymbol(dbgname,bind,AT_METADATA,voidpointertype)); + end; finish_entry; @@ -3671,7 +3682,7 @@ implementation begin { Reference all DEBUGINFO sections from the main .fpc section } { to prevent eliminating them by smartlinking } - if (target_info.system in ([system_powerpc_macosclassic]+systems_darwin)) then + if (target_info.system in ([system_powerpc_macosclassic]+systems_darwin+systems_wasm)) then exit; new_section(list,sec_fpc,'links',0);