fix(build): word-align the length symbol of embedded data files

The generated assembly emitted <name>_length immediately after the raw
payload bytes, so the 32-bit word landed misaligned whenever the data
size was not a multiple of 4. Consumers declare it as a 32-bit object
(e.g. `extern const size_t <name>_length` in the ULP firmware loaders),
so the compiler emits an alignment-assuming word load, which is a
misaligned flash read prone to spurious load faults on chips with
SOC_CPU_MISALIGNED_ACCESS_ON_PMP_MISMATCH_ISSUE (ESP32-C6/H2/H21).
This commit is contained in:
Mahavir Jain
2026-08-06 22:07:57 +05:30
committed by BOT
parent e44c357a02
commit 1612b25e70

View File

@@ -83,6 +83,8 @@ append("${data}")
make_and_append_identifier("_binary_${varname}_end" "for objcopy compatibility")
append_line("")
# Keep the length aligned on the word boundary (read as a 32-bit `<name>_length`)
append_line(".balign 4")
if(FILE_TYPE STREQUAL "TEXT")
make_and_append_identifier("${varname}_length" "not including null byte")
else()