gcc-ia16 icon indicating copy to clipboard operation
gcc-ia16 copied to clipboard

Question: How to determine start offset of eg main function in segment

Open ecm-pushbx opened this issue 3 years ago • 2 comments

As shown in my feature request I would like to trace assembly listing files created by gcc-ia16 using my debugger and trace listing viewer. Unlike simple DOS executables written in NASM assembly, the object-local zero offset does not correspond to a well-known offset (0100h) in the final executable's CS. Unlike, also, more complex DOS executables, the offset is apparently not one of a limited set of other possibilities either (0000h, 7C00h). This is what the listing file shows:

   8                            .text
   9                            .global main
  11                    main:
  12 0000 55                    push    bp

This instruction ended up at offset 0241h in the final file. How can I determine this number automatically so I can feed it to traclist?

ecm-pushbx avatar May 17 '22 18:05 ecm-pushbx

It appears that the map file can be used to find the offset. The map file can be generated by passing -Xlinker -Map=output.map to gcc. Buried in there we get:

 .text          0x0000000000000241       0x14 /tmp/ccY2O2dO.o
                0x0000000000000241                main

I'm unsure how to distinguish the tmp object from all other parts that are listed in the map file, however.

ecm-pushbx avatar May 17 '22 18:05 ecm-pushbx

@ecm-pushbx : maybe try generate the .o files as intermediate outputs, rather than going straight from .c to .exe. Thank you!

tkchia avatar May 17 '22 18:05 tkchia