
Linux x86 Program Start Up - bluetomcat
http://dbp-consulting.com/tutorials/debugging/linuxProgramStartup.html
======
userbinator
Coming from DOS/Windows the amount of... extra cruft that gets linked into a
Linux binary by default seems rather excessive. The equivalent startup code in
Windows for a C program doesn't involve constructors or destructors, for one
thing. From the entry point, there's a total of ~7 functions called in the
default stub - most of them for parsing the environment variables and creating
argc/argv, and for programs that don't need that it's quite easy to eliminate
those too.

(The whole ELF/dynamic linking system is another thing that has always seemed
overly complex to me, compared to PE/DLLs.)

~~~
jjoonathan
But Windows still supports constructors and destructors, right? I don't
understand how it eliminate the complexity.

Do you mean that the windows equivalent of _start is nested less deeply and
with more reasonable naming conventions?

------
dexen
On the other side of the spectrum, a tiny ELF executable is possible at 45
bytes:
[http://www.muppetlabs.com/~breadbox/software/tiny/teensy.htm...](http://www.muppetlabs.com/~breadbox/software/tiny/teensy.html)

Previous discussion:
[https://news.ycombinator.com/item?id=5016434](https://news.ycombinator.com/item?id=5016434)

------
dgquintas
A different take on the same matter:
[http://www.bottomupcs.com/starting_a_process.html](http://www.bottomupcs.com/starting_a_process.html)

------
planckscnst
I posted this the last time a similar article came up and a couple people
seemed interested. I'm still trying to gauge whether anyone would be
interested in a podcast about this kind of stuff. I've started putting
together notes for this podcast here:
[https://docs.google.com/document/d/1Nn01yDS5PkiegHq4Oxz43xUQ...](https://docs.google.com/document/d/1Nn01yDS5PkiegHq4Oxz43xUQRLHqbc5l5GCRjTEzRw8/edit?usp=sharing)

------
tibiapejagala
Anyone got similar article for windows?

------
umanwizard
This appears to only be about userland stuff. Would be nice to explain what
"execve" does.

~~~
Animats
It's a hack left over from the early days when AT&T UNIX became BSD. Under
pre-BSD UNIX systems, a program was started by forking a new process, which
meant sharing the code and copying the data. Then the new process did an exec,
which loaded a new code segment and wiped the data segment that had just been
copied. Copying the data segment and immediately overwriting it was
inefficient, so several new flavors of "exec" were developed to get around
that.

There probably should have just been a "run" call, which started a subprocess
given the indicated executable. Some UNIX-like operating systems have that. It
has the nice property that it scales to clusters; there's no reason a
subprocess can't run on another machine. QNX, for example, supports that.

~~~
yuubi
> Copying the data segment and immediately overwriting it was inefficient, so
> several new flavors of "exec" were developed to get around that.

The several different flavors of exec are just convenience functions that lead
to an execve syscall (execl* makes the vector out of some of its args; exec*p
searches the path first, etc). Maybe you're thinking of vfork (a restricted
fork), which seems to have gone away about when copy-on-write came in.

~~~
Animats
Right.

------
aroman
This looks like a fantastic resource, but I was off put by the (albeit tongue-
in-cheek) 'RMUVI - Real Men Use VI' line in the article.

~~~
anon4
Because of the "men", because of the "vi", because of the "real", or because
it's a jab at the readership?

Some time ago, I would have just assumed you were an emacs user, but these
days there's a much larger diversity of people on the internet, who get
offended by very many things.

~~~
a1a
It might as well say "Real _hackers_ use vi", "Real _programmers_ use vi", or
whatever. I do not see why it needs to be gender related.

The author should write whatever he pleases. But I believe it would be proper
to use a language directed to a broader audience when writing a public blog
post. I also believe that the author was trying to be funny and had no bad
intents what so ever, but either way these tiny things matter if we ever want
to see diversity in our field.

I would also like to add that your argumentation is quite unpleasant to me. I
read it as you believe that diversity is this annoying thing that destroys the
good ol' "all dude internet". Would you care to clarify what you meant?

~~~
Dewie
> I would also like to add that your argumentation is quite unpleasant to me.
> I read it as you believe that diversity is this annoying thing that destroys
> the good ol' "all dude internet".

So you're saying that men (read: dudes) can't be offended by this, also? That
insults me.

Seriously though: "real men" phrases are often used in a serious way to try to
police men's behaviour (you probably know this already, but anyway). So I, as
a man, often feel queasy about "real men" quips. But real men aren't supposed
to feel uneasy about such things, so I don't know.. ;)

I don't personally feel uneasy about this: it feels like satire that plays on
the old trope of "real men do <thing that is hard, often unnecessarily so>",
and all over "trivial" things like text editors. I can see how some people
might be offended by the phrase, though. I'm just talking for myself here.

(I hope no vi users were offended by this post.)

~~~
crypt1d
Real men don't get insulted about real men posts.

~~~
Dewie
Exactly ;)

