aboutsummaryrefslogtreecommitdiff
path: root/gold/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'gold/testsuite')
-rw-r--r--gold/testsuite/Makefile.am4
-rw-r--r--gold/testsuite/Makefile.in12
-rw-r--r--gold/testsuite/relro_test.cc4
-rwxr-xr-xgold/testsuite/relro_test.sh73
4 files changed, 88 insertions, 5 deletions
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index c4e6c03..fb4d4e3 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -1076,6 +1076,8 @@ protected_3.err: protected_4_pic.o gcctestdir/ld
fi
check_PROGRAMS += relro_test
+check_SCRIPTS += relro_test.sh
+check_DATA += relro_test.stdout
relro_test_SOURCES = relro_test_main.cc
relro_test_DEPENDENCIES = gcctestdir/ld relro_test.so
relro_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
@@ -1084,6 +1086,8 @@ relro_test.so: gcctestdir/ld relro_test_pic.o
$(CXXLINK) -Bgcctestdir/ -shared -Wl,-z,relro relro_test_pic.o
relro_test_pic.o: relro_test.cc
$(CXXCOMPILE) -c -fpic -o $@ $<
+relro_test.stdout: relro_test.so
+ $(TEST_READELF) -SlW relro_test.so > relro_test.stdout
check_PROGRAMS += relro_strip_test
relro_strip_test_SOURCES = relro_test_main.cc
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index d514893..fe62867 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -75,6 +75,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_1.sh ver_test_2.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_4.sh ver_test_5.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_7.sh ver_test_10.sh \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ relro_test.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_matching_test.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_4.sh \
@@ -112,6 +113,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_2.syms ver_test_4.syms \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_5.syms ver_test_7.syms \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_10.syms protected_3.err \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ relro_test.stdout \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_matching_test.stdout \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3.stdout \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_4.stdout \
@@ -3301,6 +3303,8 @@ ver_test_7.sh.log: ver_test_7.sh
@p='ver_test_7.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
ver_test_10.sh.log: ver_test_10.sh
@p='ver_test_10.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+relro_test.sh.log: relro_test.sh
+ @p='relro_test.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
ver_matching_test.sh.log: ver_matching_test.sh
@p='ver_matching_test.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
script_test_3.sh.log: script_test_3.sh
@@ -4196,6 +4200,8 @@ uninstall-am:
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared -Wl,-z,relro relro_test_pic.o
@GCC_TRUE@@NATIVE_LINKER_TRUE@relro_test_pic.o: relro_test.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $<
+@GCC_TRUE@@NATIVE_LINKER_TRUE@relro_test.stdout: relro_test.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -SlW relro_test.so > relro_test.stdout
@GCC_TRUE@@NATIVE_LINKER_TRUE@relro_strip_test.so: relro_test.so
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_STRIP) -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@relro_script_test.so: gcctestdir/ld relro_script_test.t relro_test_pic.o
@@ -4560,10 +4566,10 @@ uninstall-am:
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -lWS $< > $@
@NATIVE_OR_CROSS_LINKER_TRUE@script_test_10.o: script_test_10.s
@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_AS) -o $@ $<
-@NATIVE_OR_CROSS_LINKER_TRUE@script_test_10: $(srcdir)/script_test_10.t script_test_10.o
-@NATIVE_OR_CROSS_LINKER_TRUE@ ../ld-new -o $@ script_test_10.o -T $(srcdir)/script_test_10.t
+@NATIVE_OR_CROSS_LINKER_TRUE@script_test_10: $(srcdir)/script_test_10.t script_test_10.o gcctestdir/ld
+@NATIVE_OR_CROSS_LINKER_TRUE@ gcctestdir/ld -o $@ script_test_10.o -T $(srcdir)/script_test_10.t
@NATIVE_OR_CROSS_LINKER_TRUE@script_test_10.stdout: script_test_10
-@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_READELF) -SW script_test_10 > script_test_10.stdout
+@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_READELF) -SW script_test_10 > $@
@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@split_i386_1.o: split_i386_1.s
@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_AS) -o $@ $<
@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@split_i386_2.o: split_i386_2.s
diff --git a/gold/testsuite/relro_test.cc b/gold/testsuite/relro_test.cc
index bc6c77b..d741022 100644
--- a/gold/testsuite/relro_test.cc
+++ b/gold/testsuite/relro_test.cc
@@ -40,10 +40,10 @@ int i1 = 1;
static int i2 = 2;
// P1 is a global relro variable.
-int* const p1 = &i1;
+int* const p1 __attribute__ ((aligned(64))) = &i1;
// P2 is a local relro variable.
-int* const p2 = &i2;
+int* const p2 __attribute__ ((aligned(64))) = &i2;
// Test symbol addresses.
diff --git a/gold/testsuite/relro_test.sh b/gold/testsuite/relro_test.sh
new file mode 100755
index 0000000..2995302
--- /dev/null
+++ b/gold/testsuite/relro_test.sh
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+# relro_test.sh -- test -z relro
+
+# Copyright 2010 Free Software Foundation, Inc.
+# Written by Cary Coutant <ccoutant@google.com>.
+
+# This file is part of gold.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+# This test checks that the PT_GNU_RELRO segment is properly
+# aligned and is coincident with the beginning of the data segment.
+
+
+# Cleans a hexadecimal number for input to dc.
+clean_hex()
+{
+ echo "$1" | sed -e 's/0x//' -e 'y/abcdef/ABCDEF/'
+}
+
+check()
+{
+ # Get the address and length of the PT_GNU_RELRO segment.
+ RELRO_START=`grep GNU_RELRO "$1" | awk '{ print $3; }'`
+ RELRO_LEN=`grep GNU_RELRO "$1" | awk '{ print $6; }'`
+
+ if test -z "$RELRO_START"
+ then
+ echo "Did not find a PT_GNU_RELRO segment."
+ exit 1
+ fi
+
+ # Get the address and alignment of the PT_LOAD segment whose address
+ # matches the PT_GNU_RELRO segment.
+ LOAD_ALIGN=`grep LOAD "$1" | awk -v A=$RELRO_START '$3 == A { print $NF; }'`
+ LOAD_LEN=`grep LOAD "$1" | awk -v A=$RELRO_START '$3 == A { print $6; }'`
+
+ if test -z "$LOAD_LEN"
+ then
+ echo "Did not find a PT_LOAD segment matching the PT_GNU_RELRO segment."
+ exit 1
+ fi
+
+ # Compute the address of the end of the PT_GNU_RELRO segment,
+ # modulo the alignment of the PT_LOAD segment.
+ RELRO_START=`clean_hex "$RELRO_START"`
+ RELRO_LEN=`clean_hex "$RELRO_LEN"`
+ LOAD_ALIGN=`clean_hex "$LOAD_ALIGN"`
+ RELRO_END=`echo "16o 16i $RELRO_START $RELRO_LEN + p" | dc`
+ REM=`echo "16i $RELRO_END $LOAD_ALIGN % p" | dc`
+
+ if test "$REM" -ne 0
+ then
+ echo "PT_GNU_RELRO segment does not end at page boundary."
+ exit 1
+ fi
+}
+
+check relro_test.stdout