Skip to content

Commit 2d1bdf6

Browse files
hanno-beckermkannwischer
authored andcommitted
Backends: Namespace assembly local labels with mld_ prefix
Previously, local labels in the assembly backends were prefixed only by the name of the enclosing function, e.g. Lntt_layer123_start in ntt_aarch64_asm.S. Global entry symbols are namespaced per project via MLD_ASM_NAMESPACE(), but local labels are emitted as literal text and survive verbatim into the autogenerated mldsa/*.S files. mldsa-native derives its assembly from mlkem-native and kept the same function and label names, so its local labels are byte-for-byte identical (Lntt_layer123_start, Lrej_uniform_loop48, ...). This is harmless as long as each backend is assembled into its own object file, but breaks when both backends are merged into a single link unit: AWS-LC's FIPS build concatenates all sources and runs them through the delocate tool, which flattens them into one symbol namespace and panics on the duplicate labels. This commit adds a fixed mld_ project prefix to every local label across all backends (AArch64 arithmetic and FIPS202, x86_64 AVX2, Armv8.1-M MVE), not just the ones that clash today, so mldsa-native emits Lmld_ntt_layer123_start and can no longer collide with the mlk_-prefixed labels emitted by mlkem-native, independent of the integrator or platform. The change is made in the dev/ assembly sources and propagated to mldsa/*.S and the proofs/hol_light/* drops via scripts/simpasm. Local labels emit no object-code bytes, and branch targets encode PC-relative offsets rather than names, so the assembled .text is byte-identical; the byte-locked HOL Light and CBMC proofs are unaffected. check_asm_loop_labels in scripts/autogen is updated to require the mld_-prefixed function-derived prefix, so a newly added un-namespaced label fails CI. Signed-off-by: Hanno Becker <beckphan@amazon.co.uk>
1 parent ea8960e commit 2d1bdf6

121 files changed

Lines changed: 560 additions & 541 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

dev/aarch64_clean/src/intt_aarch64_asm.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ MLD_ASM_FN_SYMBOL(intt_aarch64_asm)
272272
mov count, #16
273273

274274
.p2align 2
275-
intt_layer5678_start:
275+
mld_intt_layer5678_start:
276276

277277
ldr q_data0, [inp, #(16*0)]
278278
ldr q_data1, [inp, #(16*1)]
@@ -331,7 +331,7 @@ intt_layer5678_start:
331331
str q_data3, [inp, #(-64 + 16*3)]
332332

333333
subs count, count, #1
334-
cbnz count, intt_layer5678_start
334+
cbnz count, mld_intt_layer5678_start
335335

336336
// ---------------------------------------------------------------------
337337

@@ -351,7 +351,7 @@ intt_layer5678_start:
351351

352352
.p2align 2
353353

354-
intt_layer1234_start:
354+
mld_intt_layer1234_start:
355355

356356
ldr q_data0, [in, #0]
357357
ldr q_data1, [in, #(1*(512/8))]
@@ -464,7 +464,7 @@ intt_layer1234_start:
464464
str q_data7, [in, #(-16 + 7*(512/8))]
465465

466466
subs count, count, #1
467-
cbnz count, intt_layer1234_start
467+
cbnz count, mld_intt_layer1234_start
468468

469469
pop_stack
470470
ret

dev/aarch64_clean/src/mld_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ MLD_ASM_FN_SYMBOL(polyvecl_pointwise_acc_montgomery_l4_aarch64_asm)
132132

133133
mov count, #(MLDSA_N / 4)
134134

135-
polyvecl_pointwise_acc_montgomery_l4_loop_start:
135+
mld_polyvecl_pointwise_acc_montgomery_l4_loop_start:
136136
load_polys q_a_0, q_a_1, q_a_2, q_a_3, a_ptr, 0
137137
load_polys q_b_0, q_b_1, q_b_2, q_b_3, b_ptr, 0
138138
// Bounds: |a_{i}| < q, |b_{i}| < 9q
@@ -189,7 +189,7 @@ polyvecl_pointwise_acc_montgomery_l4_loop_start:
189189
str q_c_0, [out_ptr], #4*16
190190

191191
subs count, count, #4
192-
cbnz count, polyvecl_pointwise_acc_montgomery_l4_loop_start
192+
cbnz count, mld_polyvecl_pointwise_acc_montgomery_l4_loop_start
193193

194194
ret
195195

dev/aarch64_clean/src/mld_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ MLD_ASM_FN_SYMBOL(polyvecl_pointwise_acc_montgomery_l5_aarch64_asm)
132132

133133
mov count, #(MLDSA_N / 4)
134134

135-
polyvecl_pointwise_acc_montgomery_l5_loop_start:
135+
mld_polyvecl_pointwise_acc_montgomery_l5_loop_start:
136136
load_polys q_a_0, q_a_1, q_a_2, q_a_3, a_ptr, 0
137137
load_polys q_b_0, q_b_1, q_b_2, q_b_3, b_ptr, 0
138138
// Bounds: |a_{i}| < q, |b_{i}| < 9q
@@ -199,7 +199,7 @@ polyvecl_pointwise_acc_montgomery_l5_loop_start:
199199
str q_c_0, [out_ptr], #4*16
200200

201201
subs count, count, #4
202-
cbnz count, polyvecl_pointwise_acc_montgomery_l5_loop_start
202+
cbnz count, mld_polyvecl_pointwise_acc_montgomery_l5_loop_start
203203

204204
ret
205205

dev/aarch64_clean/src/mld_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ MLD_ASM_FN_SYMBOL(polyvecl_pointwise_acc_montgomery_l7_aarch64_asm)
132132

133133
mov count, #(MLDSA_N / 4)
134134

135-
polyvecl_pointwise_acc_montgomery_l7_loop_start:
135+
mld_polyvecl_pointwise_acc_montgomery_l7_loop_start:
136136
load_polys q_a_0, q_a_1, q_a_2, q_a_3, a_ptr, 0
137137
load_polys q_b_0, q_b_1, q_b_2, q_b_3, b_ptr, 0
138138
// Bounds: |a_{i}| < q, |b_{i}| < 9q
@@ -219,7 +219,7 @@ polyvecl_pointwise_acc_montgomery_l7_loop_start:
219219
str q_c_0, [out_ptr], #4*16
220220

221221
subs count, count, #4
222-
cbnz count, polyvecl_pointwise_acc_montgomery_l7_loop_start
222+
cbnz count, mld_polyvecl_pointwise_acc_montgomery_l7_loop_start
223223

224224
ret
225225

dev/aarch64_clean/src/ntt_aarch64_asm.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ MLD_ASM_FN_SYMBOL(ntt_aarch64_asm)
244244

245245
.p2align 2
246246

247-
ntt_layer123_start:
247+
mld_ntt_layer123_start:
248248

249249
ldr q_data0, [in, #0]
250250
ldr q_data1, [in, #(1*(1024/8))]
@@ -283,13 +283,13 @@ ntt_layer123_start:
283283
str q_data7, [in, #(-16 + 7*(1024/8))]
284284

285285
subs count, count, #1
286-
cbnz count, ntt_layer123_start
286+
cbnz count, mld_ntt_layer123_start
287287

288288
mov in, inp
289289
mov count, #8
290290

291291
.p2align 2
292-
ntt_layer45678_start:
292+
mld_ntt_layer45678_start:
293293

294294
ldr q_data0, [in, #(16*0)]
295295
ldr q_data1, [in, #(16*1)]
@@ -351,7 +351,7 @@ ntt_layer45678_start:
351351
str q_data7, [in, #(-16*1)]
352352

353353
subs count, count, #1
354-
cbnz count, ntt_layer45678_start
354+
cbnz count, mld_ntt_layer45678_start
355355

356356
pop_stack
357357
ret

dev/aarch64_clean/src/pointwise_montgomery_aarch64_asm.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ MLD_ASM_FN_SYMBOL(poly_pointwise_montgomery_aarch64_asm)
109109

110110
mov count, #(MLDSA_N / 4)
111111

112-
poly_pointwise_montgomery_loop_start:
112+
mld_poly_pointwise_montgomery_loop_start:
113113
ldr q_a_0, [a_ptr, #0*16]
114114
ldr q_a_1, [a_ptr, #1*16]
115115
ldr q_a_2, [a_ptr, #2*16]
@@ -143,7 +143,7 @@ poly_pointwise_montgomery_loop_start:
143143
str q_c_0, [a_ptr], #4*16
144144

145145
subs count, count, #4
146-
cbnz count, poly_pointwise_montgomery_loop_start
146+
cbnz count, mld_poly_pointwise_montgomery_loop_start
147147

148148
ret
149149

dev/aarch64_clean/src/poly_caddq_aarch64_asm.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ MLD_ASM_FN_SYMBOL(poly_caddq_aarch64_asm)
4747
dup q_reg.4s, w9 // Load Q values
4848

4949
mov count, #64/4
50-
poly_caddq_loop:
50+
mld_poly_caddq_loop:
5151
ldr q0, [a_ptr, #0*16]
5252
ldr q1, [a_ptr, #1*16]
5353
ldr q2, [a_ptr, #2*16]
@@ -64,7 +64,7 @@ poly_caddq_loop:
6464
str q0, [a_ptr], #4*16
6565

6666
subs count, count, #1
67-
bne poly_caddq_loop
67+
bne mld_poly_caddq_loop
6868

6969
ret
7070

dev/aarch64_clean/src/poly_chknorm_aarch64_asm.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ MLD_ASM_FN_SYMBOL(poly_chknorm_aarch64_asm)
5555

5656
mov count, #(64/4)
5757

58-
poly_chknorm_loop:
58+
mld_poly_chknorm_loop:
5959
ldr q1, [a_ptr, #1*16]
6060
ldr q2, [a_ptr, #2*16]
6161
ldr q3, [a_ptr, #3*16]
@@ -67,7 +67,7 @@ poly_chknorm_loop:
6767
chknorm v0
6868

6969
subs count, count, #1
70-
bne poly_chknorm_loop
70+
bne mld_poly_chknorm_loop
7171

7272
// Return 1 if any of the 4 lanes is 0xffffffff
7373
umaxv s21, flags.4s

dev/aarch64_clean/src/poly_decompose_32_aarch64_asm.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ MLD_ASM_FN_SYMBOL(poly_decompose_32_aarch64_asm)
126126

127127
mov count, #(64/4)
128128

129-
poly_decompose_32_loop:
129+
mld_poly_decompose_32_loop:
130130
ldr q0, [a0_ptr, #0*16]
131131
ldr q1, [a0_ptr, #1*16]
132132
ldr q2, [a0_ptr, #2*16]
@@ -147,7 +147,7 @@ poly_decompose_32_loop:
147147
str q0, [a0_ptr], #4*16
148148

149149
subs count, count, #1
150-
bne poly_decompose_32_loop
150+
bne mld_poly_decompose_32_loop
151151

152152
ret
153153

dev/aarch64_clean/src/poly_decompose_88_aarch64_asm.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ MLD_ASM_FN_SYMBOL(poly_decompose_88_aarch64_asm)
124124
dup barrett_const.4s, w11
125125

126126
mov count, #(64/4)
127-
poly_decompose_88_loop:
127+
mld_poly_decompose_88_loop:
128128
ldr q0, [a0_ptr, #0*16]
129129
ldr q1, [a0_ptr, #1*16]
130130
ldr q2, [a0_ptr, #2*16]
@@ -145,7 +145,7 @@ poly_decompose_88_loop:
145145
str q0, [a0_ptr], #4*16
146146

147147
subs count, count, #1
148-
bne poly_decompose_88_loop
148+
bne mld_poly_decompose_88_loop
149149

150150
ret
151151

0 commit comments

Comments
 (0)