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

Improve R_68K_PC32 handling #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yupferris
Copy link

@yupferris yupferris commented Jan 7, 2025

Correctly translating an R_68K_PC32 relocation requires emitting a HUNK_RELRELOC32 relocation, not a HUNK_RELOC32 one as the code does currently. Since we don't emit any HUNK_RELRELOC32 hunks, we should report errors for these relocations. The exception to this is relocations that refer to symbols in the same section as the relocation, since these won't actually require any relocation at load time (everything in the same hunk will be moved together, preserving relative offsets within the hunk). So, we can handle these correctly by simply not emitting a hunk relocation at all.

This is required for targeting 68060 with modern gcc, which will emit instructions that require this (eg. bra.l) with sufficient optimizations enabled.

Side note: It looks like proper handling for these relocs was added in the original AROS tool after this version was forked, so it may be wise to incorporate those changes as well at some point. However, these turn out to be somewhat limited so it's still worthwhile to try and avoid emitting them when possible. Luckily, these are relatively rare; I have yet to encounter a case that isn't covered by this PR, for example.

Correctly translating an R_68K_PC32 relocation requires emitting a HUNK_RELRELOC32 relocation, not a HUNK_RELOC32 one as the code does currently. Since we don't emit any HUNK_RELRELOC32 hunks, we should report errors for these relocations. The exception to this is relocations that refer to symbols in the same section as the relocation, since these won't actually require any relocation at load time (everything in the same hunk will be moved together, preserving relative offsets within the hunk). So, we can handle these correctly by simply not emitting a hunk relocation at all.

This is required for targeting 68060 with modern gcc, which will emit instructions that require this (eg. bra.l) with sufficient optimizations enabled.
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.

1 participant