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

libbfd refuses to load some HUNK files #43

Open
antekone opened this issue Aug 22, 2024 · 2 comments
Open

libbfd refuses to load some HUNK files #43

antekone opened this issue Aug 22, 2024 · 2 comments

Comments

@antekone
Copy link

antekone commented Aug 22, 2024

I think that this fork of libbfd can have a bug, though I'm sorry if the fault is on me.

The core problem I have is that strip (nor objdump) doesn't work for files generated by m68k-amigaos-g++ from the 13.2 branch:

~/dev/amiga> m68k-amigaos-g++ hello.cpp -o hello -s -O3 -mcrt=nix13 && m68k-amigaos-strip hello
m68k-amigaos-strip: hello: file format not recognized

~/dev/amiga> file hello
hello: AmigaOS loadseg()ble executable/binary

I've debugged a little bit and I've found that the amigaos.c vec is refusing to load this HUNK file. The refusal is generated by this line:

https://github.com/bebbo/binutils-gdb/blame/101c27d0af524ce77cf34ca73cdfdfbbc5361ec2/bfd/amigaos.c#L1100

The hunk_type in the iteration that generates an error is HUNK_RELOC32 for my case.

@antekone
Copy link
Author

HUNK files generated by g++ look like the following:

hunk 000003f3,      HUNK_HEADER,          0
4 sections, 0 - 3 
sizes: 20424, 320, 92, 40488
hunk 000003e9,        HUNK_CODE,      20424
hunk 000003ec,     HUNK_RELOC32,        828
hunk 000003f0,      HUNK_SYMBOL,          8
HUNK_END
hunk 000003ea,        HUNK_DATA,        320
hunk 000003ec,     HUNK_RELOC32,         16
hunk 000003f0,      HUNK_SYMBOL,         16
HUNK_END
hunk 000003eb,         HUNK_BSS,         92
hunk 000003f0,      HUNK_SYMBOL,          8
HUNK_END
hunk 000003f1,       HUNK_DEBUG,      40488
hunk 000003ec,     HUNK_RELOC32,       7016
hunk 000003f0,      HUNK_SYMBOL,         20
HUNK_END

Is HUNK_DEBUG allowed as a first block inside a hunk? From various sources it seems that only CODE, DATA and BSS are allowed as first blocks in each hunk in a "load" file? (at least in OS 1.3, but that assumption is also followed by libbfd).

@bebbo
Copy link
Owner

bebbo commented Oct 2, 2024

the OS does not like relocations in DEBUG hunks...
... should be ok now

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

2 participants