Include bfd.h before sysdep.h, so ansidecl and PROTO() get defined first.
[deliverable/binutils-gdb.git] / ld / ldwarn.c
1 #include "bfd.h"
2 #include "sysdep.h"
3 #include "ldsym.h"
4 #include "ldwarn.h"
5 #include "ldmisc.h"
6
7 /* we keep all the warning symbols in a list, if we ever get a
8 warning, we'll search it the hard way. This won't be to bad since
9 warnings are infrequent, and never that many (true or false ?).
10
11 */
12
13 typedef struct warning_list_struct {
14 struct warning_list_struct *next;
15 asymbol *sym;
16 } warning_list_type;
17
18
19 static warning_list_type *warning_list;
20
21
22
23 /* This is a warning symbol, add the error text to a list we keep, and mark
24 the symbol referenced as requiring a warning */
25
26
27 void
28 DEFUN(add_warning,(sym),
29 asymbol *sym)
30 {
31 CONST char *name = ((asymbol *)(sym->value))->name;
32 warning_list_type *new;
33
34 ldsym_type *lookup = ldsym_get(name);
35
36 lookup->flags |= SYM_WARNING;
37
38 new = (warning_list_type *)ldmalloc(sizeof(warning_list_type));
39 new->next = warning_list;
40 new->sym = sym;
41 warning_list = new;
42 }
43
44 /* run through the list we kept, and find the warning associated with
45 this symbol */
46 CONST char *
47 DEFUN(fetch_warning,(sym),
48 asymbol *sym)
49 {
50 warning_list_type *ptr = warning_list;
51 while (ptr != (warning_list_type *)NULL) {
52 if (strcmp(((asymbol*)(ptr->sym->value))->name, sym->name) == 0) {
53 return ptr->sym->name;
54 }
55 ptr = ptr->next;
56 }
57 return "This is a warning without a message !";
58 }
59
60
61 void
62 DEFUN(produce_warnings,(lgs,it),
63 ldsym_type *lgs AND
64 asymbol *it)
65 {
66 asymbol **ptr;
67 ptr = lgs->srefs_chain;
68 while (ptr != (asymbol **)NULL) {
69 asymbol *ref = *ptr;
70 info("%B: %s\n", ref->the_bfd, fetch_warning(it));
71 ptr = (asymbol **)(ref->udata);
72 }
73 }
This page took 0.031079 seconds and 5 git commands to generate.