Home | History | Annotate | Download | only in testsuite
      1 #!/bin/sh
      2 
      3 # script_test_14.sh -- test SORT_BY_INIT_PRIORITY
      4 
      5 # Copyright (C) 2016 Free Software Foundation, Inc.
      6 # Written by Igor Kudrin <ikudrin (at] accesssoftek.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 file="script_test_14.stdout"
     26 
     27 check()
     28 {
     29     section=$1
     30     pattern=$2
     31     found=`fgrep "Contents of section $section:" -A1 $file | tail -n 1`
     32     if test -z "$found"; then
     33         echo "Section \"$section\" not found in file $file"
     34         echo ""
     35         echo "Actual output below:"
     36         cat "$file"
     37         exit 1
     38     fi
     39     match_pattern=`echo "$found" | grep -e "$pattern"`
     40     if test -z "$match_pattern"; then
     41         echo "Expected pattern was not found in section \"$section\":"
     42         echo "    $pattern"
     43         echo ""
     44         echo "Actual output below:"
     45         cat "$file"
     46         exit 1
     47     fi
     48 }
     49 
     50 # Sort order for .init_array:
     51 # * .init_array      -- Doesn't have a numeric part, compared with others as strings.
     52 # * .init_array.101  -- The numeric part is less than in the two others.
     53 # * .init_array.0103 -- These names have numeric parts with the same value,
     54 # * .init_array.103  /  so they are compared as strings.
     55 check ".init_array" "\<00010304\b"
     56 
     57 # Sort order for .fini_array, the same consideration as for .init_array:
     58 # * .fini_array
     59 # * .fini_array.101
     60 # * .fini_array.0103
     61 # * .fini_array.103
     62 check ".fini_array" "\<f0f1f3f4\b"
     63 
     64 # Sort order for .ctors:
     65 # * .ctors      -- Doesn't have a numeric part, compared with others as strings
     66 # * .ctors.0103 -- The numeric parts have the same value, which is greater than
     67 # * .ctors.103  /  in the last section's name. This pair is compared as strings.
     68 # * .ctors.101  -- The least numeric part among all sections which contain them.
     69 check ".ctors" "\<c0c3c4c1\b"
     70 
     71 # Sort order for .dtors, the same considerations as for .ctors:
     72 # * .dtors
     73 # * .dtors.0103
     74 # * .dtors.103
     75 # * .dtors.101
     76 check ".dtors" "\<d0d3d4d1\b"
     77 
     78 # Sort order for .sec, just sort as strings, because it's not the reserved name:
     79 # * .sec
     80 # * .sec.0103
     81 # * .sec.101
     82 # * .sec.103
     83 check ".sec" "\<a0a3a1a4\b"
     84 
     85