Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support loading initialized data memory from asm tests #725

Merged
merged 3 commits into from
Aug 11, 2024

Conversation

piotro888
Copy link
Member

Initialized data can be now declared in internal asm tests. Data memory size (also with .bss) is now determined from asm source file, instead of default fixed value.

@piotro888 piotro888 added the tests Tests and testbenches (not infrastructure) label Aug 8, 2024

return {
"text": load_section(".text"),
"data": load_section(".data") + load_section(".bss"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is OK because of the link.ld script? What about alignment, what happens if .data's length is not an integer multiple of 4 bytes? Can this happen?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that was a problem, now i moved everything to .data inside liker script, so it is address-independent

Copy link
Contributor

@xThaid xThaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized that the way we handle memory in these tests is kind of broken. The reason it didn't come out yet is that .bss and .data sections are always empty for our hand-written assembly tests.

Also having two separate memories (instructions and data separately) is just probably left over from the ancient times of the project.

I would suggest using the same structures as we use in regression/benchmarks/signature tests, i.e. CoreMemoryModel and friends. Storing and accessing the initial values of the registers could be solved by creating our own section in the assembly (and the linker script) and then associating it with a new MemorySegment

test/asm/link.ld Show resolved Hide resolved
@@ -98,3 +100,6 @@ fail:
.org 0x200
j int_handler
li x31, 0xae # should never happen

.bss
INIT_REGS_ALLOCATION
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.bss section should be always zeroed, so we shouldn't put any preloaded data there

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also: setting the location of .bss in the linker script and then overriding it using .orig is just bad

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with separate section with origin in liker script

test/test_core.py Show resolved Hide resolved
Copy link
Contributor

@xThaid xThaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I am not blocking this. The further refactor should be done in another PR.

@tilk tilk merged commit c51aab5 into kuznia-rdzeni:master Aug 11, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests and testbenches (not infrastructure)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants