Skip to content

Implemented "Handle ret on main"#117

Merged
privat merged 1 commit intorarsm:masterfrom
Cantinoo:master
Jul 9, 2025
Merged

Implemented "Handle ret on main"#117
privat merged 1 commit intorarsm:masterfrom
Cantinoo:master

Conversation

@Cantinoo
Copy link

@Cantinoo Cantinoo commented Jun 13, 2025

We wanted to emulate a more realistic compiler (ie gcc with __start that calls main). To do so, we needed to create a fake text segment with pre-built instructions.

When start at main is enabled in the settings, and main is recognized as global :

  • The instructions "li a7, 10 ; ecall" (which exits the program succesfully) are injected at the end of the text segment
  • The return address register is initialized with an address that points towards the injected text segment
  • Added a pointer in "Memory" so the injected text segment address can be known by other parts of the code

Fix #115

@github-actions
Copy link

github-actions bot commented Jun 13, 2025

Test Results

12 files  ±0  12 suites  ±0   38s ⏱️ -1s
 8 tests ±0   8 ✅ ±0  0 💤 ±0  0 ❌ ±0 
24 runs  ±0  24 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit a489a5c. ± Comparison against base commit 2869b47.

♻️ This comment has been updated with latest results.

Copy link
Collaborator

@privat privat left a comment

Choose a reason for hiding this comment

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

nice. remove the unrelated useless change. squash the commits to have a nice patch, and I will merge.

if (statement.getInstruction() instanceof BasicInstruction) {
//if statement is in .text, add to machineList
if (Memory.inTextSegment(statement.getAddress()))
if (Memory.inTextSegment(statement.getAddress())) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

useless change

@privat privat merged commit 814d573 into rarsm:master Jul 9, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Correctly handle ret in main function

2 participants