]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/bind-addend.dtest/main.c
2 // BUILD: $CC main.c -o $BUILD_DIR/bind-addend.exe -lobjc
4 // RUN: ./bind-addend.exe
6 // Verify that negative addends work with pointers in to the shared cache and pointers to the image itself
10 #include "test_support.h"
12 // Note this is weak so that we have a bind
16 // Choose a large enough negative offset to be before the shared cache or the image
17 const uintptr_t offset
= 1ULL << 36;
18 void* pMinus
= (void*)((uintptr_t)&p
- offset
);
20 // Get a pointer to something we assume is in the shared cache
21 // Note we don't declare a function as arm64e would want to sign this
22 extern int objc_msgSend
;
23 void* msgSendMinus
= (void*)((uintptr_t)&objc_msgSend
- offset
);
25 int main(int argc
, const char* argv
[], const char* envp
[], const char* apple
[]) {
26 if ( pMinus
!= (void*)((uintptr_t)&p
- offset
) ) {
27 FAIL("bind-addend: %p != %p", pMinus
, (void*)((uintptr_t)&p
- offset
));
30 if ( msgSendMinus
!= (void*)((uintptr_t)&objc_msgSend
- offset
) ) {
31 FAIL("bind-addend: %p != %p", msgSendMinus
, (void*)((uintptr_t)&objc_msgSend
- offset
));