]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/crt-old-mac10.6-vars-libSystem.dtest/main.c
1 // BUILD(macos|x86_64): $CC main.c -mmacosx-version-min=10.6 -o $BUILD_DIR/crt-vars10.6-libSystem.exe
3 // BUILD(ios,tvos,watchos,bridgeos):
5 // RUN: ./crt-vars10.6-libSystem.exe
10 #include <crt_externs.h>
11 #include <mach-o/ldsyms.h>
13 #include "test_support.h"
15 // This struct is passed as fifth parameter to libSystem.dylib's initializer so it record
16 // the address of crt global variables.
27 // global variables defeined in crt1.o
30 extern char** environ
;
31 extern char* __progname
;
34 static const struct ProgramVars
* sVars
;
36 void __attribute__((constructor
))
37 myInit(int argc
, const char* argv
[], const char* envp
[], const char* apple
[], const struct ProgramVars
* vars
)
43 int main(int argc
, const char* argv
[])
45 if ( _NSGetArgv() != &NXArgv
) {
46 FAIL("crt-libSystem: _NSGetArgv() != &NXArgv (%p!=%p) for %s", _NSGetArgv(), &NXArgv
, argv
[0]);
49 if ( _NSGetArgc() != &NXArgc
) {
50 FAIL("crt-libSystem: _NSGetArgc() != &NXArgc (%p!=%p) for %s", _NSGetArgc(), &NXArgc
, argv
[0]);
53 if ( _NSGetEnviron() != &environ
) {
54 FAIL("crt-libSystem: _NSGetEnviron() != &environv (%p!=%p) for %s", _NSGetEnviron(), &environ
, argv
[0]);
57 if ( _NSGetProgname() != &__progname
) {
58 FAIL("crt-libSystem: _NSGetProgname() != &__progname (%p!=%p) for %s", _NSGetProgname(), &__progname
, argv
[0]);
61 if ( _NSGetMachExecuteHeader() != &_mh_execute_header
) {
62 FAIL("crt-libSystem: _NSGetMachExecuteHeader() != &_mh_execute_headerv (%p!=%p) for %s", _NSGetMachExecuteHeader(), &_mh_execute_header
, argv
[0]);
65 if ( sVars
->NXArgvPtr
!= &NXArgv
) {
66 FAIL("crt-libSystem: sVars->NXArgvPtr != &NXArg (%p!=%p) for %s", sVars
->NXArgvPtr
, &NXArgv
, argv
[0]);
69 if ( sVars
->NXArgcPtr
!= &NXArgc
) {
70 FAIL("crt-libSystem: sVars->NXArgcPtr != &NXArgc (%p!=%p) for %s", sVars
->NXArgcPtr
, &NXArgc
, argv
[0]);
73 if ( sVars
->environPtr
!= &environ
) {
74 FAIL("crt-libSystem: sVars->environPtr != &environ (%p!=%p) for %s", sVars
->environPtr
, &environ
, argv
[0]);
77 if ( sVars
->__prognamePtr
!= &__progname
) {
78 FAIL("crt-libSystem: sVars->__prognamePtr != &__progname (%p!=%p) for %s", sVars
->__prognamePtr
, &__progname
, argv
[0]);
81 if ( sVars
->mh
!= &_mh_execute_header
) {
82 FAIL("crt-libSystem: sVars->mh != &_mh_execute_header (%p!=%p) for %s", sVars
->mh
, &_mh_execute_header
, argv
[0]);