Skip to content
This repository has been archived by the owner on Dec 30, 2021. It is now read-only.

support static binaries #28

Open
wangbj opened this issue Mar 15, 2019 · 6 comments
Open

support static binaries #28

wangbj opened this issue Mar 15, 2019 · 6 comments
Assignees

Comments

@wangbj
Copy link
Collaborator

wangbj commented Mar 15, 2019

Currently we rely on LD_PRELOAD to load the --tool library, however, LD_PRELOAD doesn't work with static binaries, such as compiled go programs. It is possible to write our own mini (dynamic) loader, for static binaries only, though it wouldn't be trivial to write a dynamic loader.

@rrnewton
Copy link
Collaborator

When we do need to cross this bridge, is there any shortcut to take? Currently the --tool is provided only as a shared object, but perhaps there is some other format (maybe just a .o file?) that is easier to manually link in?

GHCI for a long time maintained their own loader... I can't recall if they ever successfully got rid of it.

Here's another dumb question... is there a reason you can't hackily invoke the normal dynamic linker via ptrace from inside the execution of a statically-binary guest?

@wangbj
Copy link
Collaborator Author

wangbj commented Mar 15, 2019

It might be possible, I haven't spend too much time thinking of it, but we might be able to hijack tracee's PC, then redirect it to do a dlopen, so we don't really to write our own loader. Will try this approach first.

@rrnewton
Copy link
Collaborator

Again, fine to push down the road for now ;-). But always ok to spend a 1-3 hours and just poke at it to probe how hard it will be.

@wangbj
Copy link
Collaborator Author

wangbj commented Mar 15, 2019

I didn't know GHC maintained their own loader, dlopen might not work, because it requires a symbol from ld-linux.so.

@wangbj
Copy link
Collaborator Author

wangbj commented Mar 15, 2019

likely we could try to write a static loader (way easier) to load ld-linux.so, and then ask ld-linux.so to load the tool library (by dlopen).

@wangbj wangbj self-assigned this Mar 15, 2019
@wangbj
Copy link
Collaborator Author

wangbj commented Mar 21, 2019

The problem with is ld-linux.so doesn't seem export symbols to load other libraries, it has a function named _dl_open (not the same as dlopen, which is in libdl.so), but it is not exported and there's no easy/portable way to find it's address, symbol looking won't work either, because it is completely hidden.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants