Это полностью зависит от 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, вы можете рассчитывать, что все значения регистров равны нулю.Это не значит, что ты должен.: -)