-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: add support for VAX a.out object files
Fix some incorrectly disassembled + rewritten VAX instructions.
- Loading branch information
Showing
36 changed files
with
112,285 additions
and
68,550 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Import Project="$(ProjectDir)../../Drivers/CommonBuildProperties.items" /> | ||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> | ||
<RootNamespace>Reko.ImageLoaders.AOut</RootNamespace> | ||
<AssemblyName>Reko.ImageLoaders.AOut</AssemblyName> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="../../Core/Core.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
using Reko.Core; | ||
using Reko.Core.Configuration; | ||
using Reko.Core.IO; | ||
using Reko.Core.Loading; | ||
using Reko.Core.Memory; | ||
using Reko.Core.Services; | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace Reko.ImageLoaders.AOut | ||
{ | ||
public class AOutLoader : ProgramImageLoader | ||
{ | ||
public AOutLoader( | ||
IServiceProvider services, | ||
ImageLocation imageLocation, | ||
byte[] bytes) | ||
: base(services, imageLocation, bytes) | ||
{ | ||
this.PreferredBaseAddress = Address.Ptr32(0x00000000); | ||
} | ||
|
||
public override Address PreferredBaseAddress { get; set; } | ||
|
||
public override Program LoadProgram(Address? address) | ||
{ | ||
ushort magic = ByteMemoryArea.ReadLeUInt16(base.RawImage, 0); | ||
var cfgSvc = Services.RequireService<IConfigurationService>(); | ||
if (magic == 0x010B) | ||
{ | ||
var rdr = new ByteImageReader(RawImage); | ||
var vaxHeader = rdr.ReadStruct<vax_header>(); | ||
rdr.Offset = 0x400; | ||
var textBytes = rdr.ReadBytes(vaxHeader.a_text); | ||
var uAddrData = (uint) rdr.Offset; | ||
var dataBytes = rdr.ReadBytes(vaxHeader.a_data); | ||
var uAddrBss = (uint) rdr.Offset; | ||
var bssBytes = new byte[vaxHeader.a_bss]; | ||
|
||
var segmentMap = new SegmentMap( | ||
Seg(".text", 0x400, textBytes, AccessMode.ReadExecute), | ||
Seg(".data", uAddrData, dataBytes, AccessMode.ReadWrite), | ||
Seg(".bss", uAddrBss, bssBytes, AccessMode.ReadWrite)); | ||
|
||
var arch = cfgSvc.GetArchitecture("vax")!; | ||
|
||
var uAddrEntry = vaxHeader.a_entry != 0 | ||
? vaxHeader.a_entry | ||
: 0x404u; | ||
var entry = ImageSymbol.Location(arch, Address.Ptr32(uAddrEntry)); // Entry point | ||
|
||
var program = new Program( | ||
new ProgramMemory(segmentMap), | ||
arch, | ||
new DefaultPlatform(Services, arch, "VAX Unix")); //$TODO: VaxVms platform | ||
program.EntryPoints.Add(entry.Address, entry); | ||
|
||
return program; | ||
} | ||
|
||
throw new NotSupportedException("This a.out variant is not supported yet."); | ||
} | ||
|
||
private static ImageSegment Seg(string segmentName, uint uAddr, byte[] bytes, AccessMode access) | ||
{ | ||
var addr = Address.Ptr32(uAddr); | ||
var mem = new ByteMemoryArea(addr, bytes); | ||
var segment = new ImageSegment(segmentName, mem, access); | ||
return segment; | ||
} | ||
} | ||
|
||
[StructLayout(LayoutKind.Sequential, Pack = 1)] | ||
[Endian(Endianness.LittleEndian)] | ||
|
||
public struct vax_header | ||
{ | ||
public uint a_magic; // Magic number | ||
public uint a_text; // Size of text segment | ||
public uint a_data; // Size of data segment | ||
public uint a_bss; // Size of bss segment | ||
public uint a_syms; // Size of symbol table | ||
public uint a_entry; // Entry point | ||
public uint a_trsize; // Size of text relocation | ||
public uint a_drsize; // Size of data relocation | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#region License | ||
/* | ||
* Copyright (C) 1999-2024 John Källén. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2, or (at your option) | ||
* any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; see the file COPYING. If not, write to | ||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | ||
*/ | ||
#endregion | ||
|
||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("a.out")] | ||
[assembly: AssemblyDescription("Reko Decompiler support for the a.out executable file format.")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany(Reko.AssemblyMetadata.Company)] | ||
[assembly: AssemblyProduct(Reko.AssemblyMetadata.Product)] | ||
[assembly: AssemblyCopyright(Reko.AssemblyMetadata.Copyright)] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
[assembly: AssemblyVersion(Reko.AssemblyMetadata.AssemblyVersion)] | ||
[assembly: AssemblyFileVersion(Reko.AssemblyMetadata.AssemblyFileVersion)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.