This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: gold patch committed: Make relro_test fail if dc is not present
- From: Cary Coutant <ccoutant at google dot com>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: binutils at sourceware dot org
- Date: Tue, 22 Mar 2011 16:19:26 -0700
- Subject: Re: gold patch committed: Make relro_test fail if dc is not present
- References: <mcrpqpkuhu9.fsf@google.com>
> This patch at least makes gold's relro_test fail if dc is not present on
> the system. ?Committed to mainline.
Here's a patch to remove the dependency on dc altogether. According to
http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html
the Posix shell supports $((...)) expressions and hex constants.
OK?
-cary
* testsuite/relro_test.sh: Use shell expressions instead of dc.
Index: testsuite/relro_test.sh
===================================================================
RCS file: /cvs/src/src/gold/testsuite/relro_test.sh,v
retrieving revision 1.2
diff -u -p -r1.2 relro_test.sh
--- testsuite/relro_test.sh 22 Mar 2011 00:19:14 -0000 1.2
+++ testsuite/relro_test.sh 22 Mar 2011 23:18:14 -0000
@@ -25,13 +25,6 @@
# 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.
@@ -57,15 +50,10 @@ check()
# 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" -eq 0; then
- :
- else
+ RELRO_END=$((RELRO_START + RELRO_LEN))
+ REM=$((RELRO_END % LOAD_ALIGN))
+
+ if test "$REM" -ne 0; then
echo "PT_GNU_RELRO segment does not end at page boundary."
exit 1
fi