Nick Desaulniers (paternity leave)

Results 129 comments of Nick Desaulniers (paternity leave)

I'm able to get the usage warning printing! w00t

does linux pass command line args on the stack? https://github.com/nemasu/asmttpd/blob/master/main.asm#L53-L58 When I inspect the registers on entry, %rdi is argc and %rsi is argv. The current code looks like it...

> argv and argc are passed on the stack. right, but it doesn't look to be the case for Mach-O binaries. Asking an friend who's an LLVM dev to confirm....

err, they're passed on the stack for 32b programs on Linux/OSX and in %rdi and %rsi for 64b programs. The makefile makes it looks like you're compiling a 64b binary,...

If we take a look at the dissasembly on OSX: ``` Disassembly of section .text: 0000000100000f60 : #include int main (int argc, char** argv) { 100000f60: 55 push %rbp 100000f61:...

> Unless _start is pulling things off the stack and into registers before calling into _main. That MUST be the case. Without the `-osx_min_version` flag to ld, arguments are indeed...

For my reference, `man syscall` and `/usr/include/sys/syscall.h` are helpful!

Looks like _start is defined in `/usr/lib/crt1.o`, which should be linked against, according to `man 1 ld`.

I've got a lot more of this working. The real work will be pthread_create (processes and threads are created with clone(2) on Linux, not so on OSX), and nanosleep (nanosleep(2)...

pthread_create: - proc_info - bsdthread_create - thread_selfid pthread_join: - __disable_threadsignal - __semwait_signal