Accept and ignore the R_BPF_64_NODLYD32 relocation.
[binutils-gdb.git] / gdb / buildsym-legacy.c
blob131d24fe9b541d43f0fed3011b990b16ab1f707d
1 /* Legacy support routines for building symbol tables in GDB's internal format.
2 Copyright (C) 1986-2023 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program 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 3 of the License, or
9 (at your option) any later version.
11 This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
19 #include "defs.h"
20 #include "buildsym-legacy.h"
21 #include "symtab.h"
23 /* The work-in-progress of the compunit we are building.
24 This is created first, before any subfiles by start_compunit_symtab. */
26 static struct buildsym_compunit *buildsym_compunit;
28 void
29 record_debugformat (const char *format)
31 buildsym_compunit->record_debugformat (format);
34 void
35 record_producer (const char *producer)
37 buildsym_compunit->record_producer (producer);
42 /* See buildsym.h. */
44 void
45 set_last_source_file (const char *name)
47 gdb_assert (buildsym_compunit != nullptr || name == nullptr);
48 if (buildsym_compunit != nullptr)
49 buildsym_compunit->set_last_source_file (name);
52 /* See buildsym.h. */
54 const char *
55 get_last_source_file ()
57 if (buildsym_compunit == nullptr)
58 return nullptr;
59 return buildsym_compunit->get_last_source_file ();
62 /* See buildsym.h. */
64 void
65 set_last_source_start_addr (CORE_ADDR addr)
67 gdb_assert (buildsym_compunit != nullptr);
68 buildsym_compunit->set_last_source_start_addr (addr);
71 /* See buildsym.h. */
73 CORE_ADDR
74 get_last_source_start_addr ()
76 gdb_assert (buildsym_compunit != nullptr);
77 return buildsym_compunit->get_last_source_start_addr ();
80 /* See buildsym.h. */
82 bool
83 outermost_context_p ()
85 gdb_assert (buildsym_compunit != nullptr);
86 return buildsym_compunit->outermost_context_p ();
89 /* See buildsym.h. */
91 int
92 get_context_stack_depth ()
94 gdb_assert (buildsym_compunit != nullptr);
95 return buildsym_compunit->get_context_stack_depth ();
98 /* See buildsym.h. */
100 struct subfile *
101 get_current_subfile ()
103 gdb_assert (buildsym_compunit != nullptr);
104 return buildsym_compunit->get_current_subfile ();
107 /* See buildsym.h. */
109 struct pending **
110 get_local_symbols ()
112 gdb_assert (buildsym_compunit != nullptr);
113 return buildsym_compunit->get_local_symbols ();
116 /* See buildsym.h. */
118 struct pending **
119 get_file_symbols ()
121 gdb_assert (buildsym_compunit != nullptr);
122 return buildsym_compunit->get_file_symbols ();
125 /* See buildsym.h. */
127 struct pending **
128 get_global_symbols ()
130 gdb_assert (buildsym_compunit != nullptr);
131 return buildsym_compunit->get_global_symbols ();
134 void
135 start_subfile (const char *name)
137 gdb_assert (buildsym_compunit != nullptr);
138 buildsym_compunit->start_subfile (name);
141 void
142 patch_subfile_names (struct subfile *subfile, const char *name)
144 gdb_assert (buildsym_compunit != nullptr);
145 buildsym_compunit->patch_subfile_names (subfile, name);
148 void
149 push_subfile ()
151 gdb_assert (buildsym_compunit != nullptr);
152 buildsym_compunit->push_subfile ();
155 const char *
156 pop_subfile ()
158 gdb_assert (buildsym_compunit != nullptr);
159 return buildsym_compunit->pop_subfile ();
162 /* Delete the buildsym compunit. */
164 static void
165 free_buildsym_compunit (void)
167 if (buildsym_compunit == NULL)
168 return;
169 delete buildsym_compunit;
170 buildsym_compunit = NULL;
173 struct compunit_symtab *
174 end_compunit_symtab (CORE_ADDR end_addr)
176 gdb_assert (buildsym_compunit != nullptr);
177 struct compunit_symtab *result
178 = buildsym_compunit->end_compunit_symtab (end_addr);
179 free_buildsym_compunit ();
180 return result;
183 struct context_stack *
184 push_context (int desc, CORE_ADDR valu)
186 gdb_assert (buildsym_compunit != nullptr);
187 return buildsym_compunit->push_context (desc, valu);
190 struct context_stack
191 pop_context ()
193 gdb_assert (buildsym_compunit != nullptr);
194 return buildsym_compunit->pop_context ();
197 struct block *
198 finish_block (struct symbol *symbol, struct pending_block *old_blocks,
199 const struct dynamic_prop *static_link,
200 CORE_ADDR start, CORE_ADDR end)
202 gdb_assert (buildsym_compunit != nullptr);
203 return buildsym_compunit->finish_block (symbol, old_blocks, static_link,
204 start, end);
207 void
208 record_line (struct subfile *subfile, int line, unrelocated_addr pc)
210 gdb_assert (buildsym_compunit != nullptr);
211 /* Assume every line entry is a statement start, that is a good place to
212 put a breakpoint for that line number. */
213 buildsym_compunit->record_line (subfile, line, pc, LEF_IS_STMT);
216 /* Start a new compunit_symtab for a new source file in OBJFILE. Called, for
217 example, when a stabs symbol of type N_SO is seen, or when a DWARF
218 DW_TAG_compile_unit DIE is seen. It indicates the start of data for one
219 original source file.
221 NAME is the name of the file (cannot be NULL). COMP_DIR is the
222 directory in which the file was compiled (or NULL if not known).
223 START_ADDR is the lowest address of objects in the file (or 0 if
224 not known). LANGUAGE is the language of the source file, or
225 language_unknown if not known, in which case it'll be deduced from
226 the filename. */
228 struct compunit_symtab *
229 start_compunit_symtab (struct objfile *objfile, const char *name,
230 const char *comp_dir, CORE_ADDR start_addr,
231 enum language language)
233 /* These should have been reset either by successful completion of building
234 a symtab, or by the scoped_free_pendings destructor. */
235 gdb_assert (buildsym_compunit == nullptr);
237 buildsym_compunit = new struct buildsym_compunit (objfile, name, comp_dir,
238 language, start_addr);
240 return buildsym_compunit->get_compunit_symtab ();
243 /* At end of reading syms, or in case of quit, ensure everything
244 associated with building symtabs is freed.
246 N.B. This is *not* intended to be used when building psymtabs. Some debug
247 info readers call this anyway, which is harmless if confusing. */
249 scoped_free_pendings::~scoped_free_pendings ()
251 free_buildsym_compunit ();
254 /* See buildsym-legacy.h. */
256 struct buildsym_compunit *
257 get_buildsym_compunit ()
259 gdb_assert (buildsym_compunit != nullptr);
260 return buildsym_compunit;