loadlibrary icon indicating copy to clipboard operation
loadlibrary copied to clipboard

Make it easier to identify what undefined symbol is being called

Open jrmuizel opened this issue 8 years ago • 5 comments

when modifying mpclient to load a dll that depends on msvcrt.dll I get the following error when running the entry point: function at 0xf72cad9b attempted to call an unknown symbol.

Is there a good way to figure out what the unknown symbol is?

jrmuizel avatar Jun 08 '17 17:06 jrmuizel

There isn't a good way yet, If you change the CFLAGS in the Makefile to -UNDEBUG it will dump all the undefined imports (the output is quite verbose though).

I think it will be possible to generate stubs for each undefined import that prints out the unknown symbol, but I haven't implemented that yet! I should do that. I'll need to think about it, because I think each stub will have to be generated at runtime.

Maybe I can generate a table of callsites...

taviso avatar Jun 09 '17 15:06 taviso

The technique that I ended up using was stepping backwards to the caller using rr and then seeing where the offset into the import table was compared to other symbols that I dumped using -UNDEBUG

jrmuizel avatar Jun 09 '17 15:06 jrmuizel

Hi, I face the same issue while porting my dll file in Linux as well. Is there any progress to identify the undefined symbol? Also, I wonder is there any workaround after locate the undefined symbol. Thank you.

posutsai avatar Jun 22 '21 06:06 posutsai

@taviso: since it seems you didn't get around to implementing the automatic stub generation yet, you should know that I already spent a considerable amount of time doing precisely that for the purposes of my android translation layer (it's more like wine than like this project, but this part is definitely applicable)

see this: https://gitlab.com/Mis012/dalvik_standalone/-/blob/art-master/bionic_translation/linker/linker.c#L1419-L1478

it wasn't exactly easy to figure out all of the kinks, so I hope it saves you from having to deal with that yourself (though some of the kinks were aarch64 specific, not sure if this project works with aarch64 dlls)

note: I hereby dual-license that code to you under the original license AND GPLv2

Mis012 avatar Mar 08 '23 20:03 Mis012

Whoa, thanks! I think I can probably merge this this weekend - I've been meaning to get to this forever.

I need to work on merging the x64 code as well - sorry this dropped off my radar!

On Wed, Mar 8, 2023, 12:09 PM Mis012 @.***> wrote:

@taviso https://github.com/taviso: since it seems you didn't get around to implementing the automatic stub generation yet, you should know that I already spent a considerable amount of time doing precisely that for the purposes of my android translation layer (it's more like wine than like this project, but this part is definitely applicable)

see this:

https://gitlab.com/Mis012/dalvik_standalone/-/blob/art-master/bionic_translation/linker/linker.c#L1419-L1478

it wasn't exactly easy to figure out all of the kinks, so I hope it saves you from having to deal with that yourself (though some of the kinks were aarch64 specific, not sure if this project works with aarch64 dlls)

note: I hereby dual-license that code to you under the original license AND GPLv2

— Reply to this email directly, view it on GitHub https://github.com/taviso/loadlibrary/issues/24#issuecomment-1460801311, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA6HJVVREH5CUFZD5ENXZLW3DRQBANCNFSM4DORO23A . You are receiving this because you were mentioned.Message ID: @.***>

taviso avatar Mar 08 '23 21:03 taviso