/* Handle SVR4 shared libraries for GDB, the GNU Debugger.
- Copyright (C) 1990-2019 Free Software Foundation, Inc.
+ Copyright (C) 1990-2020 Free Software Foundation, Inc.
This file is part of GDB.
{
struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
- enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
+ enum bfd_endian byte_order = type_byte_order (ptr_type);
ULONGEST version = 0;
try
/* Always locate the debug struct, in case it moved. */
info->debug_base = 0;
if (locate_base (info) == 0)
- return;
+ {
+ /* It's possible for the reloc_complete probe to be triggered before
+ the linker has set the DT_DEBUG pointer (for example, when the
+ linker has finished relocating an LD_AUDIT library or its
+ dependencies). Since we can't yet handle libraries from other link
+ namespaces, we don't lose anything by ignoring them here. */
+ struct value *link_map_id_val;
+ try
+ {
+ link_map_id_val = pa->prob->evaluate_argument (0, frame);
+ }
+ catch (const gdb_exception_error)
+ {
+ link_map_id_val = NULL;
+ }
+ /* glibc and illumos' libc both define LM_ID_BASE as zero. */
+ if (link_map_id_val != NULL && value_as_long (link_map_id_val) != 0)
+ action = DO_NOTHING;
+ else
+ return;
+ }
/* GDB does not currently support libraries loaded via dlmopen
into namespaces other than the initial one. We must ignore
/* Helper function for svr4_update_solib_event_breakpoints. */
-static int
-svr4_update_solib_event_breakpoint (struct breakpoint *b, void *arg)
+static bool
+svr4_update_solib_event_breakpoint (struct breakpoint *b)
{
struct bp_location *loc;
if (b->type != bp_shlib_event)
{
/* Continue iterating. */
- return 0;
+ return false;
}
for (loc = b->loc; loc != NULL; loc = loc->next)
}
/* Continue iterating. */
- return 0;
+ return false;
}
/* Enable or disable optional solib event breakpoints as appropriate.
static void
svr4_update_solib_event_breakpoints (void)
{
- iterate_over_breakpoints (svr4_update_solib_event_breakpoint, NULL);
+ iterate_over_breakpoints (svr4_update_solib_event_breakpoint);
}
/* Create and register solib event breakpoints. PROBES is an array
CORE_ADDR load_addr;
tmp_bfd = os->objfile->obfd;
- load_addr = ANOFFSET (os->objfile->section_offsets,
- SECT_OFF_TEXT (os->objfile));
+ load_addr = os->objfile->section_offsets[SECT_OFF_TEXT (os->objfile)];
interp_sect = bfd_get_section_by_name (tmp_bfd, ".text");
if (interp_sect)
if (!load_addr_found)
{
struct regcache *regcache
- = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
+ = get_thread_arch_regcache (current_inferior ()->process_target (),
+ inferior_ptid, target_gdbarch ());
load_addr = (regcache_read_pc (regcache)
- exec_entry_point (tmp_bfd.get (), tmp_bfd_target));
... Though the system chooses virtual addresses for
individual processes, it maintains the segments' relative
positions. Because position-independent code uses relative
- addressesing between segments, the difference between
+ addressing between segments, the difference between
virtual addresses in memory must match the difference
between virtual addresses in the file. The difference
between the virtual address of any segment in memory and
if (symfile_objfile)
{
- struct section_offsets *new_offsets;
- int i;
-
- new_offsets = XALLOCAVEC (struct section_offsets,
- symfile_objfile->num_sections);
-
- for (i = 0; i < symfile_objfile->num_sections; i++)
- new_offsets->offsets[i] = displacement;
-
+ section_offsets new_offsets (symfile_objfile->section_offsets.size (),
+ displacement);
objfile_relocate (symfile_objfile, new_offsets);
}
else if (exec_bfd)
/* Most OS'es that have SVR4-style ELF dynamic libraries define a
`struct r_debug' and a `struct link_map' that are binary compatible
- with the origional SVR4 implementation. */
+ with the original SVR4 implementation. */
/* Fetch (and possibly build) an appropriate `struct link_map_offsets'
for an ILP32 SVR4 system. */
else
abfd = current_objfile->obfd;
- if (abfd != nullptr &&
- scan_dyntag (DT_SYMBOLIC, abfd, nullptr, nullptr) == 1)
+ if (abfd != nullptr
+ && scan_dyntag (DT_SYMBOLIC, abfd, nullptr, nullptr) == 1)
{
checked_current_objfile = true;
if (cb (current_objfile, cb_data) != 0)