/* Definitions for symbol file management in GDB.
- Copyright (C) 1992-2019 Free Software Foundation, Inc.
+ Copyright (C) 1992-2020 Free Software Foundation, Inc.
This file is part of GDB.
#include "registry.h"
#include "gdb_bfd.h"
#include "psymtab.h"
+#include <atomic>
#include <bitset>
#include <vector>
#include "gdbsupport/next-iterator.h"
#include "gdbsupport/safe-iterator.h"
#include "bcache.h"
#include "gdbarch.h"
+#include "gdbsupport/refcounted-object.h"
struct htab;
struct objfile_data;
/* Relocation offset applied to S. */
#define obj_section_offset(s) \
- (((s)->objfile->section_offsets)->offsets[gdb_bfd_section_index ((s)->objfile->obfd, (s)->the_bfd_section)])
+ (((s)->objfile->section_offsets)[gdb_bfd_section_index ((s)->objfile->obfd, (s)->the_bfd_section)])
/* The memory address of section S (vma + offset). */
#define obj_section_addr(s) \
/* The only way to create an objfile is to call objfile::make. */
objfile (bfd *, const char *, objfile_flags);
- /* The only way to free an objfile is via 'unlink'. */
- ~objfile ();
-
public:
+ /* Normally you should not call delete. Instead, call 'unlink' to
+ remove it from the program space's list. In some cases, you may
+ need to hold a reference to an objfile that is independent of its
+ existence on the program space's list; for this case, the
+ destructor must be public so that shared_ptr can reference
+ it. */
+ ~objfile ();
+
/* Create an objfile. */
static objfile *make (bfd *bfd_, const char *name_, objfile_flags flags_,
objfile *parent = nullptr);
/* The partial symbol tables. */
- std::shared_ptr<psymtab_storage> partial_symtabs;
+ std::unique_ptr<psymtab_storage> partial_symtabs;
/* The object file's BFD. Can be null if the objfile contains only
minimal symbols, e.g. the run time common symbols for SunOS4. */
/* Set of relocation offsets to apply to each section.
The table is indexed by the_bfd_section->index, thus it is generally
as large as the number of sections in the binary.
- The table is stored on the objfile_obstack.
These offsets indicate that all symbols (including partial and
minimal symbols) which have been read have been relocated by this
much. Symbols which are yet to be read need to be relocated by it. */
- struct section_offsets *section_offsets = nullptr;
- int num_sections = 0;
+ ::section_offsets section_offsets;
/* Indexes in the section_offsets array. These are initialized by the
*_symfile_offsets() family of functions (som_symfile_offsets,
extern void free_objfile_separate_debug (struct objfile *);
-extern void objfile_relocate (struct objfile *, const struct section_offsets *);
+extern void objfile_relocate (struct objfile *, const section_offsets &);
extern void objfile_rebase (struct objfile *, CORE_ADDR);
extern int objfile_has_partial_symbols (struct objfile *objfile);