d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe# This file and its contents are supplied under the terms of the
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe# Common Development and Distribution License ("CDDL"), version 1.0.
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe# You may only use this file in accordance with the terms of version
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe# 1.0 of the CDDL.
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe# A full copy of the text of the CDDL should have accompanied this
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe# source. A copy of the CDDL is also available via the Internet at
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe# Copyright 2015, Richard Lowe.
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe#include <stdio.h>
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe#include <unistd.h>
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowemain(int argc, char **argv)
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe sleep(10000);
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowegcc -o tester-noaslr tester.c -Wl,-z,aslr=disabled
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe# This is the easiest way I've found to get many many DTs, but it's gross
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowegcc -o many-dts-aslr tester.c -Wl,-z,aslr=enabled $(for elt in /usr/lib/lib*.so; do echo -Wl,-N,$(basename $elt); done)
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowegcc -o many-dts-noaslr tester.c -Wl,-z,aslr=disabled $(for elt in /usr/lib/lib*.so; do echo -Wl,-N,$(basename $elt); done)
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowecheck ./tester-aslr 0 E || fail "DT_SUNW_ASLR 1 failed"
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowecheck ./many-dts-aslr 0 E || fail "DT_SUNW_ASLR 1 with many DTs failed"
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowecheck ./tester-aslr 1 I || fail "DT_SUNW_ASLR 1 incorrectly set the inheritable flag"
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowecheck ./tester-noaslr 1 E || fail "DT_SUNW_ASLR 0 failed"
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowecheck ./many-dts-noaslr 1 E || fail "DT_SUNW_ASLR 0 with many DTs failed"