Skip to content

Commit 740256f

Browse files
authored
Rename assembly stores in the APK/AAB archive to libassembly-store.so (#10638)
Fixes: #10634 Amazon application store appears to verify the uploaded archives by, among other steps, comparing names of libraries packaged into per-ABI `lib/` directories. If it finds library names that don't correspond to entries in any of the other `lib/{ABI}` directories, it decides that the application is incorrectly constructed and rejects the upload. In our case the check failed because of names of the assembly store files in the archive which are named `libassemblies.{ABI}.blob.so` and, thus, would have unique entries in every `lib/{ABI}/` directory. This is an artifact from the time where all stores were placed in a single directory (`assemblies/`) and had to have distinct names in order for that to work. The Amazon store check, in this regard, is just an unnecessary obstacle (since there's no reason, technical or otherwise, for different ABIs to have identical sets of libraries), but since a we have no way to fix it other than to comply with the Amazon store requirements and, this PR renames assembly store files to have a uniform name across all the ABIs present in the application: `libassembly-store.so`
1 parent 071973d commit 740256f

File tree

10 files changed

+18
-32
lines changed

10 files changed

+18
-32
lines changed

Documentation/project-docs/ApkSharedLibraries.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ The first command verifies that the file is a valid ELF image and shows the head
107107
target platform/abi/machine:
108108

109109
```shell
110-
$ llvm-readelf --file-header libassemblies.arm64-v8a.blob.so
110+
$ llvm-readelf --file-header libassembly-store.so
111111
ELF Header:
112112
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
113113
Class: ELF64
@@ -134,7 +134,7 @@ The second command lists the sections contained within the ELF image, their alig
134134
into the file where the sections begin:
135135
136136
```shell
137-
$ llvm-readelf --section-headers libassemblies.arm64-v8a.blob.so
137+
$ llvm-readelf --section-headers libassembly-store.so
138138
There are 11 section headers, starting at offset 0xcf648:
139139
140140
Section Headers:
@@ -167,7 +167,7 @@ shared library.
167167
In order to extract payload from the ELF image, one can use the following command:
168168
169169
```shell
170-
$ llvm-objcopy --dump-section=payload=payload.bin libassemblies.arm64-v8a.blob.so
170+
$ llvm-objcopy --dump-section=payload=payload.bin libassembly-store.so
171171
$ ls -gG payload.bin
172172
-rw-rw-r-- 1 833095 Sep 12 11:32 payload.bin
173173
```

src/Xamarin.Android.Build.Tasks/Tasks/CollectRuntimeConfigFilesForArchive.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public override bool RunTask ()
4343
// ABI-specific data+code.
4444
if (!RuntimeConfigBinFilePath.IsNullOrEmpty () && File.Exists (RuntimeConfigBinFilePath)) {
4545
foreach (var abi in SupportedAbis) {
46-
// Prefix it with `a` because bundletool sorts entries alphabetically, and this will place it right next to `assemblies.*.blob.so`, which is what we
46+
// Prefix it with `a` because bundletool sorts entries alphabetically, and this will place it right next to `assembly-store.so`, which is what we
4747
// like since we can finish scanning the zip central directory earlier at startup.
4848
var inArchivePath = MakeArchiveLibPath (abi, "libarc.bin.so");
4949
var wrappedSourcePath = DSOWrapperGenerator.WrapIt (Log, dsoWrapperConfig, MonoAndroidHelper.AbiToTargetArch (abi), RuntimeConfigBinFilePath, Path.GetFileName (inArchivePath));

src/Xamarin.Android.Build.Tasks/Tasks/CreateAssemblyStore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace Xamarin.Android.Tasks;
1111

1212
/// <summary>
13-
/// If using $(AndroidUseAssemblyStore), place all the assemblies in a single .blob file.
13+
/// If using $(AndroidUseAssemblyStore), place all the assemblies in a single assembly store file.
1414
/// </summary>
1515
public class CreateAssemblyStore : AndroidTask
1616
{

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64SimpleDotNet.CoreCLR.apkdesc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"classes.dex": {
88
"Size": 397616
99
},
10-
"lib/arm64-v8a/libassemblies.arm64-v8a.blob.so": {
10+
"lib/arm64-v8a/libassembly-store.so": {
1111
"Size": 3124664
1212
},
1313
"lib/arm64-v8a/libclrjit.so": {
@@ -75,4 +75,4 @@
7575
}
7676
},
7777
"PackageSize": 9049893
78-
}
78+
}

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64XFormsDotNet.CoreCLR.apkdesc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"kotlin/reflect/reflect.kotlin_builtins": {
3232
"Size": 2396
3333
},
34-
"lib/arm64-v8a/libassemblies.arm64-v8a.blob.so": {
34+
"lib/arm64-v8a/libassembly-store.so": {
3535
"Size": 14221080
3636
},
3737
"lib/arm64-v8a/libclrjit.so": {
@@ -2286,4 +2286,4 @@
22862286
}
22872287
},
22882288
"PackageSize": 22619078
2289-
}
2289+
}

src/Xamarin.Android.Build.Tasks/Utilities/AssemblyStoreGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ string Generate (string baseOutputDirectory, AndroidTargetArch arch, List<Assemb
107107
Directory.CreateDirectory (outputDir);
108108

109109
uint infoCount = (uint)infos.Count;
110-
string storePath = Path.Combine (outputDir, androidAbi, $"assemblies.{androidAbi}.blob.so");
110+
string storePath = Path.Combine (outputDir, "assembly-store.so");
111111
var index = new List<AssemblyStoreIndexEntry> ();
112112
var descriptors = new List<AssemblyStoreEntryDescriptor> ();
113113
ulong namesSize = 0;

src/native/clr/include/constants.hh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,8 @@ namespace xamarin::android {
102102
private:
103103
static constexpr size_t split_config_abi_apk_name_size = calc_size (split_config_prefix, android_abi, split_config_extension);
104104

105-
static constexpr std::string_view assembly_store_prefix { "libassemblies." };
106-
static constexpr std::string_view assembly_store_extension { ".blob" };
107-
static constexpr size_t assembly_store_file_name_size = calc_size (assembly_store_prefix, android_lib_abi, assembly_store_extension, dso_suffix);
108-
static constexpr auto assembly_store_file_name_array = concat_string_views<assembly_store_file_name_size> (assembly_store_prefix, android_lib_abi, assembly_store_extension, dso_suffix);
109-
110105
public:
111-
// .data() must be used otherwise string_view length will include the trailing \0 in the array
112-
static constexpr std::string_view assembly_store_file_name { assembly_store_file_name_array.data () };
106+
static constexpr std::string_view assembly_store_file_name { "libassembly-store.so" };
113107

114108
static constexpr auto split_config_abi_apk_name = concat_string_views<split_config_abi_apk_name_size> (split_config_prefix, android_abi, split_config_extension);
115109
static constexpr std::string_view base_apk_name = { "/base.apk" };

src/native/mono/monodroid/embedded-assemblies.hh

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,11 @@ namespace xamarin::android::internal {
102102
static constexpr std::string_view dso_suffix { ".so" };
103103

104104
static constexpr std::string_view apk_lib_prefix = assemblies_prefix; // concat_const (apk_lib_dir_name, zip_path_separator, SharedConstants::android_lib_abi, zip_path_separator);
105-
static constexpr std::string_view assembly_store_prefix { "libassemblies." };
106-
static constexpr std::string_view assembly_store_extension { ".blob" };
107105

108-
static constexpr size_t assembly_store_file_name_size = calc_size (assembly_store_prefix, SharedConstants::android_lib_abi, assembly_store_extension, dso_suffix);
109-
static constexpr auto assembly_store_file_name_array = concat_string_views<assembly_store_file_name_size> (assembly_store_prefix, SharedConstants::android_lib_abi, assembly_store_extension, dso_suffix);
106+
static constexpr std::string_view assembly_store_file_name { "libassembly-store.so" };
110107

111-
// .data() must be used otherwise string_view length will include the trailing \0 in the array
112-
static constexpr std::string_view assembly_store_file_name { assembly_store_file_name_array.data () };
113-
114-
static constexpr size_t assembly_store_file_path_size = calc_size(apk_lib_dir_name, zip_path_separator, SharedConstants::android_lib_abi, zip_path_separator, assembly_store_prefix, SharedConstants::android_lib_abi, assembly_store_extension, dso_suffix);
115-
static constexpr auto assembly_store_file_path_array = concat_string_views<assembly_store_file_path_size> (apk_lib_dir_name, zip_path_separator, SharedConstants::android_lib_abi, zip_path_separator, assembly_store_prefix, SharedConstants::android_lib_abi, assembly_store_extension, dso_suffix);
108+
static constexpr size_t assembly_store_file_path_size = calc_size(apk_lib_dir_name, zip_path_separator, SharedConstants::android_lib_abi, zip_path_separator, assembly_store_file_name);
109+
static constexpr auto assembly_store_file_path_array = concat_string_views<assembly_store_file_path_size> (apk_lib_dir_name, zip_path_separator, SharedConstants::android_lib_abi, zip_path_separator, assembly_store_file_name);
116110
// .data() must be used otherwise string_view length will include the trailing \0 in the array
117111
static constexpr std::string_view assembly_store_file_path { assembly_store_file_path_array.data () };
118112

tools/assembly-store-reader-mk2/AssemblyStore/StoreReader_V2.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ string GetArchPath (AndroidTargetArch arch, string? root = null)
6565
root = LibDirName;
6666
}
6767
parts.Add (abi);
68-
parts.Add (GetBlobName (abi));
68+
parts.Add ("libassembly-store.so");
6969

7070
return MonoAndroidHelper.MakeZipArchivePath (root, parts);
7171
}
@@ -82,8 +82,6 @@ public StoreReader_V2 (Stream store, string path)
8282
};
8383
}
8484

85-
static string GetBlobName (string abi) => $"libassemblies.{abi}.blob.so";
86-
8785
protected override ulong GetStoreStartDataOffset () => elfOffset;
8886

8987
protected override bool IsSupported ()

tools/assembly-store-reader-mk2/Main.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,16 @@ static int Main (string[] args)
6666
" where each BLOB_PATH can point to:",
6767
" * aab file",
6868
" * apk file",
69-
" * index store file (e.g. base_assemblies.blob or assemblies.arm64_v8a.blob.so)",
70-
" * arch store file (e.g. base_assemblies.arm64_v8a.blob)",
69+
" * index store file (e.g. base_assemblies.blob or libassembly-store.so)",
70+
" * arch store file (e.g. base_assemblies.blob)",
7171
" * store manifest file (e.g. base_assemblies.manifest)",
7272
" * store base name (e.g. base or base_assemblies)",
7373
"",
7474
" In each case the whole set of stores and manifests will be read (if available). Search for the",
7575
" various members of the store set (common/main store, arch stores, manifest) is based on this naming",
7676
" convention:",
7777
"",
78-
" {BASE_NAME}[.ARCH_NAME].{blob|blob.so|manifest}",
78+
" {BASE_NAME}[.ARCH_NAME].{blob|so|manifest}",
7979
"",
8080
" Whichever file is referenced in `BLOB_PATH`, the BASE_NAME component is extracted and all the found files are read.",
8181
" If `BLOB_PATH` points to an aab or an apk, BASE_NAME will always be `assemblies`",

0 commit comments

Comments
 (0)