Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sudoudaisuke opened this issue Nov 20, 2024 · 0 comments
Labels
Enhancement Areas for improvement r2r

Comments

@sudoudaisuke
Copy link

sudoudaisuke commented Nov 20, 2024

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
@sudoudaisuke sudoudaisuke added the Enhancement Areas for improvement label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Areas for improvement r2r
Projects
None yet
Development

No branches or pull requests

2 participants