@@ -282,10 +282,18 @@ DIE *DwarfDebug::updateSubprogramScopeDIE(CompileUnit *SPCU, DISubprogram* SP)
282
282
}
283
283
284
284
#if 1
285
- SPCU->addLabelAddress (SPDie, dwarf::DW_AT_low_pc,
286
- Asm->GetTempSymbol (" func_begin" , m_pModule->GetFunctionNumber (SP->getName ().data ())));
287
- SPCU->addLabelAddress (SPDie, dwarf::DW_AT_high_pc,
288
- Asm->GetTempSymbol (" func_end" , m_pModule->GetFunctionNumber (SP->getName ().data ())));
285
+ if (m_pModule->isDirectElfInput )
286
+ {
287
+ SPCU->addUInt (SPDie, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, lowPc);
288
+ SPCU->addUInt (SPDie, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr, highPc);
289
+ }
290
+ else
291
+ {
292
+ SPCU->addLabelAddress (SPDie, dwarf::DW_AT_low_pc,
293
+ Asm->GetTempSymbol (" func_begin" , m_pModule->GetFunctionNumber (SP->getName ().data ())));
294
+ SPCU->addLabelAddress (SPDie, dwarf::DW_AT_high_pc,
295
+ Asm->GetTempSymbol (" func_end" , m_pModule->GetFunctionNumber (SP->getName ().data ())));
296
+ }
289
297
#else
290
298
// Following existed before supporting stack calls. GetFunctionNumber() was hard
291
299
// coded to return 0 always so for single function this worked. With stackcall
@@ -630,32 +638,35 @@ CompileUnit *DwarfDebug::constructCompileUnit(DICompileUnit* DIUnit)
630
638
Asm->EmitLabel (ModuleBeginSym);
631
639
// 2.17.1 requires that we use DW_AT_low_pc for a single entry point
632
640
// into an entity. We're using 0 (or a NULL label) for this.
633
- NewCU-> addLabelAddress (Die, dwarf::DW_AT_low_pc, ModuleBeginSym);
641
+
634
642
if (m_pModule->isDirectElfInput )
635
643
{
636
644
auto highPC = m_pModule->getUnpaddedProgramSize ();
645
+ NewCU->addUInt (Die, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, 0 );
637
646
NewCU->addUInt (Die, dwarf::DW_AT_high_pc, Optional<dwarf::Form>(), highPC);
647
+
648
+ // DW_AT_stmt_list is a offset of line number information for this
649
+ // compile unit in debug_line section. For split dwarf this is
650
+ // left in the skeleton CU and so not included.
651
+ // The line table entries are not always emitted in assembly, so it
652
+ // is not okay to use line_table_start here.
653
+ NewCU->addUInt (Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_sec_offset, 0 );
638
654
}
639
655
else
640
656
{
657
+ NewCU->addLabelAddress (Die, dwarf::DW_AT_low_pc, ModuleBeginSym);
641
658
NewCU->addLabelAddress (Die, dwarf::DW_AT_high_pc, ModuleEndSym);
642
- }
643
-
644
- // Define start line table label for each Compile Unit.
645
- MCSymbol *LineTableStartSym = Asm->GetTempSymbol (" line_table_start" , NewCU->getUniqueID ());
646
- Asm->SetMCLineTableSymbol (LineTableStartSym, NewCU->getUniqueID ());
647
659
648
- // Use a single line table if we are using .loc and generating assembly.
649
- bool UseTheFirstCU = (NewCU->getUniqueID () == 0 );
660
+ // Define start line table label for each Compile Unit.
661
+ MCSymbol *LineTableStartSym = Asm->GetTempSymbol (" line_table_start" , NewCU->getUniqueID ());
662
+ Asm->SetMCLineTableSymbol (LineTableStartSym, NewCU->getUniqueID ());
650
663
651
-
652
- // DW_AT_stmt_list is a offset of line number information for this
653
- // compile unit in debug_line section. For split dwarf this is
654
- // left in the skeleton CU and so not included.
655
- // The line table entries are not always emitted in assembly, so it
656
- // is not okay to use line_table_start here.
657
- NewCU->addLabel (Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_sec_offset,
664
+ // Use a single line table if we are using .loc and generating assembly.
665
+ bool UseTheFirstCU = (NewCU->getUniqueID () == 0 );
666
+ NewCU->addLabel (Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_sec_offset,
658
667
UseTheFirstCU ? Asm->GetTempSymbol (" section_line" ) : LineTableStartSym);
668
+ }
669
+
659
670
// If we're using split dwarf the compilation dir is going to be in the
660
671
// skeleton CU and so we don't need to duplicate it here.
661
672
if (!CompilationDir.empty ())
@@ -1764,8 +1775,7 @@ void DwarfDebug::emitDIE(DIE *Die)
1764
1775
}
1765
1776
case dwarf::DW_AT_ranges:
1766
1777
// DW_AT_range Value encodes offset in debug_range section.
1767
- Asm->EmitLabelPlusOffset (DwarfDebugRangeSectionSym,
1768
- cast<DIEInteger>(Values[i])->getValue (), 4 );
1778
+ Values[i]->EmitValue (Asm, Form);
1769
1779
break ;
1770
1780
case dwarf::DW_AT_location:
1771
1781
if (DIELabel *L = dyn_cast<DIELabel>(Values[i]))
0 commit comments