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