+2020-10-29 Tom Tromey <tom@tromey.com>
+
+ * windows-tdep.c (windows_solib_create_inferior_hook): Update.
+ * symfile.c (reread_symbols): Update.
+ * symfile-mem.c (add_symbol_file_from_memory_command)
+ (add_vsyscall_page): Update.
+ * source-cache.c (source_cache::get_plain_source_lines): Update.
+ * solib-svr4.c (find_program_interpreter, elf_locate_base)
+ (svr4_current_sos_direct, svr4_exec_displacement)
+ (svr4_relocate_main_executable): Update.
+ (svr4_iterate_over_objfiles_in_search_order): Update.
+ * solib-frv.c (enable_break2, enable_break): Update.
+ * solib-dsbt.c (lm_base, enable_break): Update.
+ * solib-darwin.c (find_program_interpreter)
+ (darwin_solib_create_inferior_hook): Update.
+ * sol-thread.c (rw_common, ps_pdmodel): Update.
+ * rs6000-nat.c (rs6000_nat_target::create_inferior): Update.
+ * remote.c (compare_sections_command)
+ (remote_target::trace_set_readonly_regions): Update.
+ * remote-sim.c (get_sim_inferior_data)
+ (gdbsim_target::create_inferior, gdbsim_target::create_inferior): Update.
+ (gdbsim_target_open, gdbsim_target::files_info): Update.
+ * exec.h (exec_bfd): Remove macro.
+ * progspace.c (initialize_progspace): Update.
+ * proc-service.c (ps_addr_to_core_addr, core_addr_to_ps_addr):
+ Update.
+ * nto-procfs.c (nto_procfs_target::post_attach)
+ (nto_procfs_target::create_inferior): Update.
+ * maint.c (maintenance_info_sections): Update.
+ * linux-thread-db.c (thread_db_target::get_thread_local_address):
+ Update.
+ * infcmd.c (post_create_inferior): Update.
+ * gcore.c (default_gcore_arch, default_gcore_target): Update.
+ (objfile_find_memory_regions): Update.
+ * exec.c (validate_exec_file, exec_file_attach)
+ (exec_read_partial_read_only, print_section_info): Update.
+ * corelow.c (core_target_open): Update.
+ * corefile.c (reopen_exec_file, validate_files): Update.
+ * arm-tdep.c (gdb_print_insn_arm): Update.
+ * arch-utils.c (gdbarch_update_p, default_print_insn): Update.
+ * progspace.h (struct program_space) <exec_bfd, set_exec_bfd>: New
+ methods.
+
2020-10-29 Tom Tromey <tom@tromey.com>
* progspace.h (current_target_sections): Remove macro.
/* Check for the current file. */
if (info.abfd == NULL)
- info.abfd = exec_bfd;
+ info.abfd = current_program_space->exec_bfd ();
if (info.abfd == NULL)
info.abfd = core_bfd;
disassembler_ftype disassemble_fn;
disassemble_fn = disassembler (info->arch, info->endian == BFD_ENDIAN_BIG,
- info->mach, exec_bfd);
+ info->mach, current_program_space->exec_bfd ());
gdb_assert (disassemble_fn != NULL);
return (*disassemble_fn) (memaddr, info);
/* GDB is able to get bfd_mach from the exe_bfd, info->mach is
accurate, so mark USER_SPECIFIED_MACHINE_TYPE bit. Otherwise,
opcodes/arm-dis.c:print_insn reset info->mach, and it will trigger
- the assert on the mismatch of info->mach and bfd_get_mach (exec_bfd)
- in default_print_insn. */
- if (exec_bfd != NULL)
+ the assert on the mismatch of info->mach and
+ bfd_get_mach (current_program_space->exec_bfd ()) in
+ default_print_insn. */
+ if (current_program_space->exec_bfd () != NULL)
info->flags |= USER_SPECIFIED_MACHINE_TYPE;
return default_print_insn (memaddr, info);
struct stat st;
/* Don't do anything if there isn't an exec file. */
- if (exec_bfd == NULL)
+ if (current_program_space->exec_bfd () == NULL)
return;
/* If the timestamp of the exec file has changed, reopen it. */
- std::string filename = bfd_get_filename (exec_bfd);
+ std::string filename = bfd_get_filename (current_program_space->exec_bfd ());
res = stat (filename.c_str (), &st);
if (res == 0
void
validate_files (void)
{
- if (exec_bfd && core_bfd)
+ if (current_program_space->exec_bfd () && core_bfd)
{
- if (!core_file_matches_executable_p (core_bfd, exec_bfd))
+ if (!core_file_matches_executable_p (core_bfd,
+ current_program_space->exec_bfd ()))
warning (_("core file may not match specified executable file."));
- else if (bfd_get_mtime (exec_bfd) > bfd_get_mtime (core_bfd))
+ else if (bfd_get_mtime (current_program_space->exec_bfd ())
+ > bfd_get_mtime (core_bfd))
warning (_("exec file is newer than core file."));
}
}
core file. We don't do this unconditionally since an exec file
typically contains more information that helps us determine the
architecture than a core file. */
- if (!exec_bfd)
+ if (!current_program_space->exec_bfd ())
set_gdbarch_from_file (core_bfd);
push_target (std::move (target_holder));
switch_to_thread (thread);
}
- if (exec_bfd == nullptr)
+ if (current_program_space->exec_bfd () == nullptr)
locate_exec_from_corefile_build_id (core_bfd, from_tty);
post_create_inferior (from_tty);
reopen_exec_file ();
current_exec_file = get_exec_file (0);
- const bfd_build_id *exec_file_build_id = build_id_bfd_get (exec_bfd);
+ const bfd_build_id *exec_file_build_id
+ = build_id_bfd_get (current_program_space->exec_bfd ());
if (exec_file_build_id != nullptr)
{
/* Prepend the target prefix, to force gdb_bfd_open to open the
void
exec_file_attach (const char *filename, int from_tty)
{
- /* First, acquire a reference to the current exec_bfd. We release
+ /* First, acquire a reference to the exec_bfd. We release
this at the end of the function; but acquiring it now lets the
BFD cache return it if this call refers to the same file. */
- gdb_bfd_ref_ptr exec_bfd_holder = gdb_bfd_ref_ptr::new_reference (exec_bfd);
+ gdb_bfd_ref_ptr exec_bfd_holder
+ = gdb_bfd_ref_ptr::new_reference (current_program_space->exec_bfd ());
/* Remove any previous exec file. */
current_program_space->exec_close ();
FOPEN_RUB, scratch_chan);
else
temp = gdb_bfd_open (canonical_pathname, gnutarget, scratch_chan);
- exec_bfd = temp.release ();
+ current_program_space->set_exec_bfd (temp.release ());
- if (!exec_bfd)
+ if (!current_program_space->exec_bfd ())
{
error (_("\"%ps\": could not open as an executable file: %s."),
styled_string (file_name_style.style (), scratch_pathname),
gdb_assert (current_program_space->exec_filename == nullptr);
if (load_via_target)
current_program_space->exec_filename
- = make_unique_xstrdup (bfd_get_filename (exec_bfd));
+ = (make_unique_xstrdup
+ (bfd_get_filename (current_program_space->exec_bfd ())));
else
current_program_space->exec_filename
= gdb_realpath_keepfile (scratch_pathname);
- if (!bfd_check_format_matches (exec_bfd, bfd_object, &matching))
+ if (!bfd_check_format_matches (current_program_space->exec_bfd (),
+ bfd_object, &matching))
{
/* Make sure to close exec_bfd, or else "run" might try to use
it. */
gdb_bfd_errmsg (bfd_get_error (), matching).c_str ());
}
- target_section_table sections = build_section_table (exec_bfd);
+ target_section_table sections
+ = build_section_table (current_program_space->exec_bfd ());
- current_program_space->ebfd_mtime = bfd_get_mtime (exec_bfd);
+ current_program_space->ebfd_mtime
+ = bfd_get_mtime (current_program_space->exec_bfd ());
validate_files ();
- set_gdbarch_from_file (exec_bfd);
+ set_gdbarch_from_file (current_program_space->exec_bfd ());
/* Add the executable's sections to the current address spaces'
list of sections. This possibly pushes the exec_ops
target. */
- add_target_sections (&exec_bfd, sections);
+ add_target_sections (¤t_program_space->ebfd, sections);
/* Tell display code (if any) about the changed file name. */
if (deprecated_exec_file_display_hook)
/* It's unduly pedantic to refuse to look at the executable for
read-only pieces; so do the equivalent of readonly regions aka
QTro packet. */
- if (exec_bfd != NULL)
+ if (current_program_space->exec_bfd () != NULL)
{
asection *s;
bfd_size_type size;
bfd_vma vma;
- for (s = exec_bfd->sections; s; s = s->next)
+ for (s = current_program_space->exec_bfd ()->sections; s; s = s->next)
{
if ((s->flags & SEC_LOAD) == 0
|| (s->flags & SEC_READONLY) == 0)
if (amt > len)
amt = len;
- amt = bfd_get_section_contents (exec_bfd, s,
+ amt = bfd_get_section_contents (current_program_space->exec_bfd (), s,
readbuf, offset - vma, amt);
if (amt == 0)
bfd_get_filename (abfd)));
wrap_here (" ");
printf_filtered (_("file type %s.\n"), bfd_get_target (abfd));
- if (abfd == exec_bfd)
+ if (abfd == current_program_space->exec_bfd ())
{
/* gcc-3.4 does not like the initialization in
<p == t->sections_end>. */
void
exec_target::files_info ()
{
- if (exec_bfd)
- print_section_info (¤t_program_space->target_sections, exec_bfd);
+ if (current_program_space->exec_bfd ())
+ print_section_info (¤t_program_space->target_sections,
+ current_program_space->exec_bfd ());
else
puts_filtered (_("\t<no file loaded>\n"));
}
struct bfd;
struct objfile;
-#define exec_bfd current_program_space->ebfd
-
/* Builds a section table, given args BFD. */
extern target_section_table build_section_table (struct bfd *);
if (bfdarch != NULL)
return bfdarch->arch;
- if (exec_bfd == NULL)
+ if (current_program_space->exec_bfd () == NULL)
error (_("Can't find bfd architecture for corefile (need execfile)."));
- return bfd_get_arch (exec_bfd);
+ return bfd_get_arch (current_program_space->exec_bfd ());
}
static const char *
if (gdbarch_gcore_bfd_target_p (target_gdbarch ()))
return gdbarch_gcore_bfd_target (target_gdbarch ());
- /* Otherwise, try to fall back to the exec_bfd target. This will probably
+ /* Otherwise, try to fall back to the exec target. This will probably
not work for non-ELF targets. */
- if (exec_bfd == NULL)
+ if (current_program_space->exec_bfd () == NULL)
return NULL;
else
- return bfd_get_target (exec_bfd);
+ return bfd_get_target (current_program_space->exec_bfd ());
}
/* Derive a reasonable stack segment by unwinding the target stack,
obfd);
/* Make a heap segment. */
- if (derive_heap_segment (exec_bfd, &temp_bottom, &temp_top))
+ if (derive_heap_segment (current_program_space->exec_bfd (), &temp_bottom,
+ &temp_top))
(*func) (temp_bottom, temp_top - temp_bottom,
1, /* Heap section will be readable. */
1, /* Heap section will be writable. */
throw;
}
- if (exec_bfd)
+ if (current_program_space->exec_bfd ())
{
const unsigned solib_add_generation
= current_program_space->solib_add_generation;
/* Cast assuming host == target. Joy. */
/* Do proper sign extension for the target. */
- gdb_assert (exec_bfd);
- return (bfd_get_sign_extend_vma (exec_bfd) > 0
+ gdb_assert (current_program_space->exec_bfd ());
+ return (bfd_get_sign_extend_vma (current_program_space->exec_bfd ()) > 0
? (CORE_ADDR) (intptr_t) address
: (CORE_ADDR) (uintptr_t) address);
}
static void
maintenance_info_sections (const char *arg, int from_tty)
{
- if (exec_bfd)
+ if (current_program_space->exec_bfd ())
{
bool allobj = false;
printf_filtered (_("Exec file:\n"));
- printf_filtered (" `%s', ", bfd_get_filename (exec_bfd));
+ printf_filtered (" `%s', ",
+ bfd_get_filename (current_program_space->exec_bfd ()));
wrap_here (" ");
- printf_filtered (_("file type %s.\n"), bfd_get_target (exec_bfd));
+ printf_filtered (_("file type %s.\n"),
+ bfd_get_target (current_program_space->exec_bfd ()));
/* Only this function cares about the 'ALLOBJ' argument;
if 'ALLOBJ' is the only argument, discard it rather than
if (allobj)
printf_filtered (_(" Object file: %s\n"),
bfd_get_filename (ofile->obfd));
- else if (ofile->obfd != exec_bfd)
+ else if (ofile->obfd != current_program_space->exec_bfd ())
continue;
int section_count = gdb_bfd_count_sections (ofile->obfd);
void
nto_procfs_target::post_attach (pid_t pid)
{
- if (exec_bfd)
+ if (current_program_space->exec_bfd ())
solib_create_inferior_hook (0);
}
push_target (ops);
target_terminal::init ();
- if (exec_bfd != NULL
+ if (current_program_space->exec_bfd () != NULL
|| (symfile_objfile != NULL && symfile_objfile->obfd != NULL))
solib_create_inferior_hook (0);
}
static CORE_ADDR
ps_addr_to_core_addr (psaddr_t addr)
{
- if (exec_bfd && bfd_get_sign_extend_vma (exec_bfd))
+ if (current_program_space->exec_bfd ()
+ && bfd_get_sign_extend_vma (current_program_space->exec_bfd ()))
return (intptr_t) addr;
else
return (uintptr_t) addr;
static psaddr_t
core_addr_to_ps_addr (CORE_ADDR addr)
{
- if (exec_bfd && bfd_get_sign_extend_vma (exec_bfd))
+ if (current_program_space->exec_bfd ()
+ && bfd_get_sign_extend_vma (current_program_space->exec_bfd ()))
return (psaddr_t) (intptr_t) addr;
else
return (psaddr_t) (uintptr_t) addr;
gdb_bfd_unref (ebfd);
/* Removing target sections may close the exec_ops target.
- Clear exec_bfd before doing so to prevent recursion. */
+ Clear ebfd before doing so to prevent recursion. */
ebfd = NULL;
ebfd_mtime = 0;
_initialize_foo routines may need to install their per-pspace
data keys. We can only allocate a progspace when all those
modules have done that. Do this before
- initialize_current_architecture, because that accesses exec_bfd,
- which in turn dereferences current_program_space. */
+ initialize_current_architecture, because that accesses the ebfd
+ of current_program_space. */
current_program_space = new program_space (new_address_space ());
}
to read memory from, this unpushes the exec_ops target. */
void exec_close ();
+ /* Return the exec BFD for this program space. */
+ bfd *exec_bfd () const
+ {
+ return ebfd;
+ }
+
+ /* Set the exec BFD for this program space to ABFD. */
+ void set_exec_bfd (bfd *abfd)
+ {
+ ebfd = abfd;
+ }
+
/* Unique ID number. */
int num = 0;
if (sim_instance_needed == SIM_INSTANCE_NEEDED
&& (sim_data == NULL || sim_data->gdbsim_desc == NULL))
{
- sim_desc = sim_open (SIM_OPEN_DEBUG, &gdb_callback, exec_bfd, sim_argv);
+ sim_desc = sim_open (SIM_OPEN_DEBUG, &gdb_callback,
+ current_program_space->exec_bfd (), sim_argv);
if (sim_desc == NULL)
error (_("Unable to create simulator instance for inferior %d."),
inf->num);
char *arg_buf;
const char *args = allargs.c_str ();
- if (exec_file == 0 || exec_bfd == 0)
+ if (exec_file == 0 || current_program_space->exec_bfd () == 0)
warning (_("No executable file specified."));
if (!sim_data->program_loaded)
warning (_("No program loaded."));
built_argv.reset (arg_buf);
}
- if (sim_create_inferior (sim_data->gdbsim_desc, exec_bfd,
+ if (sim_create_inferior (sim_data->gdbsim_desc,
+ current_program_space->exec_bfd (),
built_argv.get (), env)
!= SIM_RC_OK)
error (_("Unable to create sim inferior."));
sim_argv = argv.release ();
init_callbacks ();
- gdbsim_desc = sim_open (SIM_OPEN_DEBUG, &gdb_callback, exec_bfd, sim_argv);
+ gdbsim_desc = sim_open (SIM_OPEN_DEBUG, &gdb_callback,
+ current_program_space->exec_bfd (), sim_argv);
if (gdbsim_desc == 0)
{
= get_sim_inferior_data (current_inferior (), SIM_INSTANCE_NEEDED);
const char *file = "nothing";
- if (exec_bfd)
- file = bfd_get_filename (exec_bfd);
+ if (current_program_space->exec_bfd ())
+ file = bfd_get_filename (current_program_space->exec_bfd ());
if (remote_debug)
fprintf_unfiltered (gdb_stdlog, "gdbsim_files_info: file \"%s\"\n", file);
- if (exec_bfd)
+ if (current_program_space->exec_bfd ())
{
fprintf_unfiltered (gdb_stdlog, "\tAttached to %s running program %s\n",
target_shortname, file);
#include <signal.h>
#include "serial.h"
-#include "gdbcore.h" /* for exec_bfd */
+#include "gdbcore.h"
#include "remote-fileio.h"
#include "gdb/fileio.h"
int res;
int read_only = 0;
- if (!exec_bfd)
+ if (!current_program_space->exec_bfd ())
error (_("command cannot be used without an exec file"));
if (args != NULL && strcmp (args, "-r") == 0)
args = NULL;
}
- for (s = exec_bfd->sections; s; s = s->next)
+ for (s = current_program_space->exec_bfd ()->sections; s; s = s->next)
{
if (!(s->flags & SEC_LOAD))
continue; /* Skip non-loadable section. */
lma = s->lma;
gdb::byte_vector sectdata (size);
- bfd_get_section_contents (exec_bfd, s, sectdata.data (), 0, size);
+ bfd_get_section_contents (current_program_space->exec_bfd (), s,
+ sectdata.data (), 0, size);
res = target_verify_memory (sectdata.data (), lma, size);
int anysecs = 0;
int offset = 0;
- if (!exec_bfd)
+ if (!current_program_space->exec_bfd ())
return; /* No information to give. */
struct remote_state *rs = get_remote_state ();
strcpy (rs->buf.data (), "QTro");
offset = strlen (rs->buf.data ());
- for (s = exec_bfd->sections; s; s = s->next)
+ for (s = current_program_space->exec_bfd ()->sections; s; s = s->next)
{
char tmp1[40], tmp2[40];
int sec_length;
Blindly calling rs6000_gdbarch_init used to work in older versions of
GDB, as rs6000_gdbarch_init incorrectly used the previous tdep to
determine the wordsize. */
- if (exec_bfd)
+ if (current_program_space->exec_bfd ())
{
const struct bfd_arch_info *exec_bfd_arch_info;
- exec_bfd_arch_info = bfd_get_arch_info (exec_bfd);
+ exec_bfd_arch_info
+ = bfd_get_arch_info (current_program_space->exec_bfd ());
if (arch == exec_bfd_arch_info->arch)
return;
}
gdbarch_info_init (&info);
info.bfd_arch_info = bfd_get_arch_info (&abfd);
- info.abfd = exec_bfd;
+ info.abfd = current_program_space->exec_bfd ();
if (!gdbarch_update_p (info))
internal_error (__FILE__, __LINE__,
#if defined (__sparcv9)
/* For Sparc64 cross Sparc32, make sure the address has not been
accidentally sign-extended (or whatever) to beyond 32 bits. */
- if (bfd_get_arch_size (exec_bfd) == 32)
+ if (bfd_get_arch_size (current_program_space->exec_bfd ()) == 32)
addr &= 0xffffffff;
#endif
ps_err_e
ps_pdmodel (struct ps_prochandle *ph, int *data_model)
{
- if (exec_bfd == 0)
+ if (current_program_space->exec_bfd () == 0)
*data_model = PR_MODEL_UNKNOWN;
- else if (bfd_get_arch_size (exec_bfd) == 32)
+ else if (bfd_get_arch_size (current_program_space->exec_bfd ()) == 32)
*data_model = PR_MODEL_ILP32;
else
*data_model = PR_MODEL_LP64;
{
char *buf = NULL;
- /* If we have an exec_bfd, get the interpreter from the load commands. */
- if (exec_bfd)
+ /* If we have an current exec_bfd, get the interpreter from the load
+ commands. */
+ if (current_program_space->exec_bfd ())
{
bfd_mach_o_load_command *cmd;
- if (bfd_mach_o_lookup_command (exec_bfd,
+ if (bfd_mach_o_lookup_command (current_program_space->exec_bfd (),
BFD_MACH_O_LC_LOAD_DYLINKER, &cmd) == 1)
return cmd->command.dylinker.name_str;
}
CORE_ADDR vmaddr;
/* Find the base address of the executable. */
- vmaddr = bfd_mach_o_get_base_address (exec_bfd);
+ vmaddr = bfd_mach_o_get_base_address (current_program_space->exec_bfd ());
/* Relocate. */
if (vmaddr != load_addr)
{
/* Dyld hasn't yet relocated itself, so the notifier address may
be incorrect (as it has to be relocated). */
- CORE_ADDR start = bfd_get_start_address (exec_bfd);
+ CORE_ADDR start
+ = bfd_get_start_address (current_program_space->exec_bfd ());
if (start == 0)
notifier = 0;
else
"lm_base: get addr %x by _GLOBAL_OFFSET_TABLE_.\n",
(unsigned int) addr);
}
- else if (scan_dyntag (DT_PLTGOT, exec_bfd, &addr))
+ else if (scan_dyntag (DT_PLTGOT, current_program_space->exec_bfd (), &addr))
{
struct int_elf32_dsbt_loadmap *ldm;
asection *interp_sect;
struct dsbt_info *info;
- if (exec_bfd == NULL)
+ if (current_program_space->exec_bfd () == NULL)
return 0;
if (!target_has_execution ())
/* Find the .interp section; if not found, warn the user and drop
into the old breakpoint at symbol code. */
- interp_sect = bfd_get_section_by_name (exec_bfd, ".interp");
+ interp_sect = bfd_get_section_by_name (current_program_space->exec_bfd (),
+ ".interp");
if (interp_sect)
{
unsigned int interp_sect_size;
the contents specify the dynamic linker this program uses. */
interp_sect_size = bfd_section_size (interp_sect);
buf = (char *) alloca (interp_sect_size);
- bfd_get_section_contents (exec_bfd, interp_sect,
- buf, 0, interp_sect_size);
+ bfd_get_section_contents (current_program_space->exec_bfd (),
+ interp_sect, buf, 0, interp_sect_size);
/* Now we need to figure out where the dynamic linker was
loaded so that we can load its symbols and place a breakpoint
/* Find the .interp section; if not found, warn the user and drop
into the old breakpoint at symbol code. */
- interp_sect = bfd_get_section_by_name (exec_bfd, ".interp");
+ interp_sect = bfd_get_section_by_name (current_program_space->exec_bfd (),
+ ".interp");
if (interp_sect)
{
unsigned int interp_sect_size;
the contents specify the dynamic linker this program uses. */
interp_sect_size = bfd_section_size (interp_sect);
buf = (char *) alloca (interp_sect_size);
- bfd_get_section_contents (exec_bfd, interp_sect,
- buf, 0, interp_sect_size);
+ bfd_get_section_contents (current_program_space->exec_bfd (),
+ interp_sect, buf, 0, interp_sect_size);
/* Now we need to figure out where the dynamic linker was
loaded so that we can load its symbols and place a breakpoint
/* Check for the presence of a .interp section. If there is no
such section, the executable is statically linked. */
- interp_sect = bfd_get_section_by_name (exec_bfd, ".interp");
+ interp_sect = bfd_get_section_by_name (current_program_space->exec_bfd (),
+ ".interp");
if (interp_sect == NULL)
{
static gdb::optional<gdb::byte_vector>
find_program_interpreter (void)
{
- /* If we have an exec_bfd, use its section table. */
- if (exec_bfd
- && bfd_get_flavour (exec_bfd) == bfd_target_elf_flavour)
+ /* If we have a current exec_bfd, use its section table. */
+ if (current_program_space->exec_bfd ()
+ && (bfd_get_flavour (current_program_space->exec_bfd ())
+ == bfd_target_elf_flavour))
{
struct bfd_section *interp_sect;
- interp_sect = bfd_get_section_by_name (exec_bfd, ".interp");
+ interp_sect = bfd_get_section_by_name (current_program_space->exec_bfd (),
+ ".interp");
if (interp_sect != NULL)
{
int sect_size = bfd_section_size (interp_sect);
gdb::byte_vector buf (sect_size);
- bfd_get_section_contents (exec_bfd, interp_sect, buf.data (), 0,
- sect_size);
+ bfd_get_section_contents (current_program_space->exec_bfd (),
+ interp_sect, buf.data (), 0, sect_size);
return buf;
}
}
/* Look for DT_MIPS_RLD_MAP first. MIPS executables use this
instead of DT_DEBUG, although they sometimes contain an unused
DT_DEBUG. */
- if (scan_dyntag (DT_MIPS_RLD_MAP, exec_bfd, &dyn_ptr, NULL)
+ if (scan_dyntag (DT_MIPS_RLD_MAP, current_program_space->exec_bfd (),
+ &dyn_ptr, NULL)
|| scan_dyntag_auxv (DT_MIPS_RLD_MAP, &dyn_ptr, NULL))
{
struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
/* Then check DT_MIPS_RLD_MAP_REL. MIPS executables now use this form
because of needing to support PIE. DT_MIPS_RLD_MAP will also exist
in non-PIE. */
- if (scan_dyntag (DT_MIPS_RLD_MAP_REL, exec_bfd, &dyn_ptr, &dyn_ptr_addr)
+ if (scan_dyntag (DT_MIPS_RLD_MAP_REL, current_program_space->exec_bfd (),
+ &dyn_ptr, &dyn_ptr_addr)
|| scan_dyntag_auxv (DT_MIPS_RLD_MAP_REL, &dyn_ptr, &dyn_ptr_addr))
{
struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
}
/* Find DT_DEBUG. */
- if (scan_dyntag (DT_DEBUG, exec_bfd, &dyn_ptr, NULL)
+ if (scan_dyntag (DT_DEBUG, current_program_space->exec_bfd (), &dyn_ptr, NULL)
|| scan_dyntag_auxv (DT_DEBUG, &dyn_ptr, NULL))
return dyn_ptr;
/* Assume that everything is a library if the dynamic loader was loaded
late by a static executable. */
- if (exec_bfd && bfd_get_section_by_name (exec_bfd, ".dynamic") == NULL)
+ if (current_program_space->exec_bfd ()
+ && bfd_get_section_by_name (current_program_space->exec_bfd (),
+ ".dynamic") == NULL)
ignore_first = 0;
else
ignore_first = 1;
a call to gdbarch_convert_from_func_ptr_addr. */
CORE_ADDR entry_point, exec_displacement;
- if (exec_bfd == NULL)
+ if (current_program_space->exec_bfd () == NULL)
return 0;
/* Therefore for ELF it is ET_EXEC and not ET_DYN. Both shared libraries
being executed themselves and PIE (Position Independent Executable)
executables are ET_DYN. */
- if ((bfd_get_file_flags (exec_bfd) & DYNAMIC) == 0)
+ if ((bfd_get_file_flags (current_program_space->exec_bfd ()) & DYNAMIC) == 0)
return 0;
if (target_auxv_search (current_top_target (), AT_ENTRY, &entry_point) <= 0)
return 0;
- exec_displacement = entry_point - bfd_get_start_address (exec_bfd);
+ exec_displacement
+ = entry_point - bfd_get_start_address (current_program_space->exec_bfd ());
/* Verify the EXEC_DISPLACEMENT candidate complies with the required page
alignment. It is cheaper than the program headers comparison below. */
- if (bfd_get_flavour (exec_bfd) == bfd_target_elf_flavour)
+ if (bfd_get_flavour (current_program_space->exec_bfd ())
+ == bfd_target_elf_flavour)
{
- const struct elf_backend_data *elf = get_elf_backend_data (exec_bfd);
+ const struct elf_backend_data *elf
+ = get_elf_backend_data (current_program_space->exec_bfd ());
/* p_align of PT_LOAD segments does not specify any alignment but
only congruency of addresses:
looking at a different file than the one used by the kernel - for
instance, "gdb program" connected to "gdbserver :PORT ld.so program". */
- if (bfd_get_flavour (exec_bfd) == bfd_target_elf_flavour)
+ if (bfd_get_flavour (current_program_space->exec_bfd ())
+ == bfd_target_elf_flavour)
{
/* Be optimistic and return 0 only if GDB was able to verify the headers
really do not match. */
gdb::optional<gdb::byte_vector> phdrs_target
= read_program_header (-1, &arch_size, NULL);
gdb::optional<gdb::byte_vector> phdrs_binary
- = read_program_headers_from_bfd (exec_bfd);
+ = read_program_headers_from_bfd (current_program_space->exec_bfd ());
if (phdrs_target && phdrs_binary)
{
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
content offset for the verification purpose. */
if (phdrs_target->size () != phdrs_binary->size ()
- || bfd_get_arch_size (exec_bfd) != arch_size)
+ || bfd_get_arch_size (current_program_space->exec_bfd ()) != arch_size)
return 0;
else if (arch_size == 32
&& phdrs_target->size () >= sizeof (Elf32_External_Phdr)
&& phdrs_target->size () % sizeof (Elf32_External_Phdr) == 0)
{
- Elf_Internal_Ehdr *ehdr2 = elf_tdata (exec_bfd)->elf_header;
- Elf_Internal_Phdr *phdr2 = elf_tdata (exec_bfd)->phdr;
+ Elf_Internal_Ehdr *ehdr2
+ = elf_tdata (current_program_space->exec_bfd ())->elf_header;
+ Elf_Internal_Phdr *phdr2
+ = elf_tdata (current_program_space->exec_bfd ())->phdr;
CORE_ADDR displacement = 0;
int i;
}
/* prelink can convert .plt SHT_NOBITS to SHT_PROGBITS. */
+ bfd *exec_bfd = current_program_space->exec_bfd ();
plt2_asect = bfd_get_section_by_name (exec_bfd, ".plt");
if (plt2_asect)
{
&& phdrs_target->size () >= sizeof (Elf64_External_Phdr)
&& phdrs_target->size () % sizeof (Elf64_External_Phdr) == 0)
{
- Elf_Internal_Ehdr *ehdr2 = elf_tdata (exec_bfd)->elf_header;
- Elf_Internal_Phdr *phdr2 = elf_tdata (exec_bfd)->phdr;
+ Elf_Internal_Ehdr *ehdr2
+ = elf_tdata (current_program_space->exec_bfd ())->elf_header;
+ Elf_Internal_Phdr *phdr2
+ = elf_tdata (current_program_space->exec_bfd ())->phdr;
CORE_ADDR displacement = 0;
int i;
}
/* prelink can convert .plt SHT_NOBITS to SHT_PROGBITS. */
- plt2_asect = bfd_get_section_by_name (exec_bfd, ".plt");
+ plt2_asect
+ = bfd_get_section_by_name (current_program_space->exec_bfd (),
+ ".plt");
if (plt2_asect)
{
int content2;
filesz = extract_unsigned_integer (buf_filesz_p, 8,
byte_order);
- /* PLT2_ASECT is from on-disk file (exec_bfd) while
- FILESZ is from the in-memory image. */
+ /* PLT2_ASECT is from on-disk file (current
+ exec_bfd) while FILESZ is from the in-memory
+ image. */
if (content2)
filesz += bfd_section_size (plt2_asect);
else
printf_unfiltered (_("Using PIE (Position Independent Executable) "
"displacement %s for \"%s\".\n"),
paddress (target_gdbarch (), exec_displacement),
- bfd_get_filename (exec_bfd));
+ bfd_get_filename (current_program_space->exec_bfd ()));
}
*displacementp = exec_displacement;
displacement);
objfile_relocate (symfile_objfile, new_offsets);
}
- else if (exec_bfd)
+ else if (current_program_space->exec_bfd ())
{
asection *asect;
+ bfd *exec_bfd = current_program_space->exec_bfd ();
for (asect = exec_bfd->sections; asect != NULL; asect = asect->next)
exec_set_section_address (bfd_get_filename (exec_bfd), asect->index,
bfd_section_vma (asect) + displacement);
current_objfile = current_objfile->separate_debug_objfile_backlink;
if (current_objfile == symfile_objfile)
- abfd = exec_bfd;
+ abfd = current_program_space->exec_bfd ();
else
abfd = current_objfile->obfd;
time_t mtime = 0;
if (SYMTAB_OBJFILE (s) != NULL && SYMTAB_OBJFILE (s)->obfd != NULL)
mtime = SYMTAB_OBJFILE (s)->mtime;
- else if (exec_bfd)
+ else if (current_program_space->exec_bfd ())
mtime = current_program_space->ebfd_mtime;
if (mtime && mtime < st.st_mtime)
if (symfile_objfile != NULL)
templ = symfile_objfile->obfd;
else
- templ = exec_bfd;
+ templ = current_program_space->exec_bfd ();
if (templ == NULL)
error (_("Must use symbol-file or exec-file "
"before add-symbol-file-from-memory."));
if (core_bfd != NULL)
bfd = core_bfd;
- else if (exec_bfd != NULL)
- bfd = exec_bfd;
+ else if (current_program_space->exec_bfd () != NULL)
+ bfd = current_program_space->exec_bfd ();
else
/* FIXME: cagney/2004-05-06: Should not require an existing
BFD when trying to create a run-time BFD of the VSYSCALL
/* We need to do this whenever any symbols go away. */
clear_symtab_users_cleanup defer_clear_users (0);
- if (exec_bfd != NULL
+ if (current_program_space->exec_bfd () != NULL
&& filename_cmp (bfd_get_filename (objfile->obfd),
- bfd_get_filename (exec_bfd)) == 0)
+ bfd_get_filename (current_program_space->exec_bfd ())) == 0)
{
/* Reload EXEC_BFD without asking anything. */
#include "regcache.h"
#include "inferior.h"
#include "gdbthread.h"
-#include "exec.h" /* exec_bfd */
+#include "exec.h"
#include "completer.h"
#include "filenames.h"
#include "remote.h"
/* Rebase executable if the base address changed because of ASLR. */
if (symfile_objfile != nullptr && exec_base != 0)
{
- CORE_ADDR vmaddr = pe_data (exec_bfd)->pe_opthdr.ImageBase;
+ CORE_ADDR vmaddr
+ = pe_data (current_program_space->exec_bfd ())->pe_opthdr.ImageBase;
if (vmaddr != exec_base)
objfile_rebase (symfile_objfile, exec_base - vmaddr);
}