aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-elf/p_align-1.c
diff options
context:
space:
mode:
Diffstat (limited to 'ld/testsuite/ld-elf/p_align-1.c')
-rw-r--r--ld/testsuite/ld-elf/p_align-1.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/ld/testsuite/ld-elf/p_align-1.c b/ld/testsuite/ld-elf/p_align-1.c
new file mode 100644
index 0000000..6579cd7
--- /dev/null
+++ b/ld/testsuite/ld-elf/p_align-1.c
@@ -0,0 +1,25 @@
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#ifndef ALIGN
+# define ALIGN 0x800000
+#endif
+
+int
+__attribute__ ((weak))
+is_aligned (void *p, int align)
+{
+ return (((uintptr_t) p) & (align - 1)) == 0;
+}
+
+int foo __attribute__ ((aligned (ALIGN))) = 1;
+
+int
+main (void)
+{
+ if (!is_aligned (&foo, ALIGN))
+ abort ();
+ printf ("PASS\n");
+ return 0;
+}