@@ -49,6 +49,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
49
49
#endif
50
50
#include " llvm/MC/MCSection.h"
51
51
#include " llvm/MC/MachineLocation.h"
52
+ #include " llvm/MC/MCSymbol.h"
53
+ #include " llvm/MC/MCSymbolELF.h"
52
54
#include " llvm/IR/GlobalValue.h"
53
55
#include " llvm/IR/IntrinsicInst.h"
54
56
#include " common/LLVMWarningsPop.hpp"
@@ -297,6 +299,16 @@ void CompileUnit::addLabelAddress(DIE* Die, dwarf::Attribute Attribute, MCSymbol
297
299
}
298
300
}
299
301
302
+ void CompileUnit::addLabelLoc (DIE* Die, dwarf::Attribute Attribute, MCSymbol* Label)
303
+ {
304
+ if (Label != NULL )
305
+ {
306
+ DD->addArangeLabel (SymbolCU (this , Label));
307
+ DIEValue* Value = new (DIEValueAllocator)DIELabel (Label);
308
+ Die->addValue (Attribute, dwarf::DW_FORM_sec_offset, Value);
309
+ }
310
+ }
311
+
300
312
// / addOpAddress - Add a dwarf op address data and value using the
301
313
// / form given and an op of either DW_FORM_addr or DW_FORM_GNU_addr_index.
302
314
// /
@@ -2129,8 +2141,19 @@ IGC::DIE* CompileUnit::constructVariableDIE(DbgVariable& DV, bool isScopeAbstrac
2129
2141
if (DD->IsDirectElfInput ())
2130
2142
{
2131
2143
// Copy over references ranges to DotLocDebugEntries
2132
- Offset = DD->CopyDebugLoc (Offset);
2133
- addUInt (VariableDie, dwarf::DW_AT_location, dwarf::DW_FORM_sec_offset, Offset);
2144
+ if (EmitSettings.EnableRelocation )
2145
+ {
2146
+ // Retrieve correct location value based on Offset.
2147
+ // Then attach label corresponding to this offset
2148
+ // to DW_AT_location attribute.
2149
+ auto LocLabel = DD->CopyDebugLoc (Offset);
2150
+ addLabelLoc (VariableDie, dwarf::DW_AT_location, LocLabel);
2151
+ }
2152
+ else
2153
+ {
2154
+ Offset = DD->CopyDebugLocNoReloc (Offset);
2155
+ addUInt (VariableDie, dwarf::DW_AT_location, dwarf::DW_FORM_sec_offset, Offset);
2156
+ }
2134
2157
if (DV.getDecorations ().size () > 0 )
2135
2158
{
2136
2159
addString (VariableDie, dwarf::DW_AT_description, DV.getDecorations ());
@@ -2760,7 +2783,11 @@ void CompileUnit::emitHeader(const MCSection* ASection, const MCSymbol* ASection
2760
2783
// Emit ("DWARF version number");
2761
2784
Asm->EmitInt16 (DD->getDwarfVersion ());
2762
2785
// Emit ("Offset Into Abbrev. Section");
2763
- Asm->EmitSectionOffset (Asm->GetTempSymbol (/* ASection->getLabelBeginName()*/ " .debug_abbrev_begin" ), ASectionSym);
2786
+ if (EmitSettings.EnableRelocation )
2787
+ // Emit 4-byte offset since we're using DWARF4 32-bit format
2788
+ Asm->EmitLabelReference (Asm->GetTempSymbol (/* ASection->getLabelBeginName()*/ " .debug_abbrev_begin" ), 4 );
2789
+ else
2790
+ Asm->EmitSectionOffset (Asm->GetTempSymbol (/* ASection->getLabelBeginName()*/ " .debug_abbrev_begin" ), ASectionSym);
2764
2791
// Emit ("Address Size (in bytes)");
2765
2792
Asm->EmitInt8 (Asm->GetPointerSize ());
2766
2793
}
0 commit comments