3 # script_test_14.sh -- test SORT_BY_INIT_PRIORITY
5 # Copyright (C) 2016 Free Software Foundation, Inc.
6 # Written by Igor Kudrin <ikudrin@accesssoftek.com>.
8 # This file is part of gold.
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.
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.
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,
25 file="script_test_14.stdout"
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"
35 echo "Actual output below:"
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\":"
44 echo "Actual output below:"
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"
57 # Sort order for .fini_array, the same consideration as for .init_array:
62 check ".fini_array" "\<f0f1f3f4\b"
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"
71 # Sort order for .dtors, the same considerations as for .ctors:
76 check ".dtors" "\<d0d3d4d1\b"
78 # Sort order for .sec, just sort as strings, because it's not the reserved name:
83 check ".sec" "\<a0a3a1a4\b"