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

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

Open
ecm-pushbx opened this issue May 17, 2022 · 2 comments
Open

Comments

@ecm-pushbx
Copy link

ecm-pushbx commented May 17, 2022

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
Copy link
Author

ecm-pushbx commented May 17, 2022

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.

@tkchia
Copy link
Owner

tkchia commented May 17, 2022

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

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