Ответ 1
Это полностью зависит от ABI для каждой платформы. Поскольку вы упоминаете eax
и ebx
, посмотрим, что это за x86. В fs/binfmt_elf.c
строке # 972 внутри load_elf_binary()
ядро проверяет, указывает ли ABI любой требования для значений регистра при загрузке программы:
/*
* The ABI may specify that certain registers be set up in special
* ways (on i386 %edx is the address of a DT_FINI function, for
* example. In addition, it may also specify (eg, PowerPC64 ELF)
* that the e_entry field is the address of the function descriptor
* for the startup routine, rather than the address of the startup
* routine itself. This macro performs whatever initialization to
* the regs structure is required as well as any relocations to the
* function descriptor entries when executing dynamically links apps.
*/
Затем он вызывает ELF_PLAT_INIT
, который является макросом, определенным для каждой архитектуры в arch/xxx/include/elf.h
. Для x86 он выполняет :
#define ELF_PLAT_INIT(_r, load_addr) \
do { \
_r->bx = 0; _r->cx = 0; _r->dx = 0; \
_r->si = 0; _r->di = 0; _r->bp = 0; \
_r->ax = 0; \
} while (0)
Итак, когда ваш билд ELF загружается в Linux x86, вы можете рассчитывать на то, что все значения регистра равны нулю. Но это не значит, что вы должны.: -)