Symbolic disassembly for gcc with -Wl,--traditional-format?

C and PASCAL (or any other high-level languages) in here please

Moderators: exxos, simonsunnyboy, Mug UK, Zorro 2, Moderator Team

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4875
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Symbolic disassembly for gcc with -Wl,--traditional-format?

Postby simonsunnyboy » Mon Oct 30, 2017 3:56 pm

If I compile and link my software with "-Wl,--traditional-format", I get DRI symbols.
However m687k-atari-mint-objdump cannot disassemble the thing in this case.

What can I do to have classic debug symbols inside an Atari environment while having somethign readable during crossdevelopment?
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1564
Joined: Sun Jul 31, 2011 1:11 pm

Re: Symbolic disassembly for gcc with -Wl,--traditional-format?

Postby Eero Tamminen » Mon Oct 30, 2017 8:09 pm

What is the cross-development environment where you want to be able to read DRI symbols? If it's e.g. MiNT / aranym, you could use (much) older objdump (something from GCC v2 era) that supports DRI in addition to a.out.

mikro
Atari God
Atari God
Posts: 1308
Joined: Sat Sep 10, 2005 11:11 am
Location: Brisbane, Queensland, Australia
Contact:

Re: Symbolic disassembly for gcc with -Wl,--traditional-format?

Postby mikro » Mon Oct 30, 2017 11:29 pm

What prevents you from generating both binaries? You'll get the same result. Also, using a.out-style symbols is much better as there's no limit on length, very helpful in bigger projects.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4875
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Symbolic disassembly for gcc with -Wl,--traditional-format?

Postby simonsunnyboy » Tue Oct 31, 2017 9:13 am

I want to have DRI symbols in deployed Atari executables so it is possible to debug them with MonST, Bugaboo and Hatari's builtin debugger,

Otoh I want to use all available tools on the host during crosscompiling. This uses Vincent Riviere's toolchain.

So I need a second compile target or configuration switch?
A tool converting the normal format to the DRI format in a seperate file for loading with Hatari would be ok for me too. Honestly, using native ST debuggers is a "last desperate try" thing for debugging ;)
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

ThorstenOtto
Captain Atari
Captain Atari
Posts: 179
Joined: Sun Aug 03, 2014 5:54 pm

Re: Symbolic disassembly for gcc with -Wl,--traditional-format?

Postby ThorstenOtto » Tue Oct 31, 2017 10:13 am

simonsunnyboy wrote:A tool converting the normal format to the DRI format in a seperate file for loading with Hatari would be ok for me too.


In the emutos repo there is a shell script map2sym.sh, which is not perfect, but able to generate a text file from the symbol map, that can be read by Hatari.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4875
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Symbolic disassembly for gcc with -Wl,--traditional-format?

Postby simonsunnyboy » Tue Oct 31, 2017 10:35 am

ThorstenOtto wrote:
simonsunnyboy wrote:A tool converting the normal format to the DRI format in a seperate file for loading with Hatari would be ok for me too.


In the emutos repo there is a shell script map2sym.sh, which is not perfect, but able to generate a text file from the symbol map, that can be read by Hatari.


Thank you, I will take a look at this!
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1564
Joined: Sun Jul 31, 2011 1:11 pm

Re: Symbolic disassembly for gcc with -Wl,--traditional-format?

Postby Eero Tamminen » Tue Oct 31, 2017 11:09 pm

Downside of text symbols file is that you need to load that manually in Hatari debugger, instead of Hatari loading it automatically like happens with programs containing DRI symbols. Alternatively you could add some breakpoints that do the loading automatically for you, but that's going to require several (chained) debugger scripts, and using Hatari's --parse command line option (to start the chain).

(BadMood sources have examples of quite complicated chained breakpoints, used for automatically profiling different things.)

ThorstenOtto
Captain Atari
Captain Atari
Posts: 179
Joined: Sun Aug 03, 2014 5:54 pm

Re: Symbolic disassembly for gcc with -Wl,--traditional-format?

Postby ThorstenOtto » Wed Nov 01, 2017 2:53 am

Eero Tamminen wrote:Downside of text symbols file is that you need to load that manually in Hatari debugger, instead of Hatari loading it automatically like happens with programs containing DRI symbols.


Ever thought about implementing loading gnu-style symbols? Shouldn't be too hard, and you may find some useful code in the mintbin repo of freemint.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4875
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Symbolic disassembly for gcc with -Wl,--traditional-format?

Postby simonsunnyboy » Wed Nov 01, 2017 7:56 am

I'd appreciate having direct a.out symbols support in Hatari's debugger aswell.
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4875
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Symbolic disassembly for gcc with -Wl,--traditional-format?

Postby simonsunnyboy » Wed Nov 01, 2017 8:34 am

ThorstenOtto wrote:
simonsunnyboy wrote:A tool converting the normal format to the DRI format in a seperate file for loading with Hatari would be ok for me too.


In the emutos repo there is a shell script map2sym.sh, which is not perfect, but able to generate a text file from the symbol map, that can be read by Hatari.


Hmm, it does not work for me.
I compiled my program without -Wl,--traditional-format options.
m68k-atari-mint-objdump produces readable symbols.

Code: Select all

...
00000990 <_bordercolor>:
 990:   598f              subql #4,%sp
 992:   302f 0008         movew %sp@(8),%d0
 996:   1f40 0002         moveb %d0,%sp@(2)
 99a:   4200              clrb %d0
 99c:   588f              addql #4,%sp
 99e:   4e75              rts

...


m68k-atari-mint-nm produces a map file like this:

Code: Select all

00000388 t _assert_init
00000b70 b _basepage
00000100 a BASEPAGE_SIZE
00000928 T _bgcolor
00000990 T _bordercolor
...


But feeding the map file to map2sym.sh produces no output. Latest git for EmuTOS.
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

ThorstenOtto
Captain Atari
Captain Atari
Posts: 179
Joined: Sun Aug 03, 2014 5:54 pm

Re: Symbolic disassembly for gcc with -Wl,--traditional-format?

Postby ThorstenOtto » Wed Nov 01, 2017 11:00 am

Hm, might be a bit to special for EmuTOS purposes. But with a bit of knowledge of unix tools like sed and/or awk it shouldn't be difficult to come up with something that works for your purposes. The expected file for Hatari should look like

Code: Select all

0x0000000000e00030 T _main
0x0000000000e0010c T memdone
0x0000000000e00112 T _run_cartridge_applications


But feeding the map file to map2sym.sh produces no output. Latest git for EmuTOS.


No, that map already looks quite good. Maybe the "0x" are missing, dunno wether Hatari needs them. The script expects the mapfile that the linker produces as input, which looks like

Code: Select all

 .text          0x0000000000e00000      0x14c obj/startup.o
                0x0000000000e00000                _os_entry
                0x0000000000e00008                _os_beg
                0x0000000000e00014                _os_magic
                0x0000000000e00018                _os_date
                0x0000000000e0001c                _os_conf

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4875
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Symbolic disassembly for gcc with -Wl,--traditional-format?

Postby simonsunnyboy » Wed Nov 01, 2017 11:16 am

What is the command to produce the latter?
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

ThorstenOtto
Captain Atari
Captain Atari
Posts: 179
Joined: Sun Aug 03, 2014 5:54 pm

Re: Symbolic disassembly for gcc with -Wl,--traditional-format?

Postby ThorstenOtto » Thu Nov 02, 2017 1:46 am

Code: Select all

-Wl,-Map=myprog.map


if you use gcc to link your program, or

Code: Select all

-Map=myprog.map


if you use ld directly.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4875
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Symbolic disassembly for gcc with -Wl,--traditional-format?

Postby simonsunnyboy » Thu Nov 02, 2017 8:53 am

Thanks, I will add that to my build files in the future.

*EDIT*
And it is working now. With this input, map2sym.sh produces a *.sym listing. I will try it out later.

I am just wondering why nm outputs a different format.....
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1564
Joined: Sun Jul 31, 2011 1:11 pm

Re: Symbolic disassembly for gcc with -Wl,--traditional-format?

Postby Eero Tamminen » Sat Nov 04, 2017 7:37 pm

"nm" output is the ASCII format that Hatari debugger understands. As EmuTOS map2sym.sh script help says, its purpose is to covert linker symbol mappings file (a side-product of EmuTOS linking) to "nm" symbols format.

Linker mapping includes also information about in which object the symbols are. "nm" output cannot anymore have that, as objects are already linked together.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4875
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Symbolic disassembly for gcc with -Wl,--traditional-format?

Postby simonsunnyboy » Sun Nov 05, 2017 9:57 am

For the complete binary, is it important which object file contained the symbol? For me debugger symbols are just memory addresses. As Hatari is not a source level debugger, mapping to objects and thus source files seems not so important for me.

Where is the orginating object file important at this stage?
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1564
Joined: Sun Jul 31, 2011 1:11 pm

Re: Symbolic disassembly for gcc with -Wl,--traditional-format?

Postby Eero Tamminen » Sun Nov 05, 2017 6:50 pm

Where is the originating object file important at this stage?


It's not (*). Linker map is just what EmuTOS project uses to convert the symbol information to format accepted by Hatari.

(*) Unless you're missing symbols and you need to debug to which function some address might belong to. Then the address ranges for objects are useful. I've encountered this problem with some mintlib versions, C-library function that took most of time in BadMood, was the one for which symbols had been removed from official MiNTlib builds with badly selected linked options (I complained about that loudly on MiNT mailing list).

Besides GCC, AHCC linker can generate those too.

mikro
Atari God
Atari God
Posts: 1308
Joined: Sat Sep 10, 2005 11:11 am
Location: Brisbane, Queensland, Australia
Contact:

Re: Symbolic disassembly for gcc with -Wl,--traditional-format?

Postby mikro » Sun Nov 05, 2017 10:48 pm

Eero Tamminen wrote:I've encountered this problem with some mintlib versions, C-library function that took most of time in BadMood, was the one for which symbols had been removed from official MiNTlib builds with badly selected linked options (I complained about that loudly on MiNT mailing list).

... and look, it took only four years to get it fixed! ;-) Somehow I have totally forgotten about it and included the wrong switches in my Travis CI scripts as well. Now it's fixed for both mintlib and gemlib/cflib/gemma.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4875
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Symbolic disassembly for gcc with -Wl,--traditional-format?

Postby simonsunnyboy » Mon Nov 06, 2017 5:53 pm

So cut short, can I feed the output of nm to Hatari's symbol command?
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1564
Joined: Sun Jul 31, 2011 1:11 pm

Re: Symbolic disassembly for gcc with -Wl,--traditional-format?

Postby Eero Tamminen » Mon Nov 06, 2017 11:28 pm

Yes, I think so. Easiest is just to try it. :-)

Btw. Thorsten just mailed "a.out" symbol format support to hatari-devel. I'll test it soon (and add same support also for the external tool), if it works fine, it push it to Mercurial.

That should be really nice for debugging purposes. For profiling, one may want to go through the "nm" & manual ASCII symbols list loading, to be able to filter noise out of the symbols list (e.g. labels for loops really confuse users when they look at symbol call counts in profiler call-graphs).

ThorstenOtto
Captain Atari
Captain Atari
Posts: 179
Joined: Sun Aug 03, 2014 5:54 pm

Re: Symbolic disassembly for gcc with -Wl,--traditional-format?

Postby ThorstenOtto » Tue Nov 07, 2017 12:24 am

Eero Tamminen wrote:(and add same support also for the external tool)


I thought that won't be necessary, as you can use nm for that. But that tool has some options that nm does not have, so feel free to copy the code there, too ;)

Eero Tamminen wrote:if it works fine, it push it to Mercurial.


Any doubts on that? I'm disappointed ;)

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1564
Joined: Sun Jul 31, 2011 1:11 pm

Re: Symbolic disassembly for gcc with -Wl,--traditional-format?

Postby Eero Tamminen » Tue Nov 07, 2017 11:27 pm

ThorstenOtto wrote:
Eero Tamminen wrote:if it works fine, it push it to Mercurial.


Any doubts on that? I'm disappointed ;)


Well, I can't just push code untested, can I? There could be other changes that have broken your changes. :-)


Social Media

     

Return to “C / PASCAL etc.”

Who is online

Users browsing this forum: No registered users and 2 guests