Skip to content

Commit

Permalink
ObjWriter: Do not generate relocations within .debug_info for DW_AT_t…
Browse files Browse the repository at this point in the history
…ype (#98597)

* Do not generate relocations within .debug_info for DW_AT_type

* Fix WriteInfoAbsReference
  • Loading branch information
filipnavara authored Feb 20, 2024
1 parent 922a04f commit bee4602
Showing 1 changed file with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Buffers;
using System.Buffers.Binary;
using System.Collections.Generic;
using System.Diagnostics;
using ILCompiler.DependencyAnalysis;
Expand Down Expand Up @@ -106,7 +107,7 @@ public void WriteStringReference(string value)
public void WriteInfoAbsReference(long offset)
{
Debug.Assert(offset < uint.MaxValue);
_infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_info", offset);
WriteUInt32((uint)offset);
}

public void WriteInfoReference(uint typeIndex)
Expand All @@ -122,7 +123,7 @@ public void WriteInfoReference(uint typeIndex)
}
else
{
_infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_info", offset);
WriteUInt32(offset);
}
}

Expand Down Expand Up @@ -195,17 +196,10 @@ public void Dispose()
// Debug.Assert(_dieStack.Count == 0);

// Flush late bound forward references
int streamOffset = (int)_infoSectionWriter.Position;
foreach (var lateBoundReference in _lateBoundReferences)
{
uint offset = _builder.ResolveOffset(lateBoundReference.TypeIndex);

_infoSectionWriter.EmitRelocation(
- streamOffset + lateBoundReference.Position,
lateBoundReference.Data,
RelocType.IMAGE_REL_BASED_HIGHLOW,
".debug_info",
(int)offset);
BinaryPrimitives.WriteUInt32LittleEndian(lateBoundReference.Data, offset);
}

// Write abbreviation section
Expand Down

0 comments on commit bee4602

Please sign in to comment.