* Makefile.in: Change mkscript rule into one for ./mkscript
[deliverable/binutils-gdb.git] / ld / ldwarn.c
CommitLineData
2d1a2445
PB
1/*
2 Copyright (C) 1991 Free Software Foundation, Inc.
3 Written by Steve Chamberlain of Cygnus Support.
4
5This file is part of GLD, the GNU linker.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
19Foundation, 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
33typedef struct warning_list_struct {
34 struct warning_list_struct *next;
35 asymbol *sym;
36} warning_list_type;
37
38
39static 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
47void
48DEFUN(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 */
66CONST char *
67DEFUN(fetch_warning,(sym),
68asymbol *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
81void
82DEFUN(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;
90 info("%B: %s\n", ref->the_bfd, fetch_warning(it));
91 ptr = (asymbol **)(ref->udata);
92 }
93}
This page took 0.040517 seconds and 4 git commands to generate.