static CORE_ADDR
lm_addr (const so_list &so)
{
- auto *li = gdb::checked_static_cast<const lm_info_svr4 *> (so.lm_info);
+ auto *li = gdb::checked_static_cast<const lm_info_svr4 *> (so.lm_info.get ());
return li->l_addr;
}
struct bfd_section *bfd_sect = sec->the_bfd_section;
bfd *abfd = bfd_sect->owner;
const char *section_name = bfd_section_name (bfd_sect);
- auto *info = gdb::checked_static_cast<lm_info_aix *> (so.lm_info);
+ auto *info = gdb::checked_static_cast<lm_info_aix *> (so.lm_info.get ());
if (strcmp (section_name, ".text") == 0)
{
new_solib->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
memcpy (new_solib->so_name, new_solib->so_original_name,
SO_NAME_MAX_PATH_SIZE);
- new_solib->lm_info = new lm_info_aix (info);
+ new_solib->lm_info = gdb::make_unique<lm_info_aix> (info);
/* Add it to the list. */
if (!start)
/* Create and fill the new so_list element. */
so_list *newobj = new so_list;
- lm_info_darwin *li = new lm_info_darwin;
- newobj->lm_info = li;
+ auto li = gdb::make_unique<lm_info_darwin> ();
strncpy (newobj->so_name, file_path.get (), SO_NAME_MAX_PATH_SIZE - 1);
newobj->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
strcpy (newobj->so_original_name, newobj->so_name);
li->lm_addr = load_addr;
+ newobj->lm_info = std::move (li);
+
if (head == NULL)
head = newobj;
else
static void
darwin_relocate_section_addresses (so_list &so, target_section *sec)
{
- auto *li = gdb::checked_static_cast<lm_info_darwin *> (so.lm_info);
+ auto *li = gdb::checked_static_cast<lm_info_darwin *> (so.lm_info.get ());
sec->addr += li->lm_addr;
sec->endaddr += li->lm_addr;
}
so_list *sop = new so_list;
- lm_info_dsbt *li = new lm_info_dsbt;
- sop->lm_info = li;
+ auto li = gdb::make_unique<lm_info_dsbt> ();
li->map = loadmap;
/* Fetch the name. */
addr = extract_unsigned_integer (lm_buf.l_name,
strcpy (sop->so_original_name, sop->so_name);
}
+ sop->lm_info = std::move (li);
+
*sos_next_ptr = sop;
sos_next_ptr = &sop->next;
}
dsbt_relocate_section_addresses (so_list &so, target_section *sec)
{
int seg;
- auto *li = gdb::checked_static_cast<lm_info_dsbt *> (so.lm_info);
+ auto *li = gdb::checked_static_cast<lm_info_dsbt *> (so.lm_info.get ());
int_elf32_dsbt_loadmap *map = li->map;
for (seg = 0; seg < map->nsegs; seg++)
}
so_list *sop = new so_list;
- lm_info_frv *li = new lm_info_frv;
- sop->lm_info = li;
+ auto li = gdb::make_unique<lm_info_frv> ();
li->map = loadmap;
li->got_value = got_addr;
li->lm_addr = lm_addr;
strcpy (sop->so_original_name, sop->so_name);
}
+ sop->lm_info = std::move (li);
+
*sos_next_ptr = sop;
sos_next_ptr = &sop->next;
}
frv_relocate_section_addresses (so_list &so, target_section *sec)
{
int seg;
- auto *li = gdb::checked_static_cast<lm_info_frv *> (so.lm_info);
+ auto *li = gdb::checked_static_cast<lm_info_frv *> (so.lm_info.get ());
int_elf32_fdpic_loadmap *map = li->map;
for (seg = 0; seg < map->nsegs; seg++)
for (struct so_list *so : current_program_space->solibs ())
{
int seg;
- auto *li = gdb::checked_static_cast<lm_info_frv *> (so->lm_info);
+ auto *li = gdb::checked_static_cast<lm_info_frv *> (so->lm_info.get ());
int_elf32_fdpic_loadmap *map = li->map;
for (seg = 0; seg < map->nsegs; seg++)
{
for (struct so_list *so : current_program_space->solibs ())
{
- auto *li = gdb::checked_static_cast<lm_info_frv *> (so->lm_info);
+ auto *li = gdb::checked_static_cast<lm_info_frv *> (so->lm_info.get ());
addr = find_canonical_descriptor_in_load_object
(entry_point, got_value, name, so->abfd, li);
of shared libraries. */
for (struct so_list *so : current_program_space->solibs ())
{
- auto *li = gdb::checked_static_cast<lm_info_frv *> (so->lm_info);
+ auto *li = gdb::checked_static_cast<lm_info_frv *> (so->lm_info.get ());
if (so->objfile == objfile)
return li->lm_addr;
return;
}
- auto *li = gdb::checked_static_cast<lm_info_svr4 *> (so.lm_info);
+ auto *li = gdb::checked_static_cast<lm_info_svr4 *> (so.lm_info.get ());
sec->addr = sec->addr + li->l_addr;
sec->endaddr = sec->endaddr + li->l_addr;
}
for (const rocm_so &so : sos)
{
so_list *newobj = new so_list;
- newobj->lm_info = new lm_info_svr4 (*so.lm_info);
+ newobj->lm_info = gdb::make_unique<lm_info_svr4> (*so.lm_info);
strncpy (newobj->so_name, so.name.c_str (), sizeof (newobj->so_name));
newobj->so_name[sizeof (newobj->so_name) - 1] = '\0';
static int
svr4_same (const so_list &gdb, const so_list &inferior)
{
- auto *lmg = gdb::checked_static_cast<const lm_info_svr4 *> (gdb.lm_info);
- auto *lmi = gdb::checked_static_cast<const lm_info_svr4 *> (inferior.lm_info);
+ auto *lmg
+ = gdb::checked_static_cast<const lm_info_svr4 *> (gdb.lm_info.get ());
+ auto *lmi
+ = gdb::checked_static_cast<const lm_info_svr4 *> (inferior.lm_info.get ());
return svr4_same (gdb.so_original_name, inferior.so_original_name,
*lmg, *lmi);
static CORE_ADDR
lm_addr_check (const so_list &so, bfd *abfd)
{
- auto *li = gdb::checked_static_cast<lm_info_svr4 *> (so.lm_info);
+ auto *li = gdb::checked_static_cast<lm_info_svr4 *> (so.lm_info.get ());
if (!li->l_addr_p)
{
static void
svr4_clear_so (const so_list &so)
{
- auto *li = gdb::checked_static_cast<lm_info_svr4 *> (so.lm_info);
+ auto *li = gdb::checked_static_cast<lm_info_svr4 *> (so.lm_info.get ());
if (li != NULL)
li->l_addr_p = 0;
sizeof (newobj->so_name) - 1);
newobj->so_name[sizeof (newobj->so_name) - 1] = 0;
strcpy (newobj->so_original_name, newobj->so_name);
- newobj->lm_info = new lm_info_svr4 (*so.lm_info);
+ newobj->lm_info = gdb::make_unique<lm_info_svr4> (*so.lm_info);
newobj->next = NULL;
*link = newobj;
return NULL;
so_list *newobj = new so_list;
- lm_info_svr4 *li = new lm_info_svr4;
- newobj->lm_info = li;
+ auto li = gdb::make_unique<lm_info_svr4> ();
/* Nothing will ever check the other fields if we set l_addr_p. */
li->l_addr = li->l_addr_inferior = info->debug_loader_offset;
li->l_addr_p = 1;
+ newobj->lm_info = std::move (li);
+
strncpy (newobj->so_name, info->debug_loader_name, SO_NAME_MAX_PATH_SIZE - 1);
newobj->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
strcpy (newobj->so_original_name, newobj->so_name);
[ 9] .dynamic DYNAMIC ffffffffff700580 000580 0000f0
*/
- auto *li = gdb::checked_static_cast<lm_info_svr4 *> (so->lm_info);
+ auto *li = gdb::checked_static_cast<lm_info_svr4 *> (so->lm_info.get ());
if (address_in_mem_range (li->l_ld, &vsyscall_range))
{
for (struct so_list *so : current_program_space->solibs ())
if (so->objfile == objfile)
{
- auto *li = gdb::checked_static_cast<lm_info_svr4 *> (so->lm_info);
+ auto *li
+ = gdb::checked_static_cast<lm_info_svr4 *> (so->lm_info.get ());
return li->lm_addr;
}
svr4_info *info = get_svr4_info (current_program_space);
gdb_assert (info != nullptr);
- const lm_info_svr4 *lm_info = (const lm_info_svr4 *) solib->lm_info;
+ auto *lm_info
+ = gdb::checked_static_cast<const lm_info_svr4 *> (solib->lm_info.get ());
for (const auto &tuple : info->solib_lists)
{
/* We no longer need this copy of the name. */
info->name.clear ();
- new_solib->lm_info = info.release ();
+ new_solib->lm_info = std::move (info);
/* Add it to the list. */
if (!start)
solib_target_relocate_section_addresses (so_list &so, target_section *sec)
{
CORE_ADDR offset;
- auto *li = gdb::checked_static_cast<lm_info_target *> (so.lm_info);
+ auto *li = gdb::checked_static_cast<lm_info_target *> (so.lm_info.get ());
/* Build the offset table only once per object file. We can not do
it any earlier, since we need to open the file first. */
free_so (so_list &so)
{
clear_so (so);
- delete so.lm_info;
delete &so;
}
virtual ~lm_info () = 0;
};
+using lm_info_up = std::unique_ptr<lm_info>;
+
struct so_list
{
/* The following fields of the structure come directly from the
will be a copy of struct link_map from the user process, but
it need not be; it can be any collection of data needed to
traverse the dynamic linker's data structures. */
- struct lm_info *lm_info = nullptr;
+ lm_info_up lm_info;
/* Shared object file name, exactly as it appears in the
inferior's link map. This may be a relative path, or something