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

Investigate making text.fixed for libcalls #275

Open
mysterymath opened this issue Dec 27, 2023 · 0 comments
Open

Investigate making text.fixed for libcalls #275

mysterymath opened this issue Dec 27, 2023 · 0 comments
Labels
enhancement New feature or request p2

Comments

@mysterymath
Copy link
Member

Presently, the SDK maintains an invariant that all default C readonly sections are always visible in memory, no matter the state of the underlying system. For systems where the whole ROM image of the program is banked as a unit (that is, no portion of it is fixed), this typically requires duplicating the C readonly sections at the same address in each bank. This potentially wastes a ton of space, especially given library functions like printf.

Two requirements justify this invariant:

  1. The compiler can insert calls to certain library functions (libcalls). There is no ABI or standard for how or when these will be generated, so there's generally no supported way to prevent the compiler from inserting them. Accordingly, they must always be visibile, since anything written in C may call them.
  2. The compiler may rewrite a call from one C library function to another (e.g., printf can become puts). This only requires that C library functions are all equally callable: if any are callable, all are.

Accordingly, we could relax the SDK's invariants by moving the libcalls in the SDK into a special section: .text.fixed and/or .rodata.fixed. These sections would be duplicated across banks, but the main C sections could be placed in a single bank. This would free the other banks for other code and data, while still allowing such code to make libcalls at will.

@mysterymath mysterymath added enhancement New feature or request p1 p2 and removed p1 labels Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request p2
Projects
None yet
Development

No branches or pull requests

1 participant