2026-09-25 09:11 UTC
Replies (1)
-
@navi@social.vlhl.dev 2026-09-25 09:30
@fiore@brain.worm.pink @coolbean@brain.worm.pink (oh i was already typing a reply) first, argc itself purely is defined by the abi, e.g. for the x86_64 sysv abi¹ (which linux uses), the argument count is defined as "an eightbyte", which is more than an int in x86_64 (4 bytes) but c does require main to be `int argc, char *argv[]`, so, c spec time, does int have a size? yes... kinda², the standard says that UINT_WIDTH, the width for an object of type unsigned int, is 16 bits or more so your minimum, is 2 bytes, though in most platforms, it's 4 bytes, and "natively" outside c in x86_64 sysv specifically, it's actually 8 bytes, because it's just the word size of the processor -- your libc then implements _start, parses the aux data in the stack, and calls your main function passing in the value as an `int` not that it matters much, tbh, even with the lowest range here, 2 byte int, that's still 32767 arguments, you're gonna hit posix's ARG_MAX wayy before you hit that limit 1: https://refspecs.linuxbase.org/elf/x86_64-abi-0.99.pdf -- figure 3.9, initial process stack 2: https://open-std.org/JTC1/SC22/WG14/www/docs/n3220.pdf -- 5.2.5.3.2 - Characteristics of integer types