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