#13944: Redesign memory packing API #15980
Merged
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.
Ticket
#13944
Problem description
Packing ELF segments together for deployment relied on HAL information. That information is present in the ELF itself and no HAL involvement is necessary.
In developing this patch I discovered a bug that was mitigated by a different bug and obsolete code predating the use of ELF segments. Specifically for erisc kernel deployments packing was requested, but text memory range was incorrect. This resulted in the data segment being considered text, and the obsolete code inserted padding between the real text and the data, resulting in a deployable image, but one that was larger than necessary and would clobber any memory objects placed in that padding area.
What's changed
*) Linker scripts augmented to record the Load Memory Address(LMA) of data segments -- this is used to ensure packing is consistent
*) ELF loader augmented to record the LMA. (Other cleanups also implemented)
*) Replacement of the separate
PackSpans
andRelocate
enums with a single Loading enum offering {DISCRETE, CONTIGUOUS, CONTIGUOUS_XIP
} alternatives. (Removing an unrequired DISCRETE_XIP variant.). While the original enums are orthogonal, their use is not -- and the above mentioned bug occurred by not paying attention to how they are related.*) Removal of
core_type_idx, processor_class_idx, processor_type_idx
arguments toget_risc_binary
*) Removal of
Memory::pack_data_into_text
and direct implementation of that functionality during the conversion from ELF. (This routine contained the obsolete workaround and was given incorrect text and data base addresses for wormhole_b0 N300)Checklist