OpenCores
URL https://opencores.org/ocsvn/open8_urisc/open8_urisc/trunk

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [gold/] [testsuite/] [relro_test.sh] - Blame information for rev 97

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 khays
#!/bin/sh
2
 
3
# relro_test.sh -- test -z relro
4
 
5
# Copyright 2010, 2011 Free Software Foundation, Inc.
6
# Written by Cary Coutant <ccoutant@google.com>.
7
 
8
# This file is part of gold.
9
 
10
# This program is free software; you can redistribute it and/or modify
11
# it under the terms of the GNU General Public License as published by
12
# the Free Software Foundation; either version 3 of the License, or
13
# (at your option) any later version.
14
 
15
# This program is distributed in the hope that it will be useful,
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
# GNU General Public License for more details.
19
 
20
# You should have received a copy of the GNU General Public License
21
# along with this program; if not, write to the Free Software
22
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
23
# MA 02110-1301, USA.
24
 
25
# This test checks that the PT_GNU_RELRO segment is properly
26
# aligned and is coincident with the beginning of the data segment.
27
 
28
 
29
# Cleans a hexadecimal number for input to dc.
30
clean_hex()
31
{
32
  echo "$1" | sed -e 's/0x//' -e 'y/abcdef/ABCDEF/'
33
}
34
 
35
check()
36
{
37
  # Get the address and length of the PT_GNU_RELRO segment.
38
  RELRO_START=`grep GNU_RELRO "$1" | awk '{ print $3; }'`
39
  RELRO_LEN=`grep GNU_RELRO "$1" | awk '{ print $6; }'`
40
 
41
  if test -z "$RELRO_START"
42
  then
43
    echo "Did not find a PT_GNU_RELRO segment."
44
    exit 1
45
  fi
46
 
47
  # Get the address and alignment of the PT_LOAD segment whose address
48
  # matches the PT_GNU_RELRO segment.
49
  LOAD_ALIGN=`grep LOAD "$1" | awk -v A=$RELRO_START '$3 == A { print $NF; }'`
50
  LOAD_LEN=`grep LOAD "$1" | awk -v A=$RELRO_START '$3 == A { print $6; }'`
51
 
52
  if test -z "$LOAD_LEN"
53
  then
54
    echo "Did not find a PT_LOAD segment matching the PT_GNU_RELRO segment."
55
    exit 1
56
  fi
57
 
58
  # Compute the address of the end of the PT_GNU_RELRO segment,
59
  # modulo the alignment of the PT_LOAD segment.
60
  RELRO_START=`clean_hex "$RELRO_START"`
61
  RELRO_LEN=`clean_hex "$RELRO_LEN"`
62
  LOAD_ALIGN=`clean_hex "$LOAD_ALIGN"`
63
  RELRO_END=`echo "16o 16i $RELRO_START $RELRO_LEN + p" | dc`
64
  REM=`echo "16i $RELRO_END $LOAD_ALIGN % p" | dc`
65
 
66
  if test "$REM" -eq 0; then
67
    :
68
  else
69
    echo "PT_GNU_RELRO segment does not end at page boundary."
70
    exit 1
71
  fi
72
}
73
 
74
check relro_test.stdout

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.