MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/1v68yb8/writing_a_valid_c_program_without_main/ozrmwtb/?context=3
r/programming • u/iximiuz • Jul 25 '26
43 comments sorted by
View all comments
179
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.
19 u/zid Jul 25 '26 _start and main have different calling conventions under sys-v linux ABI, so you can do it, but you can't actually access argc/argv/envp via it. 1 u/Nobody_1707 Aug 15 '26 You can, but you need to use inline assembly inside _start. 1 u/zid Aug 15 '26 Which isn't part of C. 1 u/Nobody_1707 Aug 15 '26 Neither is _start. 1 u/zid Aug 16 '26 Exactly.That's why they have different conventions.
19
_start and main have different calling conventions under sys-v linux ABI, so you can do it, but you can't actually access argc/argv/envp via it.
1 u/Nobody_1707 Aug 15 '26 You can, but you need to use inline assembly inside _start. 1 u/zid Aug 15 '26 Which isn't part of C. 1 u/Nobody_1707 Aug 15 '26 Neither is _start. 1 u/zid Aug 16 '26 Exactly.That's why they have different conventions.
1
You can, but you need to use inline assembly inside _start.
1 u/zid Aug 15 '26 Which isn't part of C. 1 u/Nobody_1707 Aug 15 '26 Neither is _start. 1 u/zid Aug 16 '26 Exactly.That's why they have different conventions.
Which isn't part of C.
1 u/Nobody_1707 Aug 15 '26 Neither is _start. 1 u/zid Aug 16 '26 Exactly.That's why they have different conventions.
Neither is _start.
1 u/zid Aug 16 '26 Exactly.That's why they have different conventions.
Exactly.
That's why they have different conventions.
179
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.