/* 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.
/* 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) \
+ bfd_section_size ((s)->the_bfd_section) \
+ obj_section_offset (s))
+#define ALL_OBJFILE_OSECTIONS(objfile, osect) \
+ for (osect = objfile->sections; osect < objfile->sections_end; osect++) \
+ if (osect->the_bfd_section == NULL) \
+ { \
+ /* Nothing. */ \
+ } \
+ else
+
+#define SECT_OFF_DATA(objfile) \
+ ((objfile->sect_index_data == -1) \
+ ? (internal_error (__FILE__, __LINE__, \
+ _("sect_index_data not initialized")), -1) \
+ : objfile->sect_index_data)
+
+#define SECT_OFF_RODATA(objfile) \
+ ((objfile->sect_index_rodata == -1) \
+ ? (internal_error (__FILE__, __LINE__, \
+ _("sect_index_rodata not initialized")), -1) \
+ : objfile->sect_index_rodata)
+
+#define SECT_OFF_TEXT(objfile) \
+ ((objfile->sect_index_text == -1) \
+ ? (internal_error (__FILE__, __LINE__, \
+ _("sect_index_text not initialized")), -1) \
+ : objfile->sect_index_text)
+
+/* Sometimes the .bss section is missing from the objfile, so we don't
+ want to die here. Let the users of SECT_OFF_BSS deal with an
+ uninitialized section index. */
+#define SECT_OFF_BSS(objfile) (objfile)->sect_index_bss
+
/* The "objstats" structure provides a place for gdb to record some
interesting information about its internal state at runtime, on a
per objfile basis, such as information about the number of symbols
return separate_debug_range (this);
}
+ CORE_ADDR text_section_offset () const
+ {
+ return section_offsets[SECT_OFF_TEXT (this)];
+ }
+
+ CORE_ADDR data_section_offset () const
+ {
+ return section_offsets[SECT_OFF_DATA (this)];
+ }
/* The object file's original name as specified by the user,
made absolute, and tilde-expanded. However, it is not canonicalized
/* 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);
(struct gdbarch *gdbarch,
iterate_over_objfiles_in_search_order_cb_ftype *cb,
void *cb_data, struct objfile *current_objfile);
-\f
-
-#define ALL_OBJFILE_OSECTIONS(objfile, osect) \
- for (osect = objfile->sections; osect < objfile->sections_end; osect++) \
- if (osect->the_bfd_section == NULL) \
- { \
- /* Nothing. */ \
- } \
- else
-
-#define SECT_OFF_DATA(objfile) \
- ((objfile->sect_index_data == -1) \
- ? (internal_error (__FILE__, __LINE__, \
- _("sect_index_data not initialized")), -1) \
- : objfile->sect_index_data)
-
-#define SECT_OFF_RODATA(objfile) \
- ((objfile->sect_index_rodata == -1) \
- ? (internal_error (__FILE__, __LINE__, \
- _("sect_index_rodata not initialized")), -1) \
- : objfile->sect_index_rodata)
-
-#define SECT_OFF_TEXT(objfile) \
- ((objfile->sect_index_text == -1) \
- ? (internal_error (__FILE__, __LINE__, \
- _("sect_index_text not initialized")), -1) \
- : objfile->sect_index_text)
-
-/* Sometimes the .bss section is missing from the objfile, so we don't
- want to die here. Let the users of SECT_OFF_BSS deal with an
- uninitialized section index. */
-#define SECT_OFF_BSS(objfile) (objfile)->sect_index_bss
/* Reset the per-BFD storage area on OBJ. */