@@ -9,6 +9,10 @@ target triple = "riscv32cheriot-unknown-cheriotrtos"
99;; The shape of sealed `TestType`s.
1010%struct.SealedTestType = type { i32 , i32 , %struct.TestType }
1111
12+ %struct.AllocatorCapabilityState = type { i32 , i32 , [2 x ptr addrspace (200 )] }
13+
14+ %struct.SealedAllocatorCapabilityState = type { i32 , i32 , %struct.AllocatorCapabilityState }
15+
1216; Function Attrs: minsize mustprogress nounwind optsize
1317define dso_local chericcallcce noundef i32 @test_static_sealing () local_unnamed_addr addrspace (200 ) #0 {
1418entry:
2731;; CHECK-NEXT: clc ct2, %cheriot_compartment_lo_i(.LBB0_2)(ct2)
2832;; CHECK-NEXT: cjalr ct2
2933 %call = notail call chericcallcc noundef i32 @test_static_sealed_object (ptr addrspace (200 ) @test ) #2
30- ret i32 %call
34+ %call2 = notail call chericcallcc noundef i32 @test_static_sealed_object (ptr addrspace (200 ) @__default_malloc_capability ) #2
35+ ret i32 %call2
3136}
3237
3338; Function Attrs: minsize optsize
@@ -41,8 +46,10 @@ attributes #2 = { minsize nounwind optsize "no-builtin-longjmp" "no-builtin-prin
4146!llvm.module.flags = !{!0 , !1 , !2 , !4 }
4247
4348@__export.sealing_type.static_sealing_inner.SealingType = external dso_local addrspace (200 ) global i32 , align 4
49+ @__export.sealing_type.allocator.MallocKey = external dso_local addrspace (200 ) global i32 , align 4
4450
4551$test = comdat any
52+ $__default_malloc_capability = comdat any
4653;; CHECK: .type test,@object # @test
4754;; CHECK-NEXT: .section .sealed_objects,"awG",@progbits,test,comdat
4855;; CHECK-NEXT: .weak test
@@ -52,12 +59,25 @@ $test = comdat any
5259;; CHECK-NEXT: .word 0 # 0x0
5360;; CHECK-NEXT: .word 42 # 0x2a
5461;; CHECK-NEXT: .size test, 12
55- @test = linkonce_odr dso_local addrspace (200 ) global %struct.SealedTestType {
56- i32 ptrtoint (ptr addrspace (200 )
57- @__export.sealing_type.static_sealing_inner.SealingType to i32 ), i32 0 ,
58- %struct.TestType {i32 42 }}, section ".sealed_objects" , comdat, align 4 "cheriot_sealed_value"
59-
60- @llvm.compiler.used = appending addrspace (200 ) global [1 x ptr addrspace (200 )] [ptr addrspace (200 ) @test ], section "llvm.metadata"
62+ @test = linkonce_odr dso_local addrspace (200 ) global %struct.SealedTestType { i32 ptrtoint (ptr addrspace (200 ) @__export.sealing_type.static_sealing_inner.SealingType to i32 ), i32 0 , %struct.TestType {i32 42 }}, section ".sealed_objects" , comdat, align 4 "cheriot_sealed_value"
63+ ;; CHECK: .type __default_malloc_capability,@object # @__default_malloc_capability
64+ ;; CHECK-NEXT: .section .sealed_objects,"awG",@progbits,__default_malloc_capability,comdat
65+ ;; CHECK-NEXT: .weak __default_malloc_capability
66+ ;; CHECK-NEXT: .p2align 3, 0x0
67+ ;; CHECK-NEXT: __default_malloc_capability:
68+ ;; CHECK-NEXT: .word __export.sealing_type.allocator.MallocKey
69+ ;; CHECK-NEXT: .word 0 # 0x0
70+ ;; CHECK-NEXT: .word 1048576 # 0x100000
71+ ;; CHECK-NEXT: .word 0 # 0x0
72+ ;; CHECK-NEXT: .zero 16
73+ ;; CHECK-NEXT: .size __default_malloc_capability, 32
74+ @__default_malloc_capability = linkonce_odr dso_local addrspace (200 ) global
75+ %struct.SealedAllocatorCapabilityState { i32 ptrtoint (ptr
76+ addrspace (200 ) @__export.sealing_type.allocator.MallocKey to i32 ), i32 0 ,
77+ %struct.AllocatorCapabilityState { i32 1048576 , i32 0 , [2 x ptr addrspace (200 )]
78+ zeroinitializer } }, section ".sealed_objects" , comdat, align 8 "cheriot_sealed_value"
79+
80+ @llvm.compiler.used = appending addrspace (200 ) global [2 x ptr addrspace (200 )] [ptr addrspace (200 ) @test , ptr addrspace (200 ) @__default_malloc_capability ], section "llvm.metadata"
6181
6282
6383;; The use of @test above must generate this import as well.
@@ -70,6 +90,14 @@ i32 ptrtoint (ptr addrspace(200)
7090;; CHECK-NEXT: .word test
7191;; CHECK-NEXT: .word 12
7292;; CHECK-NEXT: .size __import.sealed_object.test, 8
93+ ;; CHECK: .section .compartment_imports.__default_malloc_capability,"awG",@progbits,__import.sealed_object.__default_malloc_capability
94+ ;; CHECK-NEXT: .type __import.sealed_object.__default_malloc_capability,@object
95+ ;; CHECK-NEXT: .weak __import.sealed_object.__default_malloc_capability
96+ ;; CHECK-NEXT: .p2align 3, 0x0
97+ ;; CHECK-NEXT: __import.sealed_object.__default_malloc_capability:
98+ ;; CHECK-NEXT: .word __default_malloc_capability
99+ ;; CHECK-NEXT: .word
100+ ;; CHECK-NEXT: .size __import.sealed_object.__default_malloc_capability, 8
73101
74102
75103!0 = !{i32 1 , !"wchar_size" , i32 2 }
0 commit comments