]>
Commit | Line | Data |
---|---|---|
2d1a2445 PB |
1 | /* |
2 | Copyright (C) 1991 Free Software Foundation, Inc. | |
3 | Written by Steve Chamberlain of Cygnus Support. | |
4 | ||
5 | This file is part of GLD, the GNU linker. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
20 | ||
812df84b | 21 | #include "bfd.h" |
f177a611 | 22 | #include "sysdep.h" |
812df84b | 23 | #include "ldsym.h" |
7fe11a82 SC |
24 | #include "ldwarn.h" |
25 | #include "ldmisc.h" | |
812df84b SC |
26 | |
27 | /* we keep all the warning symbols in a list, if we ever get a | |
28 | warning, we'll search it the hard way. This won't be to bad since | |
29 | warnings are infrequent, and never that many (true or false ?). | |
30 | ||
31 | */ | |
32 | ||
33 | typedef struct warning_list_struct { | |
34 | struct warning_list_struct *next; | |
35 | asymbol *sym; | |
36 | } warning_list_type; | |
37 | ||
38 | ||
39 | static warning_list_type *warning_list; | |
40 | ||
41 | ||
42 | ||
43 | /* This is a warning symbol, add the error text to a list we keep, and mark | |
44 | the symbol referenced as requiring a warning */ | |
45 | ||
46 | ||
47 | void | |
48 | DEFUN(add_warning,(sym), | |
49 | asymbol *sym) | |
50 | { | |
51 | CONST char *name = ((asymbol *)(sym->value))->name; | |
52 | warning_list_type *new; | |
53 | ||
54 | ldsym_type *lookup = ldsym_get(name); | |
55 | ||
56 | lookup->flags |= SYM_WARNING; | |
57 | ||
58 | new = (warning_list_type *)ldmalloc(sizeof(warning_list_type)); | |
59 | new->next = warning_list; | |
60 | new->sym = sym; | |
61 | warning_list = new; | |
62 | } | |
63 | ||
64 | /* run through the list we kept, and find the warning associated with | |
65 | this symbol */ | |
66 | CONST char * | |
67 | DEFUN(fetch_warning,(sym), | |
68 | asymbol *sym) | |
69 | { | |
70 | warning_list_type *ptr = warning_list; | |
71 | while (ptr != (warning_list_type *)NULL) { | |
72 | if (strcmp(((asymbol*)(ptr->sym->value))->name, sym->name) == 0) { | |
73 | return ptr->sym->name; | |
74 | } | |
75 | ptr = ptr->next; | |
76 | } | |
77 | return "This is a warning without a message !"; | |
78 | } | |
79 | ||
80 | ||
81 | void | |
82 | DEFUN(produce_warnings,(lgs,it), | |
83 | ldsym_type *lgs AND | |
84 | asymbol *it) | |
85 | { | |
86 | asymbol **ptr; | |
87 | ptr = lgs->srefs_chain; | |
88 | while (ptr != (asymbol **)NULL) { | |
89 | asymbol *ref = *ptr; | |
086c5e37 | 90 | info("%B: %s\n", bfd_asymbol_bfd(ref), fetch_warning(it)); |
812df84b SC |
91 | ptr = (asymbol **)(ref->udata); |
92 | } | |
93 | } |