9 #include <mach/machine.h>
11 #include <System/sys/reason.h>
12 #include <System/sys/proc_info.h>
13 #include <System/kern/kern_cdata.h>
15 #include <mach-o/dyld_priv.h>
18 // arm64e uses chained binds which does not support lazy binding
19 #define SUPPORTS_LAZY_BINDING 0
21 #define SUPPORTS_LAZY_BINDING 1
24 #include "test_support.h"
26 int main(int argc
, const char* argv
[], const char* envp
[], const char* apple
[]) {
27 #if SUPPORTS_LAZY_BINDING
29 process
.set_executable_path(RUN_DIR
"/lazy-symbol-missing-called.exe");
30 const char* env
[] = { "TEST_OUTPUT=None", NULL
};
32 process
.set_exit_handler(^(pid_t pid
) {
33 LOG("Child exited pid=%d", pid
);
35 struct proc_exitreasoninfo info
;
36 bzero(&info
, sizeof(info
));
37 uint8_t packReasonData
[OS_REASON_BUFFER_MAX_SIZE
];
38 bzero(packReasonData
, OS_REASON_BUFFER_MAX_SIZE
);
39 info
.eri_reason_buf_size
= OS_REASON_BUFFER_MAX_SIZE
;
40 info
.eri_kcd_buf
= (user_addr_t
)packReasonData
;
41 LOG("info=%p", &info
);
42 int procResult
= proc_pidinfo(pid
, PROC_PIDEXITREASONINFO
, 1, &info
, PROC_PIDEXITREASONINFO_SIZE
);
43 if ( procResult
!= sizeof(struct proc_exitreasoninfo
) ) {
44 FAIL("bad return size from proc_pidinfo(), %d expected %lu", procResult
, PROC_PIDEXITREASONINFO_SIZE
);
46 if ( info
.eri_namespace
!= OS_REASON_DYLD
) {
47 FAIL("eri_namespace (%d) != OS_REASON_DYLD", info
.eri_namespace
);
51 (void)process
.launch();