MIPS: Add relocation types
[glibc.git] / scripts / check-initfini.awk
blob3005b105ff23de04507d2a05114ab5b46cf95bb1
1 # Copyright (C) 2018-2023 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
4 # The GNU C Library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # The GNU C Library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with the GNU C Library; if not, see
16 # <https://www.gnu.org/licenses/>.
18 # This awk script expects to get command-line files that are each
19 # the output of 'readelf -W --dyn-syms' on a single shared object.
20 # It exits successfully (0) if none contained _init nor _fini in dynamic
21 # symbol table.
22 # It fails (1) if any did contain _init or _fini in dynamic symbol table.
23 # It fails (2) if the input did not take the expected form.
25 BEGIN { result = _init = _fini = sanity = 0 }
27 function check_one(name) {
28 if (!sanity) {
29 print name ": *** input did not look like readelf -d output";
30 result = 2;
31 } else {
32 ok = 1;
33 if (_init) {
34 print name ": *** _init is in dynamic symbol table";
35 result = result ? result : 1;
36 ok = 0;
38 if (_fini) {
39 print name ": *** _fini is in dynamic symbol table";
40 result = result ? result : 1;
41 ok = 0;
43 if (ok)
44 print name ": OK";
47 _init = _fini = sanity = 0
50 FILENAME != lastfile {
51 if (lastfile)
52 check_one(lastfile);
53 lastfile = FILENAME;
56 $1 == "Symbol" && $2 == "table" && $3 == "'.dynsym'" { sanity = 1 }
57 $8 == "_init" { _init = 1 }
58 $8 == "_fini" { _fini = 1 }
60 END {
61 check_one(lastfile);
62 exit(result);