Skip to content

Commit 35ff977

Browse files
committed
More assembly store code
1 parent 2568be8 commit 35ff977

14 files changed

+252
-30
lines changed

tools/apput/src/AssemblyStore/AssemblyStore.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,11 @@ static IAspectState DoProbeAspect (Stream storeStream, string? description)
6767
}
6868

6969
uint version = reader.ReadUInt32 ();
70-
71-
// We currently support version 3. Main store version is kept in the lower 16 bits of the version word
72-
uint mainVersion = version & 0xFFFF;
70+
var storeVersion = new AssemblyStoreVersion (version);
7371
FormatBase? validator = null;
72+
Log.Debug ($"AssemblyStore: store format version {storeVersion.MainVersion}");
7473

75-
switch (mainVersion) {
74+
switch (storeVersion.MainVersion) {
7675
case 2:
7776
validator = new Format_V2 (storeStream, description);
7877
break;
@@ -82,7 +81,7 @@ static IAspectState DoProbeAspect (Stream storeStream, string? description)
8281
break;
8382

8483
default:
85-
Log.Debug ($"AssemblyStore: unsupported store version: {mainVersion}");
84+
Log.Debug ($"AssemblyStore: unsupported store version: {storeVersion.MainVersion}");
8685
return new BasicAspectState (false);
8786
}
8887

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
namespace ApplicationUtility;
22

33
// Values correspond to those in `xamarin-app.hh`
4-
enum AssemblyStoreABI
4+
enum AssemblyStoreABI : uint
55
{
6-
Arm64 = 0x00010000,
7-
Arm = 0x00020000,
8-
X86 = 0x00030000,
9-
X64 = 0x00040000,
6+
Unknown = 0x00000000,
7+
8+
Arm64 = 0x00010000,
9+
Arm = 0x00020000,
10+
X86 = 0x00030000,
11+
X64 = 0x00040000,
1012
}

tools/apput/src/AssemblyStore/AssemblyStoreAspectState.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace ApplicationUtility;
55
class AssemblyStoreAspectState : BasicAspectState
66
{
77
public AssemblyStoreHeader Header { get; }
8-
public AssemblyStoreIndex Index { get; }
8+
public FormatBase Format { get; }
99

1010
public AssemblyStoreAspectState (bool success)
1111
: base (success)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
namespace ApplicationUtility;
2+
3+
abstract class AssemblyStoreAssemblyDescriptor
4+
{}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace ApplicationUtility;
2+
3+
class AssemblyStoreAssemblyDescriptorV2 : AssemblyStoreAssemblyDescriptor
4+
{
5+
public uint MappingIndex { get; internal set; }
6+
public uint DataOffset { get; internal set; }
7+
public uint DataSize { get; internal set; }
8+
public uint DebugDataOffset { get; internal set; }
9+
public uint DebugDataSize { get; internal set; }
10+
public uint ConfigDataOffset { get; internal set; }
11+
public uint ConfigDataSize { get; internal set; }
12+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
namespace ApplicationUtility;
2+
3+
// Format is identical to V2, class exists merely for versioning consistency
4+
class AssemblyStoreAssemblyDescriptorV3 : AssemblyStoreAssemblyDescriptorV2
5+
{}

tools/apput/src/AssemblyStore/AssemblyStoreHeader.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@ namespace ApplicationUtility;
1313
/// </summary>
1414
class AssemblyStoreHeader
1515
{
16-
public AssemblyStoreVersion Version { get; protected set; }
17-
public uint? EntryCount { get; protected set; }
18-
public uint? IndexEntryCount { get; protected set; }
19-
public uint? IndexSize { get; protected set; }
16+
public AssemblyStoreVersion Version { get; }
17+
public uint? EntryCount { get; internal set; }
18+
public uint? IndexEntryCount { get; internal set; }
19+
public uint? IndexSize { get; internal set; }
20+
21+
public AssemblyStoreHeader (AssemblyStoreVersion version)
22+
{
23+
Version = version;
24+
}
2025
}

tools/apput/src/AssemblyStore/AssemblyStoreIndex.cs

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace ApplicationUtility;
2+
3+
class AssemblyStoreIndexEntryV3
4+
{
5+
6+
}
Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,36 @@
1+
using System;
2+
13
namespace ApplicationUtility;
24

35
class AssemblyStoreVersion
46
{
7+
public uint RawVersion { get; }
58
public uint MainVersion { get; }
69
public AssemblyStoreABI ABI { get; }
710
public bool Is64Bit { get; }
811

9-
internal AssemblyStoreVersion (uint mainVersion, AssemblyStoreABI abi, bool is64Bit)
12+
internal AssemblyStoreVersion (uint rawVersion)
1013
{
11-
MainVersion = mainVersion;
12-
ABI = abi;
13-
Is64Bit = is64Bit;
14+
RawVersion = rawVersion;
15+
Log.Debug ($"AssemblyStoreVersion: raw version is 0x{rawVersion:x}");
16+
17+
// Main store version is kept in the lower 16 bits of the version word
18+
MainVersion = rawVersion & 0xFFFF;
19+
Log.Debug ($"AssemblyStoreVersion: main version is {MainVersion}");
20+
21+
// ABI is kept in the higher 15 bits of the version word
22+
uint abi = rawVersion & 0x7FFF0000;
23+
Log.Debug ($"AssemblyStoreVersion: raw ABI value is 0x{abi:x}");
24+
25+
if (Enum.IsDefined (typeof(AssemblyStoreABI), abi)) {
26+
ABI = (AssemblyStoreABI)abi;
27+
} else {
28+
ABI = AssemblyStoreABI.Unknown;
29+
}
30+
Log.Debug ($"AssemblyStoreVersion: ABI is {ABI}");
31+
32+
// 64-bit flag is the leftmost bit in the word
33+
Is64Bit = (rawVersion & 0x80000000) == 0x80000000;
34+
Log.Debug ($"AssemblyStoreVersion: is store 64-bit? {Is64Bit}");
1435
}
1536
}

0 commit comments

Comments
 (0)