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

Update Architecture to unknown machine #101038

Merged
merged 4 commits into from
Apr 15, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 1 addition & 31 deletions src/tools/illink/src/linker/Linker.Steps/OutputStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,43 +42,13 @@ namespace Mono.Linker.Steps

public class OutputStep : BaseStep
{
private Dictionary<ushort, TargetArchitecture>? architectureMap;

private enum NativeOSOverride
{
Apple = 0x4644,
FreeBSD = 0xadc4,
Linux = 0x7b79,
NetBSD = 0x1993,
Default = 0
}

readonly List<string> assembliesWritten;

public OutputStep ()
{
assembliesWritten = new List<string> ();
}

TargetArchitecture CalculateArchitecture (TargetArchitecture readyToRunArch)
{
if (architectureMap == null) {
architectureMap = new Dictionary<ushort, TargetArchitecture> ();
foreach (var os in Enum.GetValues (typeof (NativeOSOverride))) {
ushort osVal = (ushort) (NativeOSOverride) os;
foreach (var arch in Enum.GetValues (typeof (TargetArchitecture))) {
ushort archVal = (ushort) (TargetArchitecture) arch;
architectureMap.Add ((ushort) (archVal ^ osVal), (TargetArchitecture) arch);
}
}
}

if (architectureMap.TryGetValue ((ushort) readyToRunArch, out TargetArchitecture pureILArch)) {
return pureILArch;
}
throw new BadImageFormatException ("unrecognized module attributes");
}

protected override bool ConditionToProcess ()
{
return Context.ErrorsCount == 0;
Expand Down Expand Up @@ -125,7 +95,7 @@ protected virtual void WriteAssembly (AssemblyDefinition assembly, string direct
if (module.IsCrossgened ()) {
module.Attributes |= ModuleAttributes.ILOnly;
module.Attributes ^= ModuleAttributes.ILLibrary;
module.Architecture = CalculateArchitecture (module.Architecture);
module.Architecture = (TargetArchitecture)0x0001; // MSIL architecture which ultimately translates to AnyCPU
jkotas marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
Loading