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

2s-complement undefined references #3

Open
fachat opened this issue Apr 10, 2024 · 0 comments
Open

2s-complement undefined references #3

fachat opened this issue Apr 10, 2024 · 0 comments
Milestone

Comments

@fachat
Copy link
Owner

fachat commented Apr 10, 2024

In GeckOS V2, in some cases an undefined reference is not added, but subtracted from another value.

One specific case is where ROMSTART defines the beginning of the "rom" image that is scanned for executable file images. Within the rom image, each entry defines how much "rom" is mapped from the top of memory into the specific tasks memory map (note this is relevant to MMU-based ports). The resulting code where this value is defined looks like:

     .byt > $ff - ROMSTART

ROMSTART is an address that may be redefined during the build process through relocation of the rom image.

This cannot be relocated at this time, as o65 does not define a negative undefined value.

To overcome this, the following is proposed:

Currently the segment ID is defined as:

0		undefined
1		absolute value
2		text segment
3		data segment
4		bss segment
5		zero segment

where "absolute value" does not appear in the relocation table. This segment ID, however, is used in the list of exported globals, but there no undefined segment appears.

The proposal is:

  1. use segment ID value "1" as "negative undefined" entry in the relocation table
  2. use segment ID value "1" as "absolute value" in the list of exported globals.

This achieves the following:

  1. existing loaders should note an "illegal" segment value and should refuse to load such a file, doing a "fail fast" approach (avoid extensive troubleshooting)
  2. no extra bit used

An alternative would have been to use e.g. bit $10 in the segment ID, but this is only relevant in exactly one segment, and wasted otherwise. Also existing loaders may ignore this bit. So, it is the redefinition of the absolute segment for the relocation table.

@fachat fachat added this to the 1.4 milestone Apr 10, 2024
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

No branches or pull requests

1 participant