@@ -186,3 +186,72 @@ const lipoRunner = (stdout: string): NativeCommandRunner => ({
186186 } ) ,
187187 ) ,
188188} ) ;
189+
190+ // Newer lipo names arm64e ABI variants `arm64e.<variant>`; the FAT table names
191+ // the same slice `arm64e`, and its physical identity must still match.
192+ describe ( "artifact Mach-O arm64e variant slices" , ( ) => {
193+ const ARM64E_V1 = { type : 0x0100000c , subtype : 0x81000002 } as const ;
194+ const variantSlices = async (
195+ cpu : { readonly type : number ; readonly subtype : number } ,
196+ lipo : ( size : number ) => string ,
197+ ) => {
198+ const root = await createTestTempDirectory ( "rea-slices-arm64e-" ) ;
199+ const binary = join ( root , "fat" ) ;
200+ const x86 = machoImage ( { cpu : CPU . x86_64 } ) ;
201+ const arm = machoImage ( { cpu } ) ;
202+ await writeFile (
203+ binary ,
204+ fatImage ( [
205+ { cpu : CPU . x86_64 , bytes : x86 } ,
206+ { cpu, bytes : arm } ,
207+ ] ) ,
208+ ) ;
209+ const reader = new MachOSliceArtifactReader (
210+ binary ,
211+ lipoRunner (
212+ `architecture x86_64\n cputype CPU_TYPE_X86_64\n cpusubtype CPU_SUBTYPE_X86_64_ALL\n offset 4096\n size ${ String ( x86 . length ) } \n align 2^12 (4096)\n${ lipo ( arm . length ) } ` ,
213+ ) ,
214+ ) ;
215+ const entries = [ ] ;
216+ for await ( const entry of reader . entries ( ) ) entries . push ( entry ) ;
217+ return entries . map ( ( { path, byteOffset } ) => [ path , byteOffset ] ) ;
218+ } ;
219+
220+ it . each ( [
221+ [
222+ "arm64e.v1" ,
223+ " cputype CPU_TYPE_ARM64\n cpusubtype CPU_SUBTYPE_ARM64E\n capabilities PTR_AUTH_VERSION USERSPACE 1" ,
224+ ] ,
225+ [
226+ "arm64e.x1" ,
227+ " cputype CPU_TYPE_ARM64\n cpusubtype unknown arm64 cpusubtype" ,
228+ ] ,
229+ ] ) ( "accepts lipo's %s name for the FAT arm64e slice" , async ( name , cpu ) => {
230+ expect (
231+ await variantSlices (
232+ ARM64E_V1 ,
233+ ( size ) =>
234+ `architecture ${ name } \n${ cpu } \n offset 8192\n size ${ String ( size ) } \n align 2^12 (4096)\n` ,
235+ ) ,
236+ ) . toEqual ( [
237+ [ "slices/x86_64" , 4096 ] ,
238+ [ `slices/${ name } ` , 8192 ] ,
239+ ] ) ;
240+ } ) ;
241+
242+ it . each ( [
243+ [ "a plain arm64 slice" , CPU . arm64 , "8192" ] ,
244+ [ "a different offset" , ARM64E_V1 , "8193" ] ,
245+ ] ) (
246+ "still rejects an arm64e variant name for %s" ,
247+ async ( _label , cpu , offset ) => {
248+ await expect (
249+ variantSlices (
250+ cpu ,
251+ ( size ) =>
252+ `architecture arm64e.v1\n cputype CPU_TYPE_ARM64\n cpusubtype unknown arm64 cpusubtype\n offset ${ offset } \n size ${ String ( size ) } \n align 2^12 (4096)\n` ,
253+ ) ,
254+ ) . rejects . toMatchObject ( { reason : "integrity" } ) ;
255+ } ,
256+ ) ;
257+ } ) ;
0 commit comments