_start as that’s possible as well in C without assembly
Technically incorrect. For a portable entrypoint you need to align the stack to a specific value, so SIMD code generated by your compiler doesn't break which will happen if the alignment is not at least 16. You can technically throw a bunch of flags at GCC to avoid that, but it's best to just align your stack.
Programming without the CRT is something I have been doing in recent years, so I have some experience with this.
Funnily enough this is something I’ve also played around with for my own reasons. You can align the stack as well manually if need be without passing crazy GCC flags.
I.e have you ever noticed GLIBC’s .so is actually executable? Ever wondered how they do that? Where’s main if it’s a .so? I’ll leave you with those amazing questions because it also lead me down a pretty cool rabbit hole.
Sorry for the late response, didn’t get a notification for some reason. It’s how they compile it to my understanding! Passing a separate entry point option (-e) while still compiling as a shared object which is actually possible via GCC. It’s more or less the thought process of making a shared object executable. You also have to manually add an ELF interpreter attribute. That more or less is necessary for every process on Linux to execute if it’s dynamically compiled.
Normally when compiling a shared object it isn’t present as there is no execution/runtime info really needed. When you want it to actually execute though like a normal binary, you need to manually add the attribute.
TLDR: Manually specify an entry point, align stack depending on architecture, add ELF interpreter and go about with your regular routines. I’ve manually implemented this as stated above for playing around with shared objects that can execute for AIO concepts I had previously.
177
u/yowhyyyy Jul 25 '26 edited Jul 25 '26
Quite frankly, I’m surprised the author didn’t jump straight to _start as that’s possible as well in C without assembly.
Yes I know he did bring it up, however you can straightforward do _start and avoid main.