*** empty log message ***
[deliverable/binutils-gdb.git] / gas / obsolete / gdb-symbols.c
CommitLineData
0e39a8bb
RP
1/* gdb_symbols.c - Deal with symbols for GDB format
2 Copyright (C) 1987 Free Software Foundation, Inc.
3
4This file is part of GAS, the GNU Assembler.
5
6GAS is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 1, or (at your option)
9any later version.
10
11GAS is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GAS; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20/*
21 * During assembly, note requests to place symbol values in the GDB
22 * symbol file. When symbol values are known and the symbol file is
23 * in memory, place the symbol values in the memory image of the file.
24 *
25 * This has static data: it is not data_sharable.
26 *
27 * gdb_symbols_begin ()
28 * Call once before using this package.
29 *
30 * gdb_symbols_fixup (symbolP, offset_in_file)
31 * Remember to put the value of a symbol into the GDB file.
32 *
33 * gdb_symbols_emit ()
34 * Perform all the symbol fixups.
35 *
36 * uses:
37 * xmalloc()
38 * gdb_alter()
39 */
40
41#include "as.h"
42#include "struc-symbol.h"
43
44#define SYM_GROUP (100) /* We allocate storage in lumps this big. */
45
46
47struct gdb_symbol /* 1 fixup request. */
48{
49 symbolS * gs_symbol;
50 long int gs_offset; /* Where in GDB symbol file. */
51};
52typedef struct gdb_symbol gdb_symbolS;
53
54struct symbol_fixup_group
55{
56 struct symbol_fixup_group * sfg_next;
57 gdb_symbolS sfg_item [SYM_GROUP];
58};
59typedef struct symbol_fixup_group symbol_fixup_groupS;
60
61static symbol_fixup_groupS * root;
62static short int used; /* # of last slot used. */
63 /* Counts down from SYM_GROUP. */
64\f
65static symbol_fixup_groupS * /* Make storage for some more reminders. */
66new_sfg ()
67{
68 symbol_fixup_groupS * newP;
69 char * xmalloc();
70
71 newP = (symbol_fixup_groupS *) xmalloc ((long)sizeof(symbol_fixup_groupS));
72 newP -> sfg_next = root;
73 used = SYM_GROUP;
74 root = newP;
75 return (newP);
76}
77
78
79void
80gdb_symbols_begin ()
81{
82 root = 0;
83 (void)new_sfg ();
84}
85
86
87void /* Build a reminder to put a symbol value */
88gdb_symbols_fixup (sy, offset) /* into the GDB symbol file. */
89 symbolS * sy; /* Which symbol. */
90 long int offset; /* Where in GDB symbol file. */
91{
92 register symbol_fixup_groupS * p;
93 register gdb_symbolS * q;
94
95 p = root;
96 know( used >= 0 );
97 if ( used == 0)
98 {
99 p = new_sfg ();
100 }
101 q = p -> sfg_item + -- used;
102 q -> gs_symbol = sy;
103 q -> gs_offset = offset;
104}
105\f
106void
107gdb_symbols_emit () /* Append GDB symbols to object file. */
108{
109 symbol_fixup_groupS * sfgP;
110 void gdb_alter();
111
112 for (sfgP = root; sfgP; sfgP = sfgP -> sfg_next)
113 {
114 register gdb_symbolS * gsP;
115 register gdb_symbolS * limit;
116
117 limit = sfgP -> sfg_item +
118 (sfgP -> sfg_next ? 0 : used);
119 for (gsP = sfgP -> sfg_item + SYM_GROUP - 1;
120 gsP >= limit;
121 gsP --)
122 {
123 gdb_alter (gsP -> gs_offset,
124 (long int) gsP -> gs_symbol -> sy_value);
125 }
126 }
127}
128
129/* end: gdb_symbols.c */
This page took 0.02911 seconds and 4 git commands to generate.