Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That was a really cool article, anyone with more knowledge on the subject want to comment on how sound the author's thought process is? Thanks.


The article is quite sound and doing all this is standard practice in the embedded world where you can't afford the size of glibc. The article is a bit incomplete, but presumably he'll address the rest in his next installment.

As a preview, to provide the correct C ABI to main() you need to zero the BSS (this is how your static variables get initialized), maybe copy the initalized data, call the constructors and destructors for C++ / C (gcc extension), provide memcpy() and others stdlib functions (which gcc will use even if you don't), etc. You can do all of this without assembly in C, but it does take some effort.


> presumably he'll address the rest in his

by Jessica McKellar


Pretty sexist to make assumptions just because the dude's name is Jessica.


touché


It all looks correct to me. Some of it is a little "needlessly-surprised", honestly, like the bit about having to make a syscall trap to exit the program. Programs don't exit on their own: something needs to tell the kernel that the process is done.


This point isn't actually blindingly obvious. Those of us raised on Pascal might have assumed (or, in my case, actually did assume, without thinking hard about it) that the program ended when the execution point reached "the end," where the main method was probably located in the binary.

It's disturbing how many Pascal-isms still pervade my thinking, even 20 years since I last (willingly) touched the language.


I don't think this is blindingly obvious.

I always imagined something 'called us', then just returning from that would be enough to get everything shutdown.

Certainly when I wrote 6502 code, or 68000 code, I would just return.

On the iPhone, you get advised you are shutting down, do your clean-up, then someone shuts down the message loop and you are gone.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: