Skip to content

Show architecture name in DLL containing unmanaged code for ReadToRun targeting Linux #3339

@sudoudaisuke

Description

@sudoudaisuke

Is your feature request related to a problem? Please describe.
Publish the dll for linux-x64 ReadyToRun.

<PropertyGroup>
    <PublishReadyToRun>true</PublishReadyToRun>
    <RuntimeIdentifier>linux-x64</RuntimeIdentifier>
</PropertyGroup>

And display the dll header in ILSpy 9.0.0.7833-preview3.

// /tmp/sample.dll
// sample, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// Global type: <Module>
// Entry point: Program.<Main>$
// Architecture: 64797
// This assembly contains unmanaged code.
// Runtime: v4.0.30319
// Hash algorithm: SHA1
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]

"Architecture: 64797 (0xFD1D)" means Linux X64 binary. So please show detailed description instead of numbers.

Additional context

  • public static string GetPlatformDisplayName(PEFile module)
    {
    var headers = module.Reader.PEHeaders;
    var architecture = headers.CoffHeader.Machine;
    var characteristics = headers.CoffHeader.Characteristics;
    var corflags = headers.CorHeader.Flags;
    switch (architecture)
    {
    case Machine.I386:
    if ((corflags & CorFlags.Prefers32Bit) != 0)
    return "AnyCPU (32-bit preferred)";
    if ((corflags & CorFlags.Requires32Bit) != 0)
    return "x86";
    // According to ECMA-335, II.25.3.3.1 CorFlags.Requires32Bit and Characteristics.Bit32Machine must be in sync
    // for assemblies containing managed code. However, this is not true for C++/CLI assemblies.
    if ((corflags & CorFlags.ILOnly) == 0 && (characteristics & Characteristics.Bit32Machine) != 0)
    return "x86";
    return "AnyCPU (64-bit preferred)";
    case Machine.Amd64:
    return "x64";
    case Machine.IA64:
    return "Itanium";
    default:
    return architecture.ToString();
    }
    }
  • Undocumented PE Header Machine Type dotnet/runtime#36364
  • https://github.com/dotnet/runtime/blob/1e3544ec04e27538f3d38d274f7a65277f0d681f/src/coreclr/inc/pedecoder.h#L96-L111

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions