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

ELF loader behaves differently from a raw binary object #3392

Open
SBird1337 opened this issue Jan 5, 2025 · 0 comments
Open

ELF loader behaves differently from a raw binary object #3392

SBird1337 opened this issue Jan 5, 2025 · 0 comments

Comments

@SBird1337
Copy link

For lack of better words in the tittle :(

As also discussed in the discord conversation there seems to be some discrepancy between how objdump writes binary files from an ELF and how mgba interpretes ELF. Specifically the LMA of some section is sometimes not put into the respective ROM section as specied by the ELF.

An example can be found in the pokeemerald-expansion project's test system. Steps to reproduce:

diff --git a/ld_script_test.ld b/ld_script_test.ld
index d279d6b4f6..50198deeca 100644
--- a/ld_script_test.ld
+++ b/ld_script_test.ld
@@ -118,7 +118,7 @@ SECTIONS {
     } > ROM =0

     .data.iwram :
-    ALIGN(8)
+    ALIGN(4)
     {
         __iwram_lma = .;
         . = . + (__iwram_end - __iwram_start);
  • run make -j$(nproc) pokeemerald-test.elf.

The issue occured to me using gcc14, but others reported it with other gcc versions as well. Funkily enough it does not happen for me with gcc10.

The issue also disappears once you build a rom file e.g. with arm-none-eabi-objcopy -O binary pokeemerald-test.elf pokeemerald-test.gba

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