Repository navigation
optee-utee-build: fix generated TA header symbol ABI - #337
Merged
Merged
Conversation
Emit trace_ext_prefix as a sized byte array instead of a slice. A #[no_mangle] slice static exports a fat pointer, while C declares the symbol as `extern const char trace_ext_prefix[]`. OP-TEE read the pointer bytes instead of the prefix, so the TA trace prefix was wrong. Add a regression test that checks the generated static is an array whose length includes the trailing NUL, and fix the optee-utee-systest link stub to define the symbol with its C type.
OP-TEE passes ta_heap to malloc_add_pool(), which writes into the buffer, even though generated TA code never accesses it directly. Declare the exported static as `static mut` so the generated code records that the memory is mutated outside Rust. Also fix the optee-utee-systest link stub so ta_heap is an array rather than a void pointer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The generated TA header exported two symbols whose layout did not match the
C declarations used by OP-TEE:
trace_ext_prefixwas emitted aspub static trace_ext_prefix: &[u8].With
#[unsafe(no_mangle)], that exports a fat pointer (data pointer pluslength), while C declares
extern const char trace_ext_prefix[]. OP-TEEtherefore read the pointer bytes instead of the prefix. Emit a sized byte
array instead, with a length that includes the trailing NUL.
ta_heapis handed to OP-TEE's allocator, which writes into the buffer eventhough generated TA code never accesses it directly. Emit it as
static mutso the generated Rust records that the memory is mutated outside Rust.
Update the golden header fixture accordingly and fix the
optee-utee-systestC link stub to define both symbols with their C types.