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

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

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

Post Reply
simonsunnyboy
Moderator
Moderator
Posts: 5235
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

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

Post by simonsunnyboy »

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/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee
User avatar
Eero Tamminen
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2189
Joined: Sun Jul 31, 2011 1:11 pm

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

Post by Eero Tamminen »

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
Hardware Guru
Hardware Guru
Posts: 2218
Joined: Sat Sep 10, 2005 11:11 am
Location: Kosice, Slovakia
Contact:

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

Post by mikro »

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.
simonsunnyboy
Moderator
Moderator
Posts: 5235
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

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

Post by simonsunnyboy »

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/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee
ThorstenOtto
Atari God
Atari God
Posts: 1196
Joined: Sun Aug 03, 2014 5:54 pm

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

Post by ThorstenOtto »

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.
simonsunnyboy
Moderator
Moderator
Posts: 5235
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

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

Post by simonsunnyboy »

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/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee
User avatar
Eero Tamminen
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2189
Joined: Sun Jul 31, 2011 1:11 pm

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

Post by Eero Tamminen »

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
Atari God
Atari God
Posts: 1196
Joined: Sun Aug 03, 2014 5:54 pm

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

Post by ThorstenOtto »

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.
simonsunnyboy
Moderator
Moderator
Posts: 5235
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

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

Post by simonsunnyboy »

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

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee
simonsunnyboy
Moderator
Moderator
Posts: 5235
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

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

Post by simonsunnyboy »

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/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee
ThorstenOtto
Atari God
Atari God
Posts: 1196
Joined: Sun Aug 03, 2014 5:54 pm

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

Post by ThorstenOtto »

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
simonsunnyboy
Moderator
Moderator
Posts: 5235
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

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

Post by simonsunnyboy »

What is the command to produce the latter?
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee
ThorstenOtto
Atari God
Atari God
Posts: 1196
Joined: Sun Aug 03, 2014 5:54 pm

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

Post by ThorstenOtto »

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.
simonsunnyboy
Moderator
Moderator
Posts: 5235
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

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

Post by simonsunnyboy »

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/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee
User avatar
Eero Tamminen
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2189
Joined: Sun Jul 31, 2011 1:11 pm

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

Post by Eero Tamminen »

"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.
simonsunnyboy
Moderator
Moderator
Posts: 5235
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

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

Post by simonsunnyboy »

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/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee
User avatar
Eero Tamminen
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2189
Joined: Sun Jul 31, 2011 1:11 pm

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

Post by Eero Tamminen »

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
Hardware Guru
Hardware Guru
Posts: 2218
Joined: Sat Sep 10, 2005 11:11 am
Location: Kosice, Slovakia
Contact:

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

Post by mikro »

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.
simonsunnyboy
Moderator
Moderator
Posts: 5235
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

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

Post by simonsunnyboy »

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

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee
User avatar
Eero Tamminen
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2189
Joined: Sun Jul 31, 2011 1:11 pm

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

Post by Eero Tamminen »

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
Atari God
Atari God
Posts: 1196
Joined: Sun Aug 03, 2014 5:54 pm

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

Post by ThorstenOtto »

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
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2189
Joined: Sun Jul 31, 2011 1:11 pm

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

Post by Eero Tamminen »

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. :-)
Post Reply

Return to “C / PASCAL etc.”