1 /* gdb_symbols.c - Deal with symbols for GDB format
2 Copyright (C) 1987 Free Software Foundation, Inc.
4 This file is part of GAS, the GNU Assembler.
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 1, or (at your option)
11 GAS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GAS; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
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.
25 * This has static data: it is not data_sharable.
27 * gdb_symbols_begin ()
28 * Call once before using this package.
30 * gdb_symbols_fixup (symbolP, offset_in_file)
31 * Remember to put the value of a symbol into the GDB file.
34 * Perform all the symbol fixups.
42 #include "struc-symbol.h"
44 #define SYM_GROUP (100) /* We allocate storage in lumps this big. */
47 struct gdb_symbol
/* 1 fixup request. */
50 long int gs_offset
; /* Where in GDB symbol file. */
52 typedef struct gdb_symbol gdb_symbolS
;
54 struct symbol_fixup_group
56 struct symbol_fixup_group
* sfg_next
;
57 gdb_symbolS sfg_item
[SYM_GROUP
];
59 typedef struct symbol_fixup_group symbol_fixup_groupS
;
61 static symbol_fixup_groupS
* root
;
62 static short int used
; /* # of last slot used. */
63 /* Counts down from SYM_GROUP. */
65 static symbol_fixup_groupS
* /* Make storage for some more reminders. */
68 symbol_fixup_groupS
* newP
;
71 newP
= (symbol_fixup_groupS
*) xmalloc ((long)sizeof(symbol_fixup_groupS
));
72 newP
-> sfg_next
= root
;
87 void /* Build a reminder to put a symbol value */
88 gdb_symbols_fixup (sy
, offset
) /* into the GDB symbol file. */
89 symbolS
* sy
; /* Which symbol. */
90 long int offset
; /* Where in GDB symbol file. */
92 register symbol_fixup_groupS
* p
;
93 register gdb_symbolS
* q
;
101 q
= p
-> sfg_item
+ -- used
;
103 q
-> gs_offset
= offset
;
107 gdb_symbols_emit () /* Append GDB symbols to object file. */
109 symbol_fixup_groupS
* sfgP
;
112 for (sfgP
= root
; sfgP
; sfgP
= sfgP
-> sfg_next
)
114 register gdb_symbolS
* gsP
;
115 register gdb_symbolS
* limit
;
117 limit
= sfgP
-> sfg_item
+
118 (sfgP
-> sfg_next
? 0 : used
);
119 for (gsP
= sfgP
-> sfg_item
+ SYM_GROUP
- 1;
123 gdb_alter (gsP
-> gs_offset
,
124 (long int) gsP
-> gs_symbol
-> sy_value
);
129 /* end: gdb_symbols.c */