-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
support dynamic linkers #21
Comments
probably needs more syscalls needs reading the dynamic linker section dyld is WEIRD x86_64 linux test currently fails to load symbols - it jumps to 0 from PLT |
currently static and dynamically linked glibc all crash on load for various reasons. haven't tried any other libc implementations, and osx dynamic linking isn't supported yet either. |
fixed glibc crashes (was bad interp entry point) |
fixed incorrect auxv for musl and glibc. musl crashes in decode_vec |
glibc is crashing at elf_get_dynamic_info() oh, I need to point to the program header inside the loaded section, not copy my own phdr in... |
@lunixbochs can you share your code to build x86.darwin.macho? |
It's just the test binary from https://github.com/lunixbochs/lib43 - if you want to build the 32-bit version specifically, do I'm assuming it works because lib43 doesn't care about macho auxv :) |
osx auxv equivalent is supported on x86_64 now. the primary blocker is now unimplemented mach syscalls |
This is what happens on i386 after trying to run a dynamically linked binary:
|
That's a regression. I'm not sure why it's happening yet. Wouldn't be surprised if it's a problem in auxv. If you want to crack open the glibc source and take a look, narrowing this down would be helpful. |
You meant this? |
Yeah, but also where libname is set. I need to figure out what's wrong with my auxiliary vectors so I can fix them.
|
Would any of usercorn's tracing options be of any help here? |
Yeah. -trace should enable all of the useful tracing options. I don't recommend posting entire traces as they can be quite large (and I see the same error when I run one) |
No worries - I would've attached a file if you needed a trace. :) -original message- Yeah. -trace should enable all of the useful tracing options. I don't recommend posting entire traces as they can be quite large (and I see the same error when I run one) Reply to this email directly or view it on GitHub: |
I can offer this backtrace from gdb:
|
gdb isn't interesting here because it's attached to Usercorn (which I know very well) and not the target. Once I have #10 we'll be able to attach GDB to the target, but that shouldn't be necessary here (as Usercorn should be able to provide a symbolicated traceback if the binary has symbols). It might not work on dynamic symbols? (#79) |
okay, looks like phnum is zero for some reason, which makes phdr impossible to parse. |
Could you explain what's going on here? (I chose ./usercorn /bin64/ldd /bin64/wc --help
or
Thx! |
You can't run ldd under usercorn because it's a shell script that basically does In the other one, that's the bug this issue is about. Look at the stacktrace after -etrace to see where it's breaking. |
Oh, the |
Oh, it's actually This is my stacktrace:
|
Yeah, that's the trace. How do you pass vars of the guest environment to usercorn? |
Environment is inherited from host. It ends up on the stack above argv. |
I'd emailed you about this thinking I broke something with a little hack but it wasn't my fault after all:
I'm on 32-bit i386 linux. |
What's |
No idea about I don't have that binary any longer and rebuilt from the latest unstable source. That's what you meant, right? |
Can you git bisect to before this message was being printed, and see which usercorn -trace is longer? (fyi, |
I can't do that now but bisecting from memory it would have to be this one: I'll try to provide an actual trace comparison from before that later. |
Alright, if that's the case can you get me a trace from before and after (well, before and current unstable) when you get a chance? |
Ok, I tried building @ 95806ec but it failed with:
Any use going back further? |
For now, just the latest binary's trace: And an older one's @ 2b80f6a which just reads:
which, going in the opposite direction, was still the case @ d3f09a2 and the latest 3976cd6 brings back the same error. |
woah, my x86_64 dynamic musl-libc test works on the latest master, and my static glibc binary stopped working, so maybe it's fixed and I broke something else bisect shows this broke in 089b6fa |
Even though every trace shows: Inconsistency detected by ld.so: do-rel.h: 116: elf_dynamic_do_Rela: Assertion `map->l_info[(34 + 0 + (0x6fffffff - (0x6ffffff0)))] != ((void *)0)' failed! some binaries get stuff like this:
Is it about symlink handling? |
Symlinks are handled. I think there's actually a linux-specific bug. It's way more reliable on OS X. |
You probably mean darwin host; anyway could you point me to a minimal darwin lib/bin package for client testing? I have never tried the |
maybe puredarwin http://www.puredarwin.org/downloads/ |
I tried mounting the downloaded vmdk image with |
I'm not sending you OS X binaries, and I don't have any other xnu/darwin setup right now. |
Here's a tarball of the HFS rootfs from PureDarwinNano_20091226.tar.xz: https://bochs.info/~aegis/PureDarwin.tar.gz |
I'd already tried that too - the mounted iso image contains just a few files for booting from cd. How's the actual data supposed to be stored? |
Huh? This is a working root filesystem, with dynamic binaries, dyld, libraries, etc. Should be more than sufficient for basic dynamic link tests. |
Yeah, sorry, lack of concentration! I'd already had a file named Anyway, thanks a lot and getting back on topic: $ ./usercorn -prefix PureDarwin/ PureDarwin/bin/ls -l
+ block @0x8fe1fbb8
0x8fe1fbb8: 5a pop edx
0x8fe1fbb9: 89e1 mov ecx, esp edx 0x8fe1d33a
0x8fe1fbbb: 0f34 sysenter ecx 0x607fee2c
+ block @0x8fe1fbbd
0x8fe1fbbd: 0f1f00 nop dword ptr [eax]
0x8fe1fbc0: b806000000 mov eax, 6
0x8fe1fbc5: cd82 int 0x82 eax 0x00000006
panic: Syscall missing: 50331654
goroutine 17 [running, locked to thread]:
github.com/lunixbochs/usercorn/go.(*Usercorn).Syscall(0x106ca2a0, 0x3000006, 0x0, 0x0, 0x10856010, 0x0, 0x106122c0, 0x0, 0x0)
/home/odroid/go/src/github.com/lunixbochs/usercorn/go/usercorn.go:695 +0x130
github.com/lunixbochs/usercorn/go/arch/x86.DarwinSyscall(0xab29e740, 0x106ca2a0, 0x3)
/home/odroid/go/src/github.com/lunixbochs/usercorn/go/arch/x86/darwin.go:41 +0xfc
github.com/lunixbochs/usercorn/go/arch/x86.DarwinInterrupt(0xab29e740, 0x106ca2a0, 0x82)
/home/odroid/go/src/github.com/lunixbochs/usercorn/go/arch/x86/darwin.go:53 +0x80
github.com/lunixbochs/usercorn/go.(*Usercorn).addHooks.func5(0xab29e6b0, 0x106e04d0, 0x82)
/home/odroid/go/src/github.com/lunixbochs/usercorn/go/usercorn.go:553 +0x84
github.com/unicorn-engine/unicorn/bindings/go/unicorn.hookInterrupt(0x4c0148, 0x82, 0x108460b0)
/home/odroid/go/src/github.com/unicorn-engine/unicorn/bindings/go/unicorn/hook.go:45 +0x80 And it seems it's still just |
So this is LDT/GDT support on x86_32 aren't done yet, but I think if you want a 64-bit darwin root you need to build it yourself or find a mac. |
Ok, I'll explore the former option :) |
http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/i386_get_ldt.html There's a Unicorn register LDTR which points at the LDT memory address. I'm actually not sure what the LDT does in kernel mode (as I'm not doing a usermode transition). A workaround for now would be to actually set a GDT. There's experimental code in To read the userspace segment descriptors, you can do
You can do the opposite with |
gdtWrite is actually working now, so maybe PureDarwin could be supported with this. |
Thanks, I've just confirmed |
Closing this. Will break out a couple of remaining tasks. |
The text was updated successfully, but these errors were encountered: