sec = find_pc_section (memaddr);
if (sec != NULL)
{
- arm_per_bfd *data = arm_bfd_data_key.get (sec->objfile->obfd);
+ arm_per_bfd *data = arm_bfd_data_key.get (sec->objfile->obfd.get ());
if (data != NULL)
{
unsigned int section_idx = sec->the_bfd_section->index;
LONGEST i;
/* If we've already touched this file, do nothing. */
- if (!objfile || arm_exidx_data_key.get (objfile->obfd) != NULL)
+ if (!objfile || arm_exidx_data_key.get (objfile->obfd.get ()) != NULL)
return;
/* Read contents of exception table and index. */
- exidx = bfd_get_section_by_name (objfile->obfd, ELF_STRING_ARM_unwind);
+ exidx = bfd_get_section_by_name (objfile->obfd.get (),
+ ELF_STRING_ARM_unwind);
gdb::byte_vector exidx_data;
if (exidx)
{
exidx_vma = bfd_section_vma (exidx);
exidx_data.resize (bfd_section_size (exidx));
- if (!bfd_get_section_contents (objfile->obfd, exidx,
+ if (!bfd_get_section_contents (objfile->obfd.get (), exidx,
exidx_data.data (), 0,
exidx_data.size ()))
return;
}
- extab = bfd_get_section_by_name (objfile->obfd, ".ARM.extab");
+ extab = bfd_get_section_by_name (objfile->obfd.get (), ".ARM.extab");
gdb::byte_vector extab_data;
if (extab)
{
extab_vma = bfd_section_vma (extab);
extab_data.resize (bfd_section_size (extab));
- if (!bfd_get_section_contents (objfile->obfd, extab,
+ if (!bfd_get_section_contents (objfile->obfd.get (), extab,
extab_data.data (), 0,
extab_data.size ()))
return;
}
/* Allocate exception table data structure. */
- data = arm_exidx_data_key.emplace (objfile->obfd);
+ data = arm_exidx_data_key.emplace (objfile->obfd.get ());
data->section_maps.resize (objfile->obfd->section_count);
/* Fill in exception table. */
struct arm_exidx_data *data;
struct arm_exidx_entry map_key = { memaddr - sec->addr (), 0 };
- data = arm_exidx_data_key.get (sec->objfile->obfd);
+ data = arm_exidx_data_key.get (sec->objfile->obfd.get ());
if (data != NULL)
{
std::vector<arm_exidx_entry> &map
if (name[1] != 'a' && name[1] != 't' && name[1] != 'd')
return;
- data = arm_bfd_data_key.get (objfile->obfd);
+ data = arm_bfd_data_key.get (objfile->obfd.get ());
if (data == NULL)
- data = arm_bfd_data_key.emplace (objfile->obfd,
+ data = arm_bfd_data_key.emplace (objfile->obfd.get (),
objfile->obfd->section_count);
arm_mapping_symbol_vec &map
= data->section_maps[bfd_asymbol_section (sym)->index];
{
unsigned long crc32;
gdb::unique_xmalloc_ptr<char> debuglink
- (bfd_get_debug_link_info (parent->obfd, &crc32));
+ (bfd_get_debug_link_info (parent->obfd.get (), &crc32));
if (debuglink.get () != nullptr
&& strcmp (debuglink.get (), lbasename (realname.get ())) != 0)
static void
auto_load_section_scripts (struct objfile *objfile, const char *section_name)
{
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
asection *scripts_sect;
bfd_byte *data = NULL;
{
const struct bfd_build_id *build_id;
- build_id = build_id_bfd_get (objfile->obfd);
+ build_id = build_id_bfd_get (objfile->obfd.get ());
if (build_id != NULL)
{
if (separate_debug_file_debug)
read_pe_exported_syms (minimal_symbol_reader &reader,
struct objfile *objfile)
{
- bfd *dll = objfile->obfd;
+ bfd *dll = objfile->obfd.get ();
unsigned long nbnormal, nbforward;
unsigned long pe_header_offset, opthdr_ofs, num_entries, i;
unsigned long export_opthdrrva, export_opthdrsize;
int is_pe64 = 0;
int is_pe32 = 0;
- char const *target = bfd_get_target (objfile->obfd);
+ char const *target = bfd_get_target (objfile->obfd.get ());
std::vector<struct read_pe_section_data> section_data
(PE_SECTION_TABLE_SIZE);
args.targ_index = cs->c_secnum;
args.resultp = §
- bfd_map_over_sections (objfile->obfd, find_targ_sec, &args);
+ bfd_map_over_sections (objfile->obfd.get (), find_targ_sec, &args);
return sect;
}
if (sect == NULL)
return SECT_OFF_TEXT (objfile);
- return gdb_bfd_section_index (objfile->obfd, sect);
+ return gdb_bfd_section_index (objfile->obfd.get (), sect);
}
/* Return the address of the section of a COFF symbol. */
name1 = name + 6;
if (name1 != NULL)
{
- int lead = bfd_get_symbol_leading_char (objfile->obfd);
+ int lead
+ = bfd_get_symbol_leading_char (objfile->obfd.get ());
struct bound_minimal_symbol found;
if (lead != '\0' && *name1 == lead)
coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
{
struct coff_symfile_info *info;
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
coff_data_type *cdata = coff_data (abfd);
const char *filename = bfd_get_filename (abfd);
int val;
FIXME: We should use BFD to read the symbol table, and thus avoid
this problem. */
pe_file =
- startswith (bfd_get_target (objfile->obfd), "pe")
- || startswith (bfd_get_target (objfile->obfd), "epoc-pe");
+ startswith (bfd_get_target (objfile->obfd.get ()), "pe")
+ || startswith (bfd_get_target (objfile->obfd.get ()), "epoc-pe");
/* End of warning. */
{
gdb_bfd_ref_ptr debug_bfd (symfile_bfd_open (debugfile.c_str ()));
- symbol_file_add_separate (debug_bfd.get (), debugfile.c_str (),
+ symbol_file_add_separate (debug_bfd, debugfile.c_str (),
symfile_flags, objfile);
}
}
FIXME: Find out if this has been reported to Sun, whether it has
been fixed in a later release, etc. */
- bfd_seek (objfile->obfd, 0, 0);
+ bfd_seek (objfile->obfd.get (), 0, 0);
/* Position to read the symbol table. */
- val = bfd_seek (objfile->obfd, symtab_offset, 0);
+ val = bfd_seek (objfile->obfd.get (), symtab_offset, 0);
if (val < 0)
perror_with_name (objfile_name (objfile));
coffread_objfile = objfile;
- nlist_bfd_global = objfile->obfd;
+ nlist_bfd_global = objfile->obfd.get ();
nlist_nsyms_global = nsyms;
set_last_source_file (NULL);
memset (opaque_type_chain, 0, sizeof opaque_type_chain);
char *name;
name = cs->c_name;
- name = EXTERNAL_NAME (name, objfile->obfd);
+ name = EXTERNAL_NAME (name, objfile->obfd.get ());
sym->set_language (get_current_subfile ()->language,
&objfile->objfile_obstack);
sym->compute_and_set_names (name, true, objfile->per_bfd);
{
read_one_sym (ms, &sub_sym, &sub_aux);
name = ms->c_name;
- name = EXTERNAL_NAME (name, objfile->obfd);
+ name = EXTERNAL_NAME (name, objfile->obfd.get ());
switch (ms->c_sclass)
{
{
read_one_sym (ms, &sub_sym, &sub_aux);
name = ms->c_name;
- name = EXTERNAL_NAME (name, objfile->obfd);
+ name = EXTERNAL_NAME (name, objfile->obfd.get ());
switch (ms->c_sclass)
{
/* SYMFILE_VERBOSE is not passed even if FROM_TTY, user is not interested in
"Reading symbols from ..." message for automatically generated file. */
- objfile_up objfile_holder (symbol_file_add_from_bfd (abfd.get (),
+ objfile_up objfile_holder (symbol_file_add_from_bfd (abfd,
filename.get (),
0, NULL, 0, NULL));
objfile = objfile_holder.get ();
static CORE_ADDR
get_objfile_text_range (struct objfile *of, int *tsize)
{
- bfd *abfd = of->obfd;
+ bfd *abfd = of->obfd.get ();
const asection *codes;
codes = bfd_get_section_by_name (abfd, ".text");
if (strcmp (fname, ".ctf") == 0)
{
- fname = bfd_get_filename (of->obfd);
+ fname = bfd_get_filename (of->obfd.get ());
isparent = true;
}
elfctf_build_psymtabs (struct objfile *of)
{
struct ctf_per_tu_data pcu;
- bfd *abfd = of->obfd;
+ bfd *abfd = of->obfd.get ();
int err;
ctf_archive_t *arc = ctf_bfdopen (abfd, &err);
{
const char *tempstring = name;
- if (tempstring[0] == bfd_get_symbol_leading_char (objfile->obfd))
+ if (tempstring[0] == bfd_get_symbol_leading_char (objfile->obfd.get ()))
++tempstring;
if (is_vtable_name (tempstring))
ms_type = mst_data;
bfd *sym_bfd;
int val;
- sym_bfd = objfile->obfd;
+ sym_bfd = objfile->obfd.get ();
/* .o and .nlm files are relocatables with text, data and bss segs based at
0. This flag disables special (Solaris stabs-in-elf only) fixups for
dbx_symfile_init (struct objfile *objfile)
{
int val;
- bfd *sym_bfd = objfile->obfd;
+ bfd *sym_bfd = objfile->obfd.get ();
const char *name = bfd_get_filename (sym_bfd);
asection *text_sect;
unsigned char size_temp[DBX_STRINGTAB_SIZE_SIZE];
lowest_text_address = (CORE_ADDR) -1;
- symfile_bfd = objfile->obfd; /* For next_text_symbol. */
- abfd = objfile->obfd;
+ symfile_bfd = objfile->obfd.get (); /* For next_text_symbol. */
+ abfd = objfile->obfd.get ();
symbuf_end = symbuf_idx = 0;
next_symbol_text_func = dbx_next_symbol_text;
textlow_not_set = 1;
symbol_size = SYMBOL_SIZE (pst);
/* Read in this file's symbols. */
- bfd_seek (objfile->obfd, SYMBOL_OFFSET (pst), SEEK_SET);
+ bfd_seek (objfile->obfd.get (), SYMBOL_OFFSET (pst), SEEK_SET);
read_ofile_symtab (objfile, pst);
}
stringtab_global = DBX_STRINGTAB (objfile);
set_last_source_file (NULL);
- abfd = objfile->obfd;
- symfile_bfd = objfile->obfd; /* Implicit param to next_text_symbol. */
+ abfd = objfile->obfd.get ();
+ symfile_bfd = objfile->obfd.get (); /* Implicit param to next_text_symbol. */
symbuf_end = symbuf_idx = 0;
symbuf_read = 0;
symbuf_left = sym_offset + sym_size;
file_ptr stabstroffset, unsigned int stabstrsize)
{
int val;
- bfd *sym_bfd = objfile->obfd;
+ bfd *sym_bfd = objfile->obfd.get ();
const char *name = bfd_get_filename (sym_bfd);
unsigned int stabsize;
file_ptr stabstroffset, unsigned int stabstrsize)
{
int val;
- bfd *sym_bfd = objfile->obfd;
+ bfd *sym_bfd = objfile->obfd.get ();
const char *name = bfd_get_filename (sym_bfd);
stabsread_new_init ();
char *stabstr_name, char *text_name)
{
int val;
- bfd *sym_bfd = objfile->obfd;
+ bfd *sym_bfd = objfile->obfd.get ();
const char *name = bfd_get_filename (sym_bfd);
asection *stabsect;
asection *stabstrsect;
(std::vector<std::unique_ptr<probe>> *probesp,
struct objfile *objfile) const
{
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
asection *sect = NULL;
/* Do nothing in case this is a .debug file, instead of the objfile
struct comp_unit
{
comp_unit (struct objfile *objf)
- : abfd (objf->obfd)
+ : abfd (objf->obfd.get ())
{
}
static comp_unit *
find_comp_unit (struct objfile *objfile)
{
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
if (gdb_bfd_requires_relocations (abfd))
return dwarf2_frame_objfile_data.get (objfile);
static void
set_comp_unit (struct objfile *objfile, struct comp_unit *unit)
{
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
if (gdb_bfd_requires_relocations (abfd))
return dwarf2_frame_objfile_data.set (objfile, unit);
return;
/* Get build id of objfile. */
- const bfd_build_id *build_id = build_id_bfd_get (obj->obfd);
+ const bfd_build_id *build_id = build_id_bfd_get (obj->obfd.get ());
if (build_id == nullptr)
{
index_cache_debug ("objfile %s has no build id",
/* Object constructor to be called for current DWARF2_PER_OBJFILE.
All .debug_str section strings are automatically stored. */
debug_str_lookup (dwarf2_per_objfile *per_objfile)
- : m_abfd (per_objfile->objfile->obfd),
+ : m_abfd (per_objfile->objfile->obfd.get ()),
m_per_objfile (per_objfile)
{
per_objfile->per_bfd->str.read (per_objfile->objfile);
struct gdbarch *gdbarch = objfile->arch ();
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned int addr_size = baton->per_cu->addr_size ();
- int signed_addr_p = bfd_get_sign_extend_vma (objfile->obfd);
+ int signed_addr_p = bfd_get_sign_extend_vma (objfile->obfd.get ());
/* Adjustment for relocatable objects. */
CORE_ADDR text_offset = baton->per_objfile->objfile->text_section_offset ();
CORE_ADDR base_address = baton->base_address;
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned int addr_size = dlbaton->per_cu->addr_size ();
int offset_size = dlbaton->per_cu->offset_size ();
- int signed_addr_p = bfd_get_sign_extend_vma (objfile->obfd);
+ int signed_addr_p = bfd_get_sign_extend_vma (objfile->obfd.get ());
/* Adjustment for relocatable objects. */
CORE_ADDR text_offset = objfile->text_section_offset ();
CORE_ADDR base_address = dlbaton->base_address;
We don't share with objfiles for which -readnow was requested,
because it would complicate things when loading the same BFD with
-readnow and then without -readnow. */
- if (!gdb_bfd_requires_relocations (objfile->obfd)
+ if (!gdb_bfd_requires_relocations (objfile->obfd.get ())
&& (objfile->flags & OBJF_READNOW) == 0)
{
/* See if one has been created for this BFD yet. */
- per_bfd = dwarf2_per_bfd_bfd_data_key.get (objfile->obfd);
+ per_bfd = dwarf2_per_bfd_bfd_data_key.get (objfile->obfd.get ());
if (per_bfd == nullptr)
{
/* No, create it now. */
- per_bfd = new dwarf2_per_bfd (objfile->obfd, names, can_copy);
- dwarf2_per_bfd_bfd_data_key.set (objfile->obfd, per_bfd);
+ per_bfd = new dwarf2_per_bfd (objfile->obfd.get (), names,
+ can_copy);
+ dwarf2_per_bfd_bfd_data_key.set (objfile->obfd.get (), per_bfd);
}
}
else
{
/* No sharing possible, create one specifically for this objfile. */
- per_bfd = new dwarf2_per_bfd (objfile->obfd, names, can_copy);
+ per_bfd = new dwarf2_per_bfd (objfile->obfd.get (), names, can_copy);
dwarf2_per_bfd_objfile_data_key.set (objfile, per_bfd);
}
addrmap *mutable_map)
{
struct objfile *objfile = per_objfile->objfile;
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
struct gdbarch *gdbarch = objfile->arch ();
const CORE_ADDR baseaddr = objfile->text_section_offset ();
dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
dwarf2_per_bfd *per_bfd = m_per_objfile->per_bfd;
struct objfile *objfile = m_per_objfile->objfile;
- bfd *const abfd = objfile->obfd;
+ bfd *const abfd = objfile->obfd.get ();
again:
static gdb::array_view<const gdb_byte>
get_gdb_index_contents_from_cache (objfile *obj, dwarf2_per_bfd *dwarf2_per_bfd)
{
- const bfd_build_id *build_id = build_id_bfd_get (obj->obfd);
+ const bfd_build_id *build_id = build_id_bfd_get (obj->obfd.get ());
if (build_id == nullptr)
return {};
This is important because things like demangled_names_hash lives in the
objfile's per_bfd space and may have references to things like symbol
names that live in the DWO/DWP file's per_bfd space. PR 16426. */
- gdb_bfd_record_inclusion (per_objfile->objfile->obfd, sym_bfd.get ());
+ gdb_bfd_record_inclusion (per_objfile->objfile->obfd.get (), sym_bfd.get ());
return sym_bfd;
}
{
dwarf2_per_objfile *per_objfile = cu->per_objfile;
struct objfile *objfile = per_objfile->objfile;
- bfd *obfd = objfile->obfd;
+ bfd *obfd = objfile->obfd.get ();
/* Base address selection entry. */
gdb::optional<CORE_ADDR> base;
const gdb_byte *buffer;
dwarf2_per_objfile *per_objfile = cu->per_objfile;
struct objfile *objfile = per_objfile->objfile;
struct comp_unit_head *cu_header = &cu->header;
- bfd *obfd = objfile->obfd;
+ bfd *obfd = objfile->obfd.get ();
unsigned int addr_size = cu_header->addr_size;
CORE_ADDR mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1));
/* Base address selection entry. */
if (ptr - blk->data + len <= blk->size)
{
mpz_import (value->val, len,
- bfd_big_endian (cu->per_objfile->objfile->obfd) ? 1 : -1,
+ bfd_big_endian (cu->per_objfile->objfile->obfd.get ())
+ ? 1 : -1,
1, 0, 0, ptr);
return;
}
{
dwarf_block *blk = attr->as_block ();
mpz_import (value->val, blk->size,
- bfd_big_endian (cu->per_objfile->objfile->obfd) ? 1 : -1,
+ bfd_big_endian (cu->per_objfile->objfile->obfd.get ())
+ ? 1 : -1,
1, 0, 0, blk->data);
}
else
{
dwarf2_per_objfile *per_objfile = cu->per_objfile;
struct objfile *objfile = per_objfile->objfile;
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
ULONGEST loclist_header_size =
(cu->header.initial_length_size == 4 ? LOCLIST_HEADER_SIZE32
: LOCLIST_HEADER_SIZE64);
{
struct dwarf2_per_objfile *dwarf2_per_objfile = cu->per_objfile;
struct objfile *objfile = dwarf2_per_objfile->objfile;
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
ULONGEST rnglist_header_size =
(cu->header.initial_length_size == 4 ? RNGLIST_HEADER_SIZE32
: RNGLIST_HEADER_SIZE64);
dwarf2_per_objfile::read_line_string (const gdb_byte *buf,
unsigned int offset_size)
{
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
ULONGEST str_offset = read_offset (abfd, buf, offset_size);
return per_bfd->line_str.read_string (objfile, str_offset, "DW_FORM_line_strp");
const struct comp_unit_head *cu_header,
unsigned int *bytes_read_ptr)
{
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
LONGEST str_offset = cu_header->read_offset (abfd, buf, bytes_read_ptr);
return per_bfd->line_str.read_string (objfile, str_offset, "DW_FORM_line_strp");
gdb::optional<ULONGEST> addr_base, int addr_size)
{
struct objfile *objfile = per_objfile->objfile;
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
const gdb_byte *info_ptr;
ULONGEST addr_base_or_zero = addr_base.has_value () ? *addr_base : 0;
read_addr_index_from_leb128 (struct dwarf2_cu *cu, const gdb_byte *info_ptr,
unsigned int *bytes_read)
{
- bfd *abfd = cu->per_objfile->objfile->obfd;
+ bfd *abfd = cu->per_objfile->objfile->obfd.get ();
unsigned int addr_index = read_unsigned_leb128 (abfd, info_ptr, bytes_read);
return read_addr_index (cu, addr_index);
dwarf2_per_objfile *per_objfile = cu->per_objfile;
struct objfile *objfile = per_objfile->objfile;
const char *objf_name = objfile_name (objfile);
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
const gdb_byte *info_ptr;
ULONGEST str_offset;
static const char form_name[] = "DW_FORM_GNU_str_index or DW_FORM_strx";
unsigned char op_code, extended_op;
CORE_ADDR baseaddr;
struct objfile *objfile = cu->per_objfile->objfile;
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
struct gdbarch *gdbarch = objfile->arch ();
baseaddr = objfile->text_section_offset ();
if (block->data[0] == DW_OP_addr)
sym->set_value_address
- (cu->header.read_address (objfile->obfd, block->data + 1,
+ (cu->header.read_address (objfile->obfd.get (), block->data + 1,
&dummy));
else
sym->set_value_address
struct dwarf2_cu *cu, LONGEST *value, int bits)
{
struct objfile *objfile = cu->per_objfile->objfile;
- enum bfd_endian byte_order = bfd_big_endian (objfile->obfd) ?
+ enum bfd_endian byte_order = bfd_big_endian (objfile->obfd.get ()) ?
BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE;
LONGEST l = attr->constant_value (0);
struct objfile *objfile = per_objfile->objfile;
struct comp_unit_head *cu_header = &cu->header;
struct dwarf_block *blk;
- enum bfd_endian byte_order = (bfd_big_endian (objfile->obfd) ?
+ enum bfd_endian byte_order = (bfd_big_endian (objfile->obfd.get ()) ?
BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE);
*value = 0;
if (attr == NULL)
return NULL;
- byte_order = (bfd_big_endian (objfile->obfd)
+ byte_order = (bfd_big_endian (objfile->obfd.get ())
? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE);
switch (attr->form)
break;
case DW_OP_addr:
- stack[++stacki] = cu->header.read_address (objfile->obfd, &data[i],
+ stack[++stacki] = cu->header.read_address (objfile->obfd.get (),
+ &data[i],
&bytes_read);
i += bytes_read;
break;
case DW_OP_const1u:
- stack[++stacki] = read_1_byte (objfile->obfd, &data[i]);
+ stack[++stacki] = read_1_byte (objfile->obfd.get (), &data[i]);
i += 1;
break;
case DW_OP_const1s:
- stack[++stacki] = read_1_signed_byte (objfile->obfd, &data[i]);
+ stack[++stacki] = read_1_signed_byte (objfile->obfd.get (), &data[i]);
i += 1;
break;
case DW_OP_const2u:
- stack[++stacki] = read_2_bytes (objfile->obfd, &data[i]);
+ stack[++stacki] = read_2_bytes (objfile->obfd.get (), &data[i]);
i += 2;
break;
case DW_OP_const2s:
- stack[++stacki] = read_2_signed_bytes (objfile->obfd, &data[i]);
+ stack[++stacki] = read_2_signed_bytes (objfile->obfd.get (), &data[i]);
i += 2;
break;
case DW_OP_const4u:
- stack[++stacki] = read_4_bytes (objfile->obfd, &data[i]);
+ stack[++stacki] = read_4_bytes (objfile->obfd.get (), &data[i]);
i += 4;
break;
case DW_OP_const4s:
- stack[++stacki] = read_4_signed_bytes (objfile->obfd, &data[i]);
+ stack[++stacki] = read_4_signed_bytes (objfile->obfd.get (), &data[i]);
i += 4;
break;
case DW_OP_const8u:
- stack[++stacki] = read_8_bytes (objfile->obfd, &data[i]);
+ stack[++stacki] = read_8_bytes (objfile->obfd.get (), &data[i]);
i += 8;
break;
create an msymbol that references an uninitialised section object. */
int section_index = 0;
if ((bfd_section_flags (bfd_section) & SEC_ALLOC) == SEC_ALLOC)
- section_index = gdb_bfd_section_index (objfile->obfd, bfd_section);
+ section_index = gdb_bfd_section_index (objfile->obfd.get (), bfd_section);
struct minimal_symbol *result
= reader.record_full (name, copy_name, address, ms_type, section_index);
/* Name of the last file symbol. This is either a constant string or is
saved on the objfile's filename cache. */
const char *filesymname = "";
- int stripped = (bfd_get_symcount (objfile->obfd) == 0);
+ int stripped = (bfd_get_symcount (objfile->obfd.get ()) == 0);
int elf_make_msymbol_special_p
= gdbarch_elf_make_msymbol_special_p (gdbarch);
/* Skip "special" symbols, e.g. ARM mapping symbols. These are
symbols which do not correspond to objects in the symbol table,
but have some other target-specific meaning. */
- if (bfd_is_target_special_symbol (objfile->obfd, sym))
+ if (bfd_is_target_special_symbol (objfile->obfd.get (), sym))
{
if (gdbarch_record_special_symbol_p (gdbarch))
gdbarch_record_special_symbol (gdbarch, objfile, sym);
&& (sym->flags & BSF_FUNCTION))
{
struct minimal_symbol *msym;
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
asection *sect;
/* Symbol is a reference to a function defined in
elf_rel_plt_read (minimal_symbol_reader &reader,
struct objfile *objfile, asymbol **dyn_symbol_table)
{
- bfd *obfd = objfile->obfd;
+ bfd *obfd = objfile->obfd.get ();
const struct elf_backend_data *bed = get_elf_backend_data (obfd);
asection *relplt, *got_plt;
bfd_size_type reloc_count, reloc;
for (objfile *objfile : current_program_space->objfiles ())
{
- bfd *obfd = objfile->obfd;
+ bfd *obfd = objfile->obfd.get ();
struct gdbarch *gdbarch = objfile->arch ();
struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
size_t ptr_size = TYPE_LENGTH (ptr_type);
elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags,
const struct elfinfo *ei)
{
- bfd *synth_abfd, *abfd = objfile->obfd;
+ bfd *synth_abfd, *abfd = objfile->obfd.get ();
long symcount = 0, dynsymcount = 0, synthcount, storage_needed;
asymbol **symbol_table = NULL, **dyn_symbol_table = NULL;
asymbol *synthsyms;
/* Process the normal ELF symbol table first. */
- storage_needed = bfd_get_symtab_upper_bound (objfile->obfd);
+ storage_needed = bfd_get_symtab_upper_bound (objfile->obfd.get ());
if (storage_needed < 0)
error (_("Can't read symbols from %s: %s"),
- bfd_get_filename (objfile->obfd),
+ bfd_get_filename (objfile->obfd.get ()),
bfd_errmsg (bfd_get_error ()));
if (storage_needed > 0)
bfd_canonicalize_symtab so it must not get freed before ABFD gets. */
symbol_table = (asymbol **) bfd_alloc (abfd, storage_needed);
- symcount = bfd_canonicalize_symtab (objfile->obfd, symbol_table);
+ symcount = bfd_canonicalize_symtab (objfile->obfd.get (), symbol_table);
if (symcount < 0)
error (_("Can't read symbols from %s: %s"),
- bfd_get_filename (objfile->obfd),
+ bfd_get_filename (objfile->obfd.get ()),
bfd_errmsg (bfd_get_error ()));
elf_symtab_read (reader, objfile, ST_REGULAR, symcount, symbol_table,
/* Add the dynamic symbols. */
- storage_needed = bfd_get_dynamic_symtab_upper_bound (objfile->obfd);
+ storage_needed = bfd_get_dynamic_symtab_upper_bound (objfile->obfd.get ());
if (storage_needed > 0)
{
implementation detail, though. */
dyn_symbol_table = (asymbol **) bfd_alloc (abfd, storage_needed);
- dynsymcount = bfd_canonicalize_dynamic_symtab (objfile->obfd,
+ dynsymcount = bfd_canonicalize_dynamic_symtab (objfile->obfd.get (),
dyn_symbol_table);
if (dynsymcount < 0)
error (_("Can't read symbols from %s: %s"),
- bfd_get_filename (objfile->obfd),
+ bfd_get_filename (objfile->obfd.get ()),
bfd_errmsg (bfd_get_error ()));
elf_symtab_read (reader, objfile, ST_DYNAMIC, dynsymcount,
backlinked binary where it is valid. */
if (objfile->separate_debug_objfile_backlink)
- synth_abfd = objfile->separate_debug_objfile_backlink->obfd;
+ synth_abfd = objfile->separate_debug_objfile_backlink->obfd.get ();
else
synth_abfd = abfd;
static void
elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
{
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
struct elfinfo ei;
bool has_dwarf2 = true;
{
gdb_bfd_ref_ptr debug_bfd (symfile_bfd_open (debugfile.c_str ()));
- symbol_file_add_separate (debug_bfd.get (), debugfile.c_str (),
+ symbol_file_add_separate (debug_bfd, debugfile.c_str (),
symfile_flags, objfile);
}
else
{
has_dwarf2 = false;
- const struct bfd_build_id *build_id = build_id_bfd_get (objfile->obfd);
+ const struct bfd_build_id *build_id
+ = build_id_bfd_get (objfile->obfd.get ());
if (build_id != nullptr)
{
objfile->original_name);
else if (build_id_verify (debug_bfd.get (), build_id->size, build_id->data))
{
- symbol_file_add_separate (debug_bfd.get (), symfile_path.get (),
+ symbol_file_add_separate (debug_bfd, symfile_path.get (),
symfile_flags, objfile);
has_dwarf2 = true;
}
static const elfread_data &
elf_get_probes (struct objfile *objfile)
{
- elfread_data *probes_per_bfd = probe_key.get (objfile->obfd);
+ elfread_data *probes_per_bfd = probe_key.get (objfile->obfd.get ());
if (probes_per_bfd == NULL)
{
- probes_per_bfd = probe_key.emplace (objfile->obfd);
+ probes_per_bfd = probe_key.emplace (objfile->obfd.get ());
/* Here we try to gather information about all types of probes from the
objfile. */
for (objfile *objfile : current_program_space->objfiles ())
ALL_OBJFILE_OSECTIONS (objfile, objsec)
{
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
asection *asec = objsec->the_bfd_section;
bfd_vma align = (bfd_vma) 1 << bfd_section_alignment (asec);
bfd_vma start = objsec->addr () & -align;
{
low_text_segment_address = -1;
- bfd_map_over_sections (objfile->obfd,
+ bfd_map_over_sections (objfile->obfd.get (),
record_text_segment_lowaddr,
&low_text_segment_address);
text_offset = tdep->solib_get_text_base (objfile);
}
- bfd_get_section_contents (objfile->obfd, section, buf, 0, size);
+ bfd_get_section_contents (objfile->obfd.get (), section, buf, 0, size);
/* Now internalize the information being careful to handle host/target
endian issues. */
/* Now compute the size of the stub unwinds. Note the ELF tools do not
use stub unwinds at the current time. */
- stub_unwind_sec = bfd_get_section_by_name (objfile->obfd, "$UNWIND_END$");
+ stub_unwind_sec = bfd_get_section_by_name (objfile->obfd.get (),
+ "$UNWIND_END$");
if (stub_unwind_sec)
{
char *buf = (char *) alloca (stub_unwind_size);
/* Read in the stub unwind entries. */
- bfd_get_section_contents (objfile->obfd, stub_unwind_sec, buf,
+ bfd_get_section_contents (objfile->obfd.get (), stub_unwind_sec, buf,
0, stub_unwind_size);
/* Now convert them into regular unwind entries. */
if (objf != nullptr)
{
/* Get corresponding .got.plt or .got section. */
- asect = bfd_get_section_by_name (objf->obfd, ".got.plt");
+ asect = bfd_get_section_by_name (objf->obfd.get (), ".got.plt");
if (asect == nullptr)
- asect = bfd_get_section_by_name (objf->obfd, ".got");
+ asect = bfd_get_section_by_name (objf->obfd.get (), ".got");
}
if (asect != nullptr)
/* Translate asection to obj_section. */
- osect = maint_obj_section_from_bfd_section (objf->obfd, asect, objf);
+ osect = maint_obj_section_from_bfd_section (objf->obfd.get (),
+ asect, objf);
if (osect != nullptr)
{
}
/* This call does not take ownership of SAI. */
- objfile = symbol_file_add_from_bfd (nbfd.get (),
+ objfile = symbol_file_add_from_bfd (nbfd,
bfd_get_filename (nbfd.get ()), 0,
&sai,
OBJF_SHARED | OBJF_NOT_FILENAME, NULL);
return; /* Skip this symbol. */
reader.record_with_info (sym->name, symaddr, ms_type,
- gdb_bfd_section_index (objfile->obfd,
+ gdb_bfd_section_index (objfile->obfd.get (),
sym->section));
}
}
struct bound_minimal_symbol msym;
const char *name = sym->name;
- if (name[0] == bfd_get_symbol_leading_char (main_objfile->obfd))
+ if (name[0] == bfd_get_symbol_leading_char (main_objfile->obfd.get ()))
++name;
msym = lookup_minimal_symbol (name, NULL, main_objfile);
if (msym.minsym == NULL)
/* We need to clear SYMFILE_MAINLINE to avoid interactive question
from symfile.c:symbol_file_add_with_addrs_or_offsets. */
symbol_file_add_from_bfd
- (abfd.get (), name, symfile_flags & ~(SYMFILE_MAINLINE | SYMFILE_VERBOSE),
+ (abfd, name, symfile_flags & ~(SYMFILE_MAINLINE | SYMFILE_VERBOSE),
NULL,
main_objfile->flags & (OBJF_REORDERED | OBJF_SHARED
| OBJF_READNOW | OBJF_USERLOADED),
if (access (dsym_filename, R_OK) != 0)
return NULL;
- if (bfd_mach_o_lookup_command (objfile->obfd,
+ if (bfd_mach_o_lookup_command (objfile->obfd.get (),
BFD_MACH_O_LC_UUID, &main_uuid) == 0)
{
warning (_("can't find UUID in %s"), objfile_name (objfile));
static void
macho_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
{
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
long storage_needed;
std::vector<oso_el> oso_vector;
/* We have to hold on to the symbol table until the call to
std::string dsym_filename;
/* Process the normal symbol table first. */
- storage_needed = bfd_get_symtab_upper_bound (objfile->obfd);
+ storage_needed = bfd_get_symtab_upper_bound (objfile->obfd.get ());
if (storage_needed < 0)
error (_("Can't read symbols from %s: %s"),
- bfd_get_filename (objfile->obfd),
+ bfd_get_filename (objfile->obfd.get ()),
bfd_errmsg (bfd_get_error ()));
if (storage_needed > 0)
minimal_symbol_reader reader (objfile);
- symcount = bfd_canonicalize_symtab (objfile->obfd,
+ symcount = bfd_canonicalize_symtab (objfile->obfd.get (),
symbol_table.data ());
if (symcount < 0)
error (_("Can't read symbols from %s: %s"),
- bfd_get_filename (objfile->obfd),
+ bfd_get_filename (objfile->obfd.get ()),
bfd_errmsg (bfd_get_error ()));
macho_symtab_read (reader, objfile, symcount, symbol_table.data (),
}
/* Add the dsym file as a separate file. */
- symbol_file_add_separate (dsym_bfd.get (), dsym_filename.c_str (),
+ symbol_file_add_separate (dsym_bfd, dsym_filename.c_str (),
symfile_flags, objfile);
/* Don't try to read dwarf2 from main file or shared libraries. */
macho_symfile_relocate (struct objfile *objfile, asection *sectp,
bfd_byte *buf)
{
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
/* We're only interested in sections with relocation
information. */
struct obj_section *osect;
/* Allocate section_offsets. */
- objfile->section_offsets.assign (gdb_bfd_count_sections (objfile->obfd), 0);
+ objfile->section_offsets.assign (gdb_bfd_count_sections (objfile->obfd.get ()), 0);
/* This code is run when we first add the objfile with
symfile_add_with_addrs_or_offsets, when "addrs" not "offsets" are
for (objfile *ofile : current_program_space->objfiles ())
{
if (ofile->obfd == current_program_space->exec_bfd ())
- maint_print_all_sections (_("Exec file: "), ofile->obfd, ofile, arg);
+ maint_print_all_sections (_("Exec file: "), ofile->obfd.get (),
+ ofile, arg);
else if (opts.all_objects)
- maint_print_all_sections (_("Object file: "), ofile->obfd, ofile, arg);
+ maint_print_all_sections (_("Object file: "), ofile->obfd.get (),
+ ofile, arg);
}
if (core_bfd)
const struct ecoff_debug_swap *swap,
struct ecoff_debug_info *info)
{
- cur_bfd = objfile->obfd;
+ cur_bfd = objfile->obfd.get ();
debug_swap = swap;
debug_info = info;
+ info->symbolic_header.ifdMax * swap->external_fdr_size);
fdr_ptr = info->fdr;
for (; fdr_src < fdr_end; fdr_src += swap->external_fdr_size, fdr_ptr++)
- (*swap->swap_fdr_in) (objfile->obfd, fdr_src, fdr_ptr);
+ (*swap->swap_fdr_in) (objfile->obfd.get (), fdr_src, fdr_ptr);
}
psymbol_functions *psf = new psymbol_functions ();
elfmdebug_build_psymtabs (struct objfile *objfile,
const struct ecoff_debug_swap *swap, asection *sec)
{
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
struct ecoff_debug_info *info;
/* FIXME: It's not clear whether we should be getting minimal symbol
if (objfile->obfd == NULL)
return NULL;
- section = bfd_get_section_by_name (objfile->obfd, ".gnu_debugdata");
+ section = bfd_get_section_by_name (objfile->obfd.get (), ".gnu_debugdata");
if (section == NULL)
return NULL;
#ifdef HAVE_LIBLZMA
- gdb_bfd_ref_ptr *shared = gnu_debug_key.get (objfile->obfd);
+ gdb_bfd_ref_ptr *shared = gnu_debug_key.get (objfile->obfd.get ());
if (shared != nullptr)
return *shared;
return NULL;
}
- gnu_debug_key.emplace (objfile->obfd, abfd);
+ gnu_debug_key.emplace (objfile->obfd.get (), abfd);
#else
warning (_("Cannot parse .gnu_debugdata section; LZMA support was "
{
objfile *objf = current_program_space->symfile_object_file;
if (objf->obfd != NULL)
- return bfd_get_symbol_leading_char (objf->obfd);
+ return bfd_get_symbol_leading_char (objf->obfd.get ());
}
return 0;
}
/* It's safe to strip the leading char here once, since the name
is also stored stripped in the minimal symbol table. */
- if (name[0] == get_symbol_leading_char (m_objfile->obfd))
+ if (name[0] == get_symbol_leading_char (m_objfile->obfd.get ()))
name = name.substr (1);
if (ms_type == mst_file_text && startswith (name, "__gnu_compiled"))
static void
mipscoff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
{
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
minimal_symbol_reader reader (objfile);
read_alphacoff_dynamic_symtab (minimal_symbol_reader &reader,
struct objfile *objfile)
{
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
struct alphacoff_dynsecinfo si;
int sym_count;
int i;
void
set_objfile_per_bfd (struct objfile *objfile)
{
- objfile->per_bfd = get_objfile_bfd_data (objfile->obfd);
+ objfile->per_bfd = get_objfile_bfd_data (objfile->obfd.get ());
}
/* Set the objfile's per-BFD notion of the "main" name and
void
build_objfile_section_table (struct objfile *objfile)
{
- int count = gdb_bfd_count_sections (objfile->obfd);
+ int count = gdb_bfd_count_sections (objfile->obfd.get ());
objfile->sections = OBSTACK_CALLOC (&objfile->objfile_obstack,
count,
struct obj_section);
objfile->sections_end = (objfile->sections + count);
for (asection *sect : gdb_bfd_sections (objfile->obfd))
- add_to_objfile_sections (objfile->obfd, sect, objfile, 0);
+ add_to_objfile_sections (objfile->obfd.get (), sect, objfile, 0);
/* See gdb_bfd_section_index. */
- add_to_objfile_sections (objfile->obfd, bfd_com_section_ptr, objfile, 1);
- add_to_objfile_sections (objfile->obfd, bfd_und_section_ptr, objfile, 1);
- add_to_objfile_sections (objfile->obfd, bfd_abs_section_ptr, objfile, 1);
- add_to_objfile_sections (objfile->obfd, bfd_ind_section_ptr, objfile, 1);
+ add_to_objfile_sections (objfile->obfd.get (), bfd_com_section_ptr,
+ objfile, 1);
+ add_to_objfile_sections (objfile->obfd.get (), bfd_und_section_ptr,
+ objfile, 1);
+ add_to_objfile_sections (objfile->obfd.get (), bfd_abs_section_ptr,
+ objfile, 1);
+ add_to_objfile_sections (objfile->obfd.get (), bfd_ind_section_ptr,
+ objfile, 1);
}
/* Given a pointer to an initialized bfd (ABFD) and some flag bits,
requests for specific operations. Other bits like OBJF_SHARED are
simply copied through to the new objfile flags member. */
-objfile::objfile (bfd *abfd, const char *name, objfile_flags flags_)
+objfile::objfile (gdb_bfd_ref_ptr bfd_, const char *name, objfile_flags flags_)
: flags (flags_),
pspace (current_program_space),
- obfd (abfd)
+ obfd (std::move (bfd_))
{
const char *expanded_name;
std::string name_holder;
if (name == NULL)
{
- gdb_assert (abfd == NULL);
+ gdb_assert (obfd == nullptr);
gdb_assert ((flags & OBJF_NOT_FILENAME) != 0);
expanded_name = "<<anonymous objfile>>";
}
that any data that is reference is saved in the per-objfile data
region. */
- gdb_bfd_ref (abfd);
- if (abfd != NULL)
+ if (obfd != nullptr)
{
- mtime = bfd_get_mtime (abfd);
+ mtime = bfd_get_mtime (obfd.get ());
/* Build section table. */
build_objfile_section_table (this);
}
- per_bfd = get_objfile_bfd_data (abfd);
+ per_bfd = get_objfile_bfd_data (obfd.get ());
}
/* If there is a valid and known entry point, function fills *ENTRY_P with it
/* See objfiles.h. */
objfile *
-objfile::make (bfd *bfd_, const char *name_, objfile_flags flags_,
+objfile::make (gdb_bfd_ref_ptr bfd_, const char *name_, objfile_flags flags_,
objfile *parent)
{
- objfile *result = new objfile (bfd_, name_, flags_);
+ objfile *result = new objfile (std::move (bfd_), name_, flags_);
if (parent != nullptr)
add_separate_debug_objfile (result, parent);
if (sf != NULL)
(*sf->sym_finish) (this);
- if (obfd)
- gdb_bfd_unref (obfd);
- else
+ if (obfd == nullptr)
delete per_bfd;
/* Before the symbol table code was redone to make it easier to
{
int idx = s - objfile->sections;
- exec_set_section_address (bfd_get_filename (objfile->obfd), idx,
+ exec_set_section_address (bfd_get_filename (objfile->obfd.get ()), idx,
s->addr ());
}
/* Here OBJFILE_ADDRS contain the correct absolute addresses, the
relative ones must be already created according to debug_objfile. */
- addr_info_make_relative (&objfile_addrs, debug_objfile->obfd);
+ addr_info_make_relative (&objfile_addrs, debug_objfile->obfd.get ());
gdb_assert (debug_objfile->section_offsets.size ()
- == gdb_bfd_count_sections (debug_objfile->obfd));
+ == gdb_bfd_count_sections (debug_objfile->obfd.get ()));
section_offsets new_debug_offsets
(debug_objfile->section_offsets.size ());
relative_addr_info_to_section_offsets (new_debug_offsets, objfile_addrs);
alloc_size = 0;
for (objfile *objfile : pspace->objfiles ())
ALL_OBJFILE_OSECTIONS (objfile, s)
- if (insert_section_p (objfile->obfd, s->the_bfd_section))
+ if (insert_section_p (objfile->obfd.get (), s->the_bfd_section))
alloc_size += 1;
/* This happens on detach/attach (e.g. in gdb.base/attach.exp). */
i = 0;
for (objfile *objfile : pspace->objfiles ())
ALL_OBJFILE_OSECTIONS (objfile, s)
- if (insert_section_p (objfile->obfd, s->the_bfd_section))
+ if (insert_section_p (objfile->obfd.get (), s->the_bfd_section))
map[i++] = s;
std::sort (map, map + alloc_size, sort_cmp);
objfile_name (const struct objfile *objfile)
{
if (objfile->obfd != NULL)
- return bfd_get_filename (objfile->obfd);
+ return bfd_get_filename (objfile->obfd.get ());
return objfile->original_name;
}
objfile_filename (const struct objfile *objfile)
{
if (objfile->obfd != NULL)
- return bfd_get_filename (objfile->obfd);
+ return bfd_get_filename (objfile->obfd.get ());
return NULL;
}
objfile_flavour_name (struct objfile *objfile)
{
if (objfile->obfd != NULL)
- return bfd_flavour_name (bfd_get_flavour (objfile->obfd));
+ return bfd_flavour_name (bfd_get_flavour (objfile->obfd.get ()));
return NULL;
}
private:
/* The only way to create an objfile is to call objfile::make. */
- objfile (bfd *, const char *, objfile_flags);
+ objfile (gdb_bfd_ref_ptr, const char *, objfile_flags);
public:
~objfile ();
/* Create an objfile. */
- static objfile *make (bfd *bfd_, const char *name_, objfile_flags flags_,
- objfile *parent = nullptr);
+ static objfile *make (gdb_bfd_ref_ptr bfd_, const char *name_,
+ objfile_flags flags_, objfile *parent = nullptr);
/* Remove an objfile from the current program space, and free
it. */
section. */
gdb_assert (section->owner == nullptr || section->owner == this->obfd);
- int idx = gdb_bfd_section_index (this->obfd, section);
+ int idx = gdb_bfd_section_index (this->obfd.get (), section);
return this->section_offsets[idx];
}
section. */
gdb_assert (section->owner == nullptr || section->owner == this->obfd);
- int idx = gdb_bfd_section_index (this->obfd, section);
+ int idx = gdb_bfd_section_index (this->obfd.get (), section);
this->section_offsets[idx] = offset;
}
/* The object file's BFD. Can be null if the objfile contains only
minimal symbols, e.g. the run time common symbols for SunOS4. */
- bfd *obfd;
+ gdb_bfd_ref_ptr obfd;
/* The per-BFD data. Note that this is treated specially if OBFD
is NULL. */
try
{
- build_id = build_id_bfd_get (objfile->obfd);
+ build_id = build_id_bfd_get (objfile->obfd.get ());
}
catch (const gdb_exception &except)
{
{
gdb_bfd_ref_ptr abfd (symfile_bfd_open (file_name));
- symbol_file_add_separate (abfd.get (), file_name, 0, obj->objfile);
+ symbol_file_add_separate (abfd, file_name, 0, obj->objfile);
}
catch (const gdb_exception &except)
{
/* Don't return separate debug files. */
if (objfile->separate_debug_objfile_backlink != NULL)
continue;
- obfd_build_id = build_id_bfd_get (objfile->obfd);
+ obfd_build_id = build_id_bfd_get (objfile->obfd.get ());
if (obfd_build_id == NULL)
continue;
if (objfpy_build_id_matches (obfd_build_id, build_id))
objfile *objf = current_program_space->symfile_object_file;
section_offsets offs = objf->section_offsets;
- symfile_segment_data_up data = get_symfile_segment_data (objf->obfd);
+ symfile_segment_data_up data = get_symfile_segment_data (objf->obfd.get ());
do_segments = (data != NULL);
do_sections = num_segments == 0;
if (do_segments)
{
- int ret = symfile_map_offsets_to_segments (objf->obfd,
+ int ret = symfile_map_offsets_to_segments (objf->obfd.get (),
data.get (), offs,
num_segments, segments);
solib_aix_get_section_offsets (struct objfile *objfile,
lm_info_aix *info)
{
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
section_offsets offsets (objfile->section_offsets.size ());
/* Check the main executable. */
objfile *objf = current_program_space->symfile_object_file;
addr = find_canonical_descriptor_in_load_object
- (entry_point, got_value, name, objf->obfd,
+ (entry_point, got_value, name, objf->obfd.get (),
main_executable_lm_info);
/* If descriptor not found via main executable, check each load object
bfd *tmp_bfd;
CORE_ADDR load_addr;
- tmp_bfd = os->objfile->obfd;
+ tmp_bfd = os->objfile->obfd.get ();
load_addr = os->objfile->text_section_offset ();
interp_sect = bfd_get_section_by_name (tmp_bfd, ".text");
if (current_objfile == current_program_space->symfile_object_file)
abfd = current_program_space->exec_bfd ();
else
- abfd = current_objfile->obfd;
+ abfd = current_objfile->obfd.get ();
if (abfd != nullptr
&& gdb_bfd_scan_elf_dyntag (DT_SYMBOLIC, abfd, nullptr, nullptr) == 1)
{
section_addr_info sap
= build_section_addr_info_from_section_table (*so->sections);
- so->objfile = symbol_file_add_from_bfd (so->abfd, so->so_name,
+ gdb_bfd_ref_ptr tmp_bfd
+ (gdb_bfd_ref_ptr::new_reference (so->abfd));
+ so->objfile = symbol_file_add_from_bfd (tmp_bfd, so->so_name,
flags, &sap,
OBJF_SHARED, NULL);
so->objfile->addr_low = so->addr_low;
srcpath += s->filename;
}
- const struct bfd_build_id *build_id = build_id_bfd_get (ofp->obfd);
+ const struct bfd_build_id *build_id
+ = build_id_bfd_get (ofp->obfd.get ());
/* Query debuginfod for the source file. */
if (build_id != nullptr && !srcpath.empty ())
std::vector<std::unique_ptr<probe>> *probesp,
CORE_ADDR base)
{
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
int size = bfd_get_arch_size (abfd) / 8;
struct gdbarch *gdbarch = objfile->arch ();
struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
SystemTap probe's information. We basically have to count how many
probes the objfile has, and then fill in the necessary information
for each one. */
- bfd *obfd = objfile->obfd;
+ bfd *obfd = objfile->obfd.get ();
bfd_vma base;
struct sdt_note *iter;
unsigned save_probesp_len = probesp->size ();
if (from_tty)
add_flags |= SYMFILE_VERBOSE;
- objf = symbol_file_add_from_bfd (nbfd, bfd_get_filename (nbfd),
+ objf = symbol_file_add_from_bfd (nbfd_holder, bfd_get_filename (nbfd),
add_flags, &sai, OBJF_SHARED, NULL);
current_program_space->add_target_sections (objf);
/* We need some representative bfd to know the target we are looking at. */
if (current_program_space->symfile_object_file != NULL)
- templ = current_program_space->symfile_object_file->obfd;
+ templ = current_program_space->symfile_object_file->obfd.get ();
else
templ = current_program_space->exec_bfd ();
if (templ == NULL)
/* Before reread_symbols gets rewritten it is not safe to call:
gdb_assert (objfile->num_sections == bfd_count_sections (objfile->obfd));
*/
- section_addr_info sap = build_section_addr_info_from_bfd (objfile->obfd);
+ section_addr_info sap
+ = build_section_addr_info_from_bfd (objfile->obfd.get ());
for (i = 0; i < sap.size (); i++)
{
int sectindex = sap[i].sectindex;
asection *sect;
int i;
- sect = bfd_get_section_by_name (objfile->obfd, ".text");
+ sect = bfd_get_section_by_name (objfile->obfd.get (), ".text");
if (sect)
objfile->sect_index_text = sect->index;
- sect = bfd_get_section_by_name (objfile->obfd, ".data");
+ sect = bfd_get_section_by_name (objfile->obfd.get (), ".data");
if (sect)
objfile->sect_index_data = sect->index;
- sect = bfd_get_section_by_name (objfile->obfd, ".bss");
+ sect = bfd_get_section_by_name (objfile->obfd.get (), ".bss");
if (sect)
objfile->sect_index_bss = sect->index;
- sect = bfd_get_section_by_name (objfile->obfd, ".rodata");
+ sect = bfd_get_section_by_name (objfile->obfd.get (), ".rodata");
if (sect)
objfile->sect_index_rodata = sect->index;
default_symfile_offsets (struct objfile *objfile,
const section_addr_info &addrs)
{
- objfile->section_offsets.resize (gdb_bfd_count_sections (objfile->obfd));
+ objfile->section_offsets.resize (gdb_bfd_count_sections (objfile->obfd.get ()));
relative_addr_info_to_section_offsets (objfile->section_offsets, addrs);
/* For relocatable files, all loadable sections will start at zero.
that no loadable sections overlap. This algorithm is quadratic,
but the number of sections in a single object file is generally
small. */
- if ((bfd_get_file_flags (objfile->obfd) & (EXEC_P | DYNAMIC)) == 0)
+ if ((bfd_get_file_flags (objfile->obfd.get ()) & (EXEC_P | DYNAMIC)) == 0)
{
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
asection *cur_sec;
for (cur_sec = abfd->sections; cur_sec != NULL; cur_sec = cur_sec->next)
/* Pick non-overlapping offsets for sections the user did not
place explicitly. */
CORE_ADDR lowest = 0;
- for (asection *sect : gdb_bfd_sections (objfile->obfd))
- place_section (objfile->obfd, sect, objfile->section_offsets,
+ for (asection *sect : gdb_bfd_sections (objfile->obfd.get ()))
+ place_section (objfile->obfd.get (), sect, objfile->section_offsets,
lowest);
/* Correctly filling in the section offsets is not quite
virtual section-as-bfd like the bfd filename containing the
section. Therefore use also non-canonical name form for the same
file containing the section. */
- symbol_file_add_separate (abfd.get (),
- bfd_get_filename (abfd.get ()),
+ symbol_file_add_separate (abfd, bfd_get_filename (abfd.get ()),
add_flags | SYMFILE_NOT_FILENAME, objfile);
}
}
/* Save startup file's range of PC addresses to help blockframe.c
decide where the bottom of the stack is. */
- if (bfd_get_file_flags (objfile->obfd) & EXEC_P)
+ if (bfd_get_file_flags (objfile->obfd.get ()) & EXEC_P)
{
/* Executable file -- record its entry point so we'll recognize
the startup file because it contains the entry point. */
- ei->entry_point = bfd_get_start_address (objfile->obfd);
+ ei->entry_point = bfd_get_start_address (objfile->obfd.get ());
ei->entry_point_p = 1;
}
- else if (bfd_get_file_flags (objfile->obfd) & DYNAMIC
- && bfd_get_start_address (objfile->obfd) != 0)
+ else if (bfd_get_file_flags (objfile->obfd.get ()) & DYNAMIC
+ && bfd_get_start_address (objfile->obfd.get ()) != 0)
{
/* Some shared libraries may have entry points set and be
runnable. There's no clear way to indicate this, so just check
for values other than zero. */
- ei->entry_point = bfd_get_start_address (objfile->obfd);
+ ei->entry_point = bfd_get_start_address (objfile->obfd.get ());
ei->entry_point_p = 1;
}
else
+ bfd_section_size (sect)))
{
ei->the_bfd_section_index
- = gdb_bfd_section_index (objfile->obfd, sect);
+ = gdb_bfd_section_index (objfile->obfd.get (), sect);
found = 1;
break;
}
section_addr_info local_addr;
const int mainline = add_flags & SYMFILE_MAINLINE;
- objfile_set_sym_fns (objfile, find_sym_fns (objfile->obfd));
+ objfile_set_sym_fns (objfile, find_sym_fns (objfile->obfd.get ()));
objfile->qf.clear ();
if (objfile->sf == NULL)
{
/* No symbols to load, but we still need to make sure
that the section_offsets table is allocated. */
- int num_sections = gdb_bfd_count_sections (objfile->obfd);
+ int num_sections = gdb_bfd_count_sections (objfile->obfd.get ());
objfile->section_offsets.assign (num_sections, 0);
return;
We no longer warn if the lowest section is not a text segment (as
happens for the PA64 port. */
if (addrs->size () > 0)
- addr_info_make_relative (addrs, objfile->obfd);
+ addr_info_make_relative (addrs, objfile->obfd.get ());
/* Initialize symbol reading routines for this objfile, allow complaints to
appear for this new file, and record how verbose to be, then do the
Upon failure, jumps back to command level (never returns). */
static struct objfile *
-symbol_file_add_with_addrs (bfd *abfd, const char *name,
+symbol_file_add_with_addrs (const gdb_bfd_ref_ptr &abfd, const char *name,
symfile_add_flags add_flags,
section_addr_info *addrs,
objfile_flags flags, struct objfile *parent)
see the objfile constructor. */
void
-symbol_file_add_separate (bfd *bfd, const char *name,
+symbol_file_add_separate (const gdb_bfd_ref_ptr &bfd, const char *name,
symfile_add_flags symfile_flags,
struct objfile *objfile)
{
See symbol_file_add_with_addrs's comments for details. */
struct objfile *
-symbol_file_add_from_bfd (bfd *abfd, const char *name,
+symbol_file_add_from_bfd (const gdb_bfd_ref_ptr &abfd, const char *name,
symfile_add_flags add_flags,
section_addr_info *addrs,
objfile_flags flags, struct objfile *parent)
{
gdb_bfd_ref_ptr bfd (symfile_bfd_open (name));
- return symbol_file_add_from_bfd (bfd.get (), name, add_flags, addrs,
+ return symbol_file_add_from_bfd (bfd, name, add_flags, addrs,
flags, NULL);
}
if (bfd_stat (abfd.get (), &abfd_stat) == 0
&& abfd_stat.st_ino != 0
- && bfd_stat (parent_objfile->obfd, &parent_stat) == 0)
+ && bfd_stat (parent_objfile->obfd.get (), &parent_stat) == 0)
{
if (abfd_stat.st_dev == parent_stat.st_dev
&& abfd_stat.st_ino == parent_stat.st_ino)
if (!verified_as_different)
{
- if (!gdb_bfd_crc (parent_objfile->obfd, &parent_crc))
+ if (!gdb_bfd_crc (parent_objfile->obfd.get (), &parent_crc))
{
if (separate_debug_file_debug)
gdb_printf (gdb_stdlog,
unsigned long crc32;
gdb::unique_xmalloc_ptr<char> debuglink
- (bfd_get_debug_link_info (objfile->obfd, &crc32));
+ (bfd_get_debug_link_info (objfile->obfd.get (), &crc32));
if (debuglink == NULL)
{
int
get_section_index (struct objfile *objfile, const char *section_name)
{
- asection *sect = bfd_get_section_by_name (objfile->obfd, section_name);
+ asection *sect = bfd_get_section_by_name (objfile->obfd.get (), section_name);
if (sect)
return sect->index;
for (objfile *objfile : current_program_space->objfiles ())
{
- if (objfile->obfd == NULL)
+ if (objfile->obfd.get () == NULL)
continue;
/* Separate debug objfiles are handled in the main objfile. */
clear_symtab_users_cleanup defer_clear_users (0);
if (current_program_space->exec_bfd () != NULL
- && filename_cmp (bfd_get_filename (objfile->obfd),
+ && filename_cmp (bfd_get_filename (objfile->obfd.get ()),
bfd_get_filename (current_program_space->exec_bfd ())) == 0)
{
/* Reload EXEC_BFD without asking anything. */
- exec_file_attach (bfd_get_filename (objfile->obfd), 0);
+ exec_file_attach (bfd_get_filename (objfile->obfd.get ()), 0);
}
/* Keep the calls order approx. the same as in free_objfile. */
/* Clean up any state BFD has sitting around. */
{
- gdb_bfd_ref_ptr obfd (objfile->obfd);
+ gdb_bfd_ref_ptr obfd = objfile->obfd;
const char *obfd_filename;
- obfd_filename = bfd_get_filename (objfile->obfd);
+ obfd_filename = bfd_get_filename (objfile->obfd.get ());
/* Open the new BFD before freeing the old one, so that
the filename remains live. */
gdb_bfd_ref_ptr temp (gdb_bfd_open (obfd_filename, gnutarget));
- objfile->obfd = temp.release ();
+ objfile->obfd = std::move (temp);
if (objfile->obfd == NULL)
error (_("Can't open %s to read symbols."), obfd_filename);
}
std::string original_name = objfile->original_name;
/* bfd_openr sets cacheable to true, which is what we want. */
- if (!bfd_check_format (objfile->obfd, bfd_object))
+ if (!bfd_check_format (objfile->obfd.get (), bfd_object))
error (_("Can't read symbols from %s: %s."), objfile_name (objfile),
bfd_errmsg (bfd_get_error ()));
/* Reset the sym_fns pointer. The ELF reader can change it
based on whether .gdb_index is present, and we need it to
start over. PR symtab/15885 */
- objfile_set_sym_fns (objfile, find_sym_fns (objfile->obfd));
+ objfile_set_sym_fns (objfile, find_sym_fns (objfile->obfd.get ()));
objfile->qf.clear ();
build_objfile_section_table (objfile);
static void
symfile_find_segment_sections (struct objfile *objfile)
{
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
int i;
asection *sect;
- symfile_segment_data_up data
- = get_symfile_segment_data (objfile->obfd);
+ symfile_segment_data_up data = get_symfile_segment_data (abfd);
if (data == NULL)
return;
extern struct objfile *symbol_file_add (const char *, symfile_add_flags,
section_addr_info *, objfile_flags);
-extern struct objfile *symbol_file_add_from_bfd (bfd *, const char *, symfile_add_flags,
+extern struct objfile *symbol_file_add_from_bfd (const gdb_bfd_ref_ptr &,
+ const char *, symfile_add_flags,
section_addr_info *,
objfile_flags, struct objfile *parent);
-extern void symbol_file_add_separate (bfd *, const char *, symfile_add_flags,
- struct objfile *);
+extern void symbol_file_add_separate (const gdb_bfd_ref_ptr &, const char *,
+ symfile_add_flags, struct objfile *);
extern std::string find_separate_debug_file_by_debuglink (struct objfile *);
gdb_printf ("\nObject file %s: ", objfile_name (objfile));
gdb_printf ("Objfile at %s, bfd at %s, %d minsyms\n\n",
host_address_to_string (objfile),
- host_address_to_string (objfile->obfd),
+ host_address_to_string (objfile->obfd.get ()),
objfile->per_bfd->minimal_symbol_count);
objfile->dump ();
*bfd_sect = NULL;
*secnum = SECT_OFF_TEXT (objfile);
- bfd_map_over_sections (objfile->obfd, find_targ_sec, &args);
+ bfd_map_over_sections (objfile->obfd.get (), find_targ_sec, &args);
}
/* Return the section number (SECT_OFF_*) that N_SCNUM points to. */
else
limit_offset -= 1;
- abfd = objfile->obfd;
+ abfd = objfile->obfd.get ();
linesz = coff_data (abfd)->local_linesz;
ext_lnno = alloca (linesz);
if (this_symtab_objfile)
objfile = this_symtab_objfile;
- bfd_coff_swap_sym_in (objfile->obfd, raw_symbol, &symbol);
+ bfd_coff_swap_sym_in (objfile->obfd.get (), raw_symbol, &symbol);
if (symbol.n_zeroes)
{
complaint (_("Unexpected symbol continuation"));
static void
read_xcoff_symtab (struct objfile *objfile, legacy_psymtab *pst)
{
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
char *raw_auxptr; /* Pointer to first raw aux entry for sym. */
struct xcoff_symfile_info *xcoff = XCOFF_DATA (objfile);
char *strtbl = xcoff->strtbl;
symbol->n_scnum = -1;
return;
}
- bfd_coff_swap_sym_in (this_symtab_objfile->obfd,
+ bfd_coff_swap_sym_in (this_symtab_objfile->obfd.get (),
stbl + (symno * local_symesz),
symbol);
}
gotit:
/* Take aux entry and return its lineno. */
symno++;
- bfd_coff_swap_aux_in (objfile->obfd, stbl + symno * local_symesz,
+ bfd_coff_swap_aux_in (objfile->obfd.get (), stbl + symno * local_symesz,
symbol->n_type, symbol->n_sclass,
0, symbol->n_numaux, main_aux);
const char **name, char **raw, unsigned int *symnump,
struct objfile *objfile)
{
- bfd_coff_swap_sym_in (objfile->obfd, *raw, symbol);
+ bfd_coff_swap_sym_in (objfile->obfd.get (), *raw, symbol);
if (symbol->n_zeroes)
{
/* If it's exactly E_SYMNMLEN characters long it isn't
*raw += coff_data (objfile->obfd)->local_symesz;
if (symbol->n_numaux > 0)
{
- bfd_coff_swap_aux_in (objfile->obfd, *raw, symbol->n_type,
+ bfd_coff_swap_aux_in (objfile->obfd.get (), *raw, symbol->n_type,
symbol->n_sclass, 0, symbol->n_numaux, aux);
*symnump += symbol->n_numaux;
set_last_source_file (NULL);
- abfd = objfile->obfd;
+ abfd = objfile->obfd.get ();
next_symbol_text_func = xcoff_next_symbol_text;
sraw_symbol = XCOFF_DATA (objfile)->symtbl;
if (symbol.n_numaux > 1)
{
bfd_coff_swap_aux_in
- (objfile->obfd,
+ (objfile->obfd.get (),
sraw_symbol - coff_data (abfd)->local_symesz,
symbol.n_type,
symbol.n_sclass,
unsigned int size;
info = XCOFF_DATA (objfile);
- symfile_bfd = abfd = objfile->obfd;
+ symfile_bfd = abfd = objfile->obfd.get ();
name = objfile_name (objfile);
num_symbols = bfd_get_symcount (abfd); /* # of symbols */