[Question] debug bionic linker with gdb

Skip to first unread message

Chen Wang

Dec 28, 2020, 1:34:30 PM12/28/20
to android-porting
Hi, android team guys,
I am working on port aosp to other isa than arm/x86. When I am debugging bionic/linker, I find a strange question, that is the gdb can not get file/line info from the linker_main.c, but for other files in linker, it works as normal.
I am running qemu as gdb server and run gdb as client to connect to qemu remotely.
I confirm that all the source files are compiled with "-g" and I can see the linker executable contains debug info with objdump.
Why it's special for the linker_main.c? What should I do to handle this?
Thanks in adv.

Notur Business

Mar 20, 2021, 1:11:37 PM3/20/21
to android-porting

I assume being linux the linker makes a .o, first insure the make (script) does make an .o  (sometimes, making a library, separate .o are not made or not made for one of all of the .cpp)

Insure this .cpp is not merely included into another .cpp:  if it is there will be no separate object file for it but there will be a trace for it whenever execution passes through it.  You should know how you can generate a separate object file by hand.

The file does not define main(), it defines ?1 function.  It has various "compiler markings" (like HIDDEN), so the linker may treat it specially even if any .o file contains the function it defines.  There's a 50% chance this is the issue.

It appears to be part of the library loader which, by android guidelines, you aren't allowed to alter.  You shouldn't have a reason for tracing into it.  I can say though even if you persist that the linux loader is "properly" changed by using it's configuration files (to get specific needs done), rather than hacking the loader code.

That may be all very basic material for you you already know.  I have no idea.
Reply all
Reply to author
0 new messages