bebbo / binutils-gdb

Unofficial mirror of sourceware binutils-gdb repository. Updated daily.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git
GNU General Public License v2.0
3 stars 3 forks source link

amiga13.2 + libnix13: creating a broken hunk object and a broken exe #41

Closed Z4JC closed 6 months ago

Z4JC commented 6 months ago

While preparing a new pull request for libnix13, I ran into a problem once I tried to include a unittesting framework. As a sidenote, I think the implementation of getcwd for Kickstart 1.3 is solid, so it's yours if you want it ;)

Repro steps (using amiga13.2 branch):

git clone -b broken_utest https://github.com/Z4JC/a500-sys.git
cd a500-sys/nix13_extra/
make -f Makefile.unix

This should create the following objects: m68k-amigaos-gcc -Os -m68000 -mcrt=nix13 -Iinclude/ -c getcwd.c -o build-files/getcwd.o m68k-amigaos-gcc -Os -m68000 -mcrt=nix13 -Iinclude/ -c tests/test_main.c -o build-files/tests/test_main.o m68k-amigaos-gcc -Os -m68000 -mcrt=nix13 -Iinclude/ -c tests/test_getcwd.c -o build-files/tests/test_getcwd.o

and then finally link: m68k-amigaos-gcc -Os -m68000 -mcrt=nix13 -Iinclude/ build-files/tests/test_main.o build-files/tests/test_getcwd.o build-files/getcwd.o -o build-files/tests/test_getcwd.exe -lm

However, the resultant exe is broken:

hunktool info build-files/tests/test_getcwd.exe 
build-files/tests/test_getcwd.exe (0.0003s) BUILD SEGMENTS FAILED: Expected hunk start in loadseg: HUNK_ABSRELOC32 1004/3ec

Amiga will refuse to execute this file, but it will load with vamos (but not really run all the way).

The culprit is test_main.c that just includes a (mostly) straightforward utest.h

hunktool info build-files/tests/test_main.o
build-files/tests/test_main.o (0.0001s) RESULT_INVALID_HUNK_FILE HUNK_EXT has unspported ext entry 33

I am attaching the built files so you can take a look: build-files.zip

What's hunk_ext 33? What in your gcc branch deals with hunk generation? (I can take a look myself)

bebbo commented 6 months ago

Please strip the generated executable. There are multiple DEBUG hunks which do cause problems. (The stabs debug file format was removed and the now used format is not yet processed correctly)

bebbo commented 6 months ago

Also note, that clock_gettime can't be used with vamos since the DOSBases`s TimerDevice is not available.

bebbo commented 6 months ago

Also note, that clock_gettime can't be used with vamos since the DOSBase`s TimerDevice is not available.

I updated my cloned vamos repo:

 vamos -C20 build-files/tests/test_getcwd.exe
[==========] Running 1 test cases.
[ RUN      ] getcwd_tests.einval_size_0
[       OK ] getcwd_tests.einval_size_0 (0ns)
[==========] 1 test cases ran.
[  PASSED  ] 1 tests.
Z4JC commented 6 months ago

Love it! :) Awesome! 👍 💯

If you don't hate it, could be potentially used to test the libnix stuff / document regressions..

I pushed the fixed version of broken_utest branch.

I am probably missing something here: The only way I could get stripping to work is to explicitly add it as a Makefile step, so it does: m68k-amigaos-strip --strip-debug build-files/getcwd.o Placing -s on the gcc line did not work no matter where I put it (did not strip anyting), and neither did -Wl,-s or similar.

Any ideas of how to pass this down to line to linker/stripper? Totally cool if it's not working/worth it for now..

bebbo commented 6 months ago

strip the executable:

m68k-amigaos-strip build-files/tests/test_getcwd.exe

the new debug hunks are treated as normal code for now... ... 13.2 is still alpha

Z4JC commented 6 months ago

All good, stripped the .o file and the .exe. Sent you a pull request for getcwd.c under Kickstart V34 (probably works on older too?), the other stuff TBA. Trying to minimally invade/touch/change the libnix repo and hopefully just add stuff that makes it more fun to hack on this..

bebbo commented 6 months ago

you have to strip the file.