]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/crt-vars-libSystem.dtest/main.c
2 // BUILD: $CC main.c -o $BUILD_DIR/crt-vars-libSystem.exe
4 // RUN: ./crt-vars-libSystem.exe
9 #include <crt_externs.h>
10 #include <mach-o/ldsyms.h>
12 #include "test_support.h"
14 // This struct is passed as fifth parameter to libSystem.dylib's initializer so it record
15 // the address of crt global variables.
26 // global variables defeined in crt1.o
29 extern char** environ
;
30 extern char* __progname
;
33 static const struct ProgramVars
* sVars
;
35 void __attribute__((constructor
))
36 myInit(int argc
, const char* argv
[], const char* envp
[], const char* apple
[], const struct ProgramVars
* vars
)
41 int main(int argc
, const char* argv
[], const char* envp
[], const char* apple
[]) {
42 if ( _NSGetArgv() != &NXArgv
) {
43 FAIL("_NSGetArgv() != &NXArgv (%p!=%p) for %s", _NSGetArgv(), &NXArgv
, argv
[0]);
46 if ( _NSGetArgc() != &NXArgc
) {
47 FAIL("_NSGetArgc() != &NXArgc (%p!=%p) for %s", _NSGetArgc(), &NXArgc
, argv
[0]);
50 if ( _NSGetEnviron() != &environ
) {
51 FAIL("_NSGetEnviron() != &environv (%p!=%p) for %s", _NSGetEnviron(), &environ
, argv
[0]);
54 if ( _NSGetProgname() != &__progname
) {
55 FAIL("_NSGetProgname() != &__progname (%p!=%p) for %s", _NSGetProgname(), &__progname
, argv
[0]);
58 if ( _NSGetMachExecuteHeader() != &_mh_execute_header
) {
59 FAIL("_NSGetMachExecuteHeader() != &_mh_execute_headerv (%p!=%p) for %s", _NSGetMachExecuteHeader(), &_mh_execute_header
, argv
[0]);
62 if ( sVars
->NXArgvPtr
!= &NXArgv
) {
63 FAIL("sVars->NXArgvPtr != &NXArg (%p!=%p) for %s", sVars
->NXArgvPtr
, &NXArgv
, argv
[0]);
66 if ( sVars
->NXArgcPtr
!= &NXArgc
) {
67 FAIL("sVars->NXArgcPtr != &NXArgc (%p!=%p) for %s", sVars
->NXArgcPtr
, &NXArgc
, argv
[0]);
70 if ( sVars
->environPtr
!= &environ
) {
71 FAIL("sVars->environPtr != &environ (%p!=%p) for %s", sVars
->environPtr
, &environ
, argv
[0]);
74 if ( sVars
->__prognamePtr
!= &__progname
) {
75 FAIL("sVars->__prognamePtr != &__progname (%p!=%p) for %s", sVars
->__prognamePtr
, &__progname
, argv
[0]);
78 if ( sVars
->mh
!= &_mh_execute_header
) {
79 FAIL("sVars->mh != &_mh_execute_header (%p!=%p) for %s", sVars
->mh
, &_mh_execute_header
, argv
[0]);