Skip to content

Make code position-independent#24

Merged
jburgy merged 3 commits into
mainfrom
position-independent-code
Dec 15, 2025
Merged

Make code position-independent#24
jburgy merged 3 commits into
mainfrom
position-independent-code

Conversation

@jburgy

@jburgy jburgy commented Dec 13, 2025

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the Forth interpreter to use position-independent code by changing from a statically allocated memory array to dynamic memory allocation at runtime. This enables the code to work correctly regardless of where it's loaded in memory.

Key changes:

  • Separated read-only initialization data into a rodata array while making memory and bytes dynamically allocated pointers
  • Added set_up_data_segment() function to allocate memory via sbrk() and copy the initial data at runtime
  • Added special handling for SYS_brk syscall to adjust returned addresses for position independence

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread forth/jansforth.c
Comment thread forth/jansforth.c
Comment thread forth/jansforth.c
Comment thread forth/jansforth.c
Comment thread forth/jansforth.c
@jburgy jburgy marked this pull request as ready for review December 15, 2025 15:41
@jburgy jburgy merged commit 29c7d9d into main Dec 15, 2025
4 checks passed
@jburgy jburgy deleted the position-independent-code branch December 15, 2025 15:41
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.

2 participants