/* 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
open_symbol_file_object (int from_tty)
{
CORE_ADDR lm, l_name;
- gdb::unique_xmalloc_ptr<char> filename;
- int errcode;
struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
int l_name_size = TYPE_LENGTH (ptr_type);
return 0; /* No filename. */
/* Now fetch the filename from target memory. */
- target_read_string (l_name, &filename, SO_NAME_MAX_PATH_SIZE - 1, &errcode);
+ gdb::unique_xmalloc_ptr<char> filename
+ = target_read_string (l_name, SO_NAME_MAX_PATH_SIZE - 1);
- if (errcode)
+ if (filename == nullptr)
{
- warning (_("failed to read exec filename from attached file: %s"),
- safe_strerror (errcode));
+ warning (_("failed to read exec filename from attached file"));
return 0;
}
for (; lm != 0; prev_lm = lm, lm = next_lm)
{
- int errcode;
- gdb::unique_xmalloc_ptr<char> buffer;
-
so_list_up newobj (XCNEW (struct so_list));
lm_info_svr4 *li = lm_info_read (lm).release ();
}
/* Extract this shared object's name. */
- target_read_string (li->l_name, &buffer, SO_NAME_MAX_PATH_SIZE - 1,
- &errcode);
- if (errcode != 0)
+ gdb::unique_xmalloc_ptr<char> buffer
+ = target_read_string (li->l_name, SO_NAME_MAX_PATH_SIZE - 1);
+ if (buffer == nullptr)
{
/* If this entry's l_name address matches that of the
inferior executable, then this is not a normal shared
object, but (most likely) a vDSO. In this case, silently
skip it; otherwise emit a warning. */
if (first_l_name == 0 || li->l_name != first_l_name)
- warning (_("Can't read pathname for load map: %s."),
- safe_strerror (errcode));
+ warning (_("Can't read pathname for load map."));
continue;
}
CORE_ADDR
svr4_fetch_objfile_link_map (struct objfile *objfile)
{
- struct so_list *so;
struct svr4_info *info = get_svr4_info (objfile->pspace);
/* Cause svr4_current_sos() to be run if it hasn't been already. */
/* The other link map addresses may be found by examining the list
of shared libraries. */
- for (so = master_so_list (); so; so = so->next)
+ for (struct so_list *so : current_program_space->solibs ())
if (so->objfile == objfile)
{
lm_info_svr4 *li = (lm_info_svr4 *) so->lm_info;
/* 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
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->text_section_offset ();
interp_sect = bfd_get_section_by_name (tmp_bfd, ".text");
if (interp_sect)
CORE_ADDR load_addr = 0;
int load_addr_found = 0;
int loader_found_in_list = 0;
- struct so_list *so;
struct target_ops *tmp_bfd_target;
sym_addr = 0;
/* On a running target, we can get the dynamic linker's base
address from the shared library table. */
- so = master_so_list ();
- while (so)
+ for (struct so_list *so : current_program_space->solibs ())
{
if (svr4_same_1 (interp_name, so->so_original_name))
{
load_addr = lm_addr_check (so, tmp_bfd.get ());
break;
}
- so = so->next;
}
/* If we were not able to find the base address of the loader
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. */
}
}
+void _initialize_svr4_solib ();
void
-_initialize_svr4_solib (void)
+_initialize_svr4_solib ()
{
solib_svr4_data = gdbarch_data_register_pre_init (solib_svr4_init);