Skip to content

Commit 29184cb

Browse files
committed
Fix --host-only problem with 5.x runtime
Look for Interp program headers to find host. It also finds libc-2.27.so and libpthread-2.27.so. Issue: dotnet#179
1 parent b99d7d1 commit 29184cb

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/Microsoft.FileFormats/ELF/ELFFile.cs

+15
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,21 @@ public ELFSection FindSectionByName(string name)
109109
return null;
110110
}
111111

112+
public ELFProgramSegment FindProgramSegment(ELFProgramHeaderType type)
113+
{
114+
if (Header.ProgramHeaderOffset > 0 && Header.ProgramHeaderEntrySize > 0 && Header.ProgramHeaderCount > 0)
115+
{
116+
foreach (ELFProgramSegment segment in Segments)
117+
{
118+
if (segment.Header.Type == type)
119+
{
120+
return segment;
121+
}
122+
}
123+
}
124+
return null;
125+
}
126+
112127
private IEnumerable<ELFProgramSegment> ReadSegments()
113128
{
114129
Header.IsProgramHeaderCountReasonable.CheckThrowing();

src/Microsoft.SymbolStore/KeyGenerators/ELFFileKeyGenerator.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public override IEnumerable<SymbolStoreKey> GetKeys(KeyTypeFlags flags)
6767
}
6868
if ((flags & KeyTypeFlags.HostKeys) != 0)
6969
{
70-
if (_elfFile.Header.Type == ELFHeaderType.Executable)
70+
if (_elfFile.Header.Type == ELFHeaderType.Executable ||
71+
_elfFile.FindProgramSegment(ELFProgramHeaderType.Interp) != null)
7172
{
7273
// The host program as itself (usually dotnet)
7374
yield return BuildKey(_path, IdentityPrefix, buildId);

0 commit comments

Comments
 (0)