binutils-gdb/gdb/solib-legacy.c

133 lines
4.5 KiB
C
Raw Normal View History

/* Provide legacy r_debug and link_map support for SVR4-like native targets.
2007-01-09 18:59:20 +01:00
Copyright (C) 2000, 2001, 2006, 2007 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
#include "gdbcore.h"
#include "solib-svr4.h"
#ifdef HAVE_LINK_H
#ifdef HAVE_NLIST_H
/* nlist.h needs to be included before link.h on some older *BSD systems. */
#include <nlist.h>
#endif
#include <link.h>
/* Fetch (and possibly build) an appropriate link_map_offsets structure
for native targets using struct definitions from link.h. */
static struct link_map_offsets *
legacy_svr4_fetch_link_map_offsets (void)
{
static struct link_map_offsets lmo;
static struct link_map_offsets *lmp = 0;
#if defined (HAVE_STRUCT_LINK_MAP32)
static struct link_map_offsets lmo32;
static struct link_map_offsets *lmp32 = 0;
#endif
#ifndef offsetof
#define offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER)
#endif
#define fieldsize(TYPE, MEMBER) (sizeof (((TYPE *)0)->MEMBER))
if (lmp == 0)
{
lmp = &lmo;
#ifdef HAVE_STRUCT_LINK_MAP_WITH_L_MEMBERS
lmo.r_version_offset = offsetof (struct r_debug, r_version);
lmo.r_version_size = fieldsize (struct r_debug, r_version);
lmo.r_map_offset = offsetof (struct r_debug, r_map);
lmo.r_ldsomap_offset = -1;
lmo.link_map_size = sizeof (struct link_map);
lmo.l_addr_offset = offsetof (struct link_map, l_addr);
lmo.l_next_offset = offsetof (struct link_map, l_next);
lmo.l_ld_offset = offsetof (struct link_map, l_ld);
lmo.l_prev_offset = offsetof (struct link_map, l_prev);
lmo.l_name_offset = offsetof (struct link_map, l_name);
#else /* !defined(HAVE_STRUCT_LINK_MAP_WITH_L_MEMBERS) */
#ifdef HAVE_STRUCT_LINK_MAP_WITH_LM_MEMBERS
lmo.link_map_size = sizeof (struct link_map);
lmo.l_addr_offset = offsetof (struct link_map, lm_addr);
lmo.l_next_offset = offsetof (struct link_map, lm_next);
/* FIXME: Is this the right field name, or is it available at all? */
lmo.l_ld_offset = offsetof (struct link_map, lm_ld);
lmo.l_name_offset = offsetof (struct link_map, lm_name);
#else /* !defined(HAVE_STRUCT_LINK_MAP_WITH_LM_MEMBERS) */
#if HAVE_STRUCT_SO_MAP_WITH_SOM_MEMBERS
lmo.link_map_size = sizeof (struct so_map);
lmo.l_addr_offset = offsetof (struct so_map, som_addr);
lmo.l_next_offset = offsetof (struct so_map, som_next);
lmo.l_name_offset = offsetof (struct so_map, som_path);
/* FIXME: Is the address of the dynamic table available? */
lmo.l_ld_offset = -1;
#endif /* HAVE_STRUCT_SO_MAP_WITH_SOM_MEMBERS */
#endif /* HAVE_STRUCT_LINK_MAP_WITH_LM_MEMBERS */
#endif /* HAVE_STRUCT_LINK_MAP_WITH_L_MEMBERS */
}
#if defined (HAVE_STRUCT_LINK_MAP32)
if (lmp32 == 0)
{
lmp32 = &lmo32;
lmo32.r_version_offset = offsetof (struct r_debug32, r_version);
lmo32.r_version_size = fieldsize (struct r_debug32, r_version);
lmo32.r_map_offset = offsetof (struct r_debug32, r_map);
lmo32.r_ldsomap_offset = -1;
lmo32.link_map_size = sizeof (struct link_map32);
lmo32.l_addr_offset = offsetof (struct link_map32, l_addr);
lmo32.l_next_offset = offsetof (struct link_map32, l_next);
lmo32.l_prev_offset = offsetof (struct link_map32, l_prev);
lmo32.l_name_offset = offsetof (struct link_map32, l_name);
}
#endif /* defined (HAVE_STRUCT_LINK_MAP32) */
#if defined (HAVE_STRUCT_LINK_MAP32)
if (exec_bfd != NULL)
{
if (bfd_get_arch_size (exec_bfd) == 32)
return lmp32;
}
if (gdbarch_ptr_bit (current_gdbarch) == 32)
return lmp32;
#endif
return lmp;
}
#endif /* HAVE_LINK_H */
2003-06-11 Andrew Cagney <cagney@redhat.com> * xstormy16-tdep.c (xstormy16_push_return_address): Make static. (xstormy16_save_dummy_frame_tos): Make static. (_initialize_xstormy16_tdep): Add declaration. * vax-tdep.c (_initialize_vax_tdep): Add declaration. * v850-tdep.c: Make local functions static. (_initialize_v850_tdep): Add declaration. * sparc-tdep.c: Make local functions static. (_initialize_sparc_tdep): Add declaration. * sh-tdep.c: Make local functions static. (_initialize_sh_tdep): Add declaration. * sh3-rom.c (_initialize_sh3_rom): Add declaration. * s390-tdep.c: Make local functions static. (_initialize_s390_tdep): Add declaration. * dbxread.c (find_stab_function_addr): Make static. * ppc-bdm.c (_initialize_bdm_ppc): Add declaration. * ocd.c (_initialize_remote_ocd): Add declaration. * dink32-rom.c (_initialize_dink32_rom): Add declaration. * ppcbug-rom.c (_initialize_ppcbug_rom): Add declaration. * ns32k-tdep.c (_initialize_ns32k_tdep): Add declaration. * ns32knbsd-tdep.c (_initialize_ns32knbsd_tdep): Add declaration. * mips-tdep.c (_initialize_mips_tdep): Add declaration. * remote-array.c (_initialize_array): Add declaration. (_initialize_remote_monitors): Add declaration. * remote-mips.c: Make local functions static. (_initialize_remote_mips): Add declaration. * mcore-tdep.c: Make all local functions static. (_initialize_mcore_tdep): Add declaration. * dbug-rom.c (_initialize_dbug_rom): Add declaration. * abug-rom.c (_initialize_abug_rom): Add declaration. * rom68k-rom.c (_initialize_rom68k): Add declaration. * cpu32bug-rom.c (_initialize_cpu32bug_rom): Add declaration. * m68k-tdep.c (_initialize_m68k_tdep): Add declaration. * remote-est.c (_initialize_est): Add declaration. * m68hc11-tdep.c (_initialize_m68hc11_tdep): Add declaration. (m68hc11_call_dummy_address): Make static. * ia64-tdep.c: Make local functions static. (_initialize_ia64_tdep): Add declaration. * solib-legacy.c (_initialize_svr4_lm): Add declaration. * monitor.c (monitor_wait_filter): Make static. (_initialize_remote_monitors): Add declaration. * remote-hms.c (_initialize_remote_hms): Add declaration. * remote-e7000.c (fetch_regs_from_dump): Make static. (expect_n): Make static. (_initialize_remote_e7000): Add declaration. * ser-e7kpc.c: Always include "defs.h". (_initialize_ser_e7000pc): Add declaration. * h8300-tdep.c (_initialize_h8300_tdep): Add declaration. * cris-tdep.c: Make all but one function static. (_initialize_cris_tdep): Add declaration. * solib-svr4.c (_initialize_svr4_solib): Add declaration. * solib.c (update_solib_list): Make static. (_initialize_solib): Add declaration. * avr-tdep.c (avr_breakpoint_from_pc): Make static. (_initialize_avr_tdep): Add declaration. * remote-rdi.c (voiddummy): Make static. (_initialize_remote_rdi): Add declaration. * arm-tdep.c (_initialize_arm_tdep): Add declaration. * remote-rdp.c (send_rdp): Make static. (_initialize_remote_rdp): Add declaration. * alpha-tdep.c (_initialize_alpha_tdep): Add declaration.
2003-06-11 15:16:30 +02:00
extern initialize_file_ftype _initialize_svr4_lm; /* -Wmissing-prototypes */
void
_initialize_svr4_lm (void)
{
#ifdef HAVE_LINK_H
legacy_svr4_fetch_link_map_offsets_hook = legacy_svr4_fetch_link_map_offsets;
#endif /* HAVE_LINK_H */
}