Unbreak relative references to immediate addresses
[nasm/autotest.git] / test / objlink.c
blob982ca59ebb3e19f44cc97cf00379134f74ebcf8d
1 /*
2 * test source file for assembling to Microsoft 16-bit .OBJ
3 * build with (16-bit Microsoft C):
4 * nasm -f obj objtest.asm
5 * cl /AL objtest.obj objlink.c
6 * other compilers should work too, provided they handle large
7 * model in the same way as MS C
8 */
10 #include <stdio.h>
12 int8_t text[] = "hello, world\n";
14 extern void function(int8_t *);
15 extern int bsssym, commvar;
16 extern void *selfptr;
17 extern void *selfptr2;
19 int main(void)
21 printf("these should be identical: %p, %p\n",
22 (int32_t)selfptr, (int32_t)&selfptr);
23 printf("these should be equivalent but different: %p, %p\n",
24 (int32_t)selfptr2, (int32_t)&selfptr2);
25 printf("you should see \"hello, world\" twice:\n");
26 bsssym = 0xF00D;
27 commvar = 0xD00F;
28 function(text);
29 printf("this should be 0xF00E: 0x%X\n", bsssym);
30 printf("this should be 0xD00E: 0x%X\n", commvar);
31 return 0;