aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-12-13 17:34:15 +0100
committerlemon <lsof@mailbox.org>2025-12-13 17:39:08 +0100
commit6c7cdc537b7b341f9ca25a3e8b61de46c99840e7 (patch)
tree1cbbcee4cdace1c7f16d78ee46755d9cb825c754 /test
parentfc7048a0c4c4b9647f032edfba74f7d7a62335e1 (diff)
c: handle more static eval edgecases for int -> ptr
sqlite3 was falling back to `((void*)&((char*)0)[X])` for INT_TO_PTR, which this handles now.
Diffstat (limited to 'test')
-rw-r--r--test/15-reloc.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/15-reloc.c b/test/15-reloc.c
index cd91fd0..713e98d 100644
--- a/test/15-reloc.c
+++ b/test/15-reloc.c
@@ -3,6 +3,7 @@
1.3
5
ok
+0x55, 0x6, 5
*/
const void *const relro = &relro;
@@ -22,9 +23,17 @@ int (*(getputs(void)))(const char *) {
return t;
}
+static char *int2ptr[] = {
+ (void *)&*((char*)0 + 0x55),
+ (void *)&((short*)0)[0x3],
+ (void *)&*((char*)7 - 2),
+};
+
#include <stdio.h>
+#include <stdint.h>
int main() {
printf("%g\n", get_value(2));
printf("%d\n", ou(2));
getputs()("ok");
+ printf("%p, %p, %d\n", int2ptr[0], int2ptr[1], (int)(intptr_t)int2ptr[2]);
}