Cleanup solib-svr4.c by moving legacy code out to its own file.

This commit is contained in:
Kevin Buettner 2001-03-10 06:17:24 +00:00
parent d7fa9de08d
commit 21479deda0
40 changed files with 295 additions and 141 deletions

View File

@ -1,3 +1,67 @@
2001-03-09 Kevin Buettner <kevinb@redhat.com>
* Makefile.in (solib-svr4.o): Depend on solib-svr4.c, not solib.c.
(solib-legacy.o): New makefile target.
* solib-legacy.c: New file.
* solib-svr4.h (SVR4_FETCH_LINK_MAP_OFFSETS): Delete.
(default_svr4_fetch_link_map_offsets): Delete.
(set_solib_svr4_fetch_link_map_offsets): Declare.
(legacy_svr4_fetch_link_map_offsets_hook): Declare.
* solib-svr4.c (elf/common.h): Include.
(link.h): Only include for SunOS shared library support.
(_SYSCALL32): Don't define.
(SVR4_FETCH_LINK_MAP_OFFSETS): Define.
(default_svr4_fetch_link_map_offsets): Made static; added forward
declaration.
(fetch_link_map_offsets): New static global.
(legacy_svr4_fetch_link_map_offsets_hook): New global variable.
(default_svr4_fetch_link_map_offsets): Rewritten. The guts
of what used to be in this function now reside in
legacy_svr4_fetch_link_map_offsets() in solib-legacy.c.
(open_symbol_file_object): Fix declaration in SunOS section
of the code.
(set_solib_svr4_fetch_link_map_offsets): New extern function.
(init_fetch_link_map_offsets): New static function.
(_initialize_svr4_solib): Put static global fetch_link_map_offsets
under multiarch control.
* config/alpha/alpha-linux.mt (TDEPFILES): Add solib-legacy.o to
list.
* config/alpha/fbsd.mh (NATDEPFILES): Likewise.
* config/arm/linux.mt (TDEPFILES): Likewise.
* config/i386/fbsd.mh (NATDEPFILES): Likewise.
* config/i386/i386dgux.mh (NATDEPFILES): Likewise.
* config/i386/i386gnu.mh (NATDEPFILES): Likewise.
* config/i386/i386sco5.mh (NATDEPFILES): Likewise.
* config/i386/i386sol2.mt (TDEPFILES): Likewise.
* config/i386/i386v4.mh (NATDEPFILES): Likewise.
* config/i386/i386v42mp.mh (NATDEPFILES): Likewise.
* config/i386/linux.mt (TDEPFILES): Likewise.
* config/i386/nbsd.mh (NATDEPFILES): Likewise.
* config/i386/nbsdelf.mh (NATDEPFILES): Likewise.
* config/i386/ncr3000.mt (TDEPFILES): Likewise.
* config/i386/ptx4.mh (XDEPFILES): Likewise.
* config/i386/sun386.mt (TDEPFILES): Likewise.
* config/ia64/linux.mt (TDEPFILES): Likewise.
* config/m68k/linux.mt (TDEPFILES): Likewise.
* config/m68k/m68kv4.mh (NATDEPFILES): Likewise.
* config/m68k/nbsd.mh (NATDEPFILES): Likewise.
* config/m68k/sun2os4.mt (TDEPFILES): Likewise.
* config/m68k/sun3os4.mt (TDEPFILES): Likewise.
* config/m88k/delta88v4.mh (NATDEPFILES): Likewise.
* config/mips/mipsv4.mh (NATDEPFILES): Likewise.
* config/ns32k/nbsd.mh (NATDEPFILES): Likewise.
* config/powerpc/linux.mt (TDEPFILES): Likewise.
* config/powerpc/nbsd.mh (NATDEPFILES): Likewise.
* config/powerpc/solaris.mh (NATDEPFILES): Likewise.
* config/sh/linux.mt (TDEPFILES): Likewise.
* config/sparc/linux.mt (TDEPFILES): Likewise.
* config/sparc/nbsd.mh (NATDEPFILES): Likewise.
* config/sparc/nbsdelf.mh (NATDEPFILES): Likewise.
* config/sparc/sp64linux.mt (TDEPFILES): Likewise.
* config/sparc/sun4os4.mt (TDEPFILES): Likewise.
* config/sparc/sun4sol2.mh (NATDEPFILES): Likewise.
2001-03-09 Kevin Buettner <kevinb@redhat.com>
* utils.c (xmrealloc, xcalloc): Return NULL for zero-sized requests.

View File

@ -1905,10 +1905,12 @@ mon960-rom.o: mon960-rom.c monitor.h $(bfd_h) gdb_wait.h $(defs_h) $(gdbcmd_h) \
solib.o: solib.c $(command_h) $(defs_h) $(gdbcore_h) $(inferior_h) \
objfiles.h gnu-regex.h symfile.h target.h gdb_string.h solist.h
solib-svr4.o: solib.c $(command_h) $(defs_h) $(gdbcore_h) $(inferior_h) \
solib-svr4.o: solib-svr4.c $(command_h) $(defs_h) $(gdbcore_h) $(inferior_h) \
objfiles.h gnu-regex.h symfile.h target.h gdb_string.h solist.h \
solib-svr4.h $(regcache_h)
solib-legacy.o: solib-legacy.c $(defs_h) $(gdbcore_h) solib-svr4.h
source.o: source.c $(defs_h) $(expression_h) $(frame_h) $(gdbcmd_h) \
$(gdbcore_h) language.h objfiles.h gnu-regex.h symfile.h $(symtab_h) \
gdb_string.h source.h completer.h linespec.h

View File

@ -1,3 +1,3 @@
# Target: Little-endian Alpha
TDEPFILES= alpha-tdep.o solib.o solib-svr4.o
TDEPFILES= alpha-tdep.o solib.o solib-svr4.o solib-legacy.o
TM_FILE= tm-alphalinux.h

View File

@ -1,6 +1,7 @@
# Host: FreeBSD/Alpha
XDEPFILES=
NATDEPFILES= fork-child.o infptrace.o inftarg.o solib.o solib-svr4.o \
NATDEPFILES= fork-child.o infptrace.o inftarg.o \
solib.o solib-svr4.o solib-legacy.o \
corelow.o core-regset.o alphabsd-nat.o
XM_FILE= xm-fbsd.h
NAT_FILE= nm-fbsd.h

View File

@ -1,5 +1,5 @@
# Target: ARM based machine running GNU/Linux
TM_FILE= tm-linux.h
TDEPFILES= arm-tdep.o arm-linux-tdep.o solib.o solib-svr4.o
TDEPFILES= arm-tdep.o arm-linux-tdep.o solib.o solib-svr4.o solib-legacy.o
GDBSERVER_DEPFILES= low-linux.o

View File

@ -1,6 +1,6 @@
# Host: Intel 386 running FreeBSD
XDEPFILES=
# NOTE: Do not spread NATDEPFILES over several lines - it hurts BSD make.
NATDEPFILES= fork-child.o infptrace.o inftarg.o solib.o solib-svr4.o corelow.o core-aout.o core-regset.o i387-nat.o i386bsd-nat.o
NATDEPFILES= fork-child.o infptrace.o inftarg.o solib.o solib-svr4.o solib-legacy.o corelow.o core-aout.o core-regset.o i387-nat.o i386bsd-nat.o
XM_FILE= xm-fbsd.h
NAT_FILE= nm-fbsd.h

View File

@ -6,5 +6,6 @@ XDEPFILES=
XM_CLIBS= -lsocket -lnsl
NAT_FILE= nm-i386v4.h
NATDEPFILES= corelow.o core-regset.o solib.o solib-svr4.o fork-child.o i386v4-nat.o \
NATDEPFILES= corelow.o core-regset.o fork-child.o i386v4-nat.o \
solib.o solib-svr4.o solib-legacy.o \
procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o

View File

@ -1,6 +1,6 @@
# Host: Intel 386 running the GNU Hurd
XDEPFILES= i387-tdep.o
NATDEPFILES= i386gnu-nat.o gnu-nat.o fork-child.o solib.o solib-svr4.o corelow.o notify_S.o process_reply_S.o msg_reply_S.o msg_U.o exc_request_U.o exc_request_S.o
NATDEPFILES= i386gnu-nat.o gnu-nat.o fork-child.o solib.o solib-svr4.o solib-legacy.o corelow.o notify_S.o process_reply_S.o msg_reply_S.o msg_U.o exc_request_U.o exc_request_S.o
XM_FILE= xm-i386gnu.h
NAT_FILE= nm-gnu.h
MH_CFLAGS = -D_GNU_SOURCE

View File

@ -13,5 +13,5 @@ XM_CLIBS= -lPW -lsocket
NAT_FILE= nm-i386sco5.h
NATDEPFILES= infptrace.o inftarg.o fork-child.o corefile.o core-aout.o \
corelow.o i386v-nat.o solib.o solib-svr4.o
corelow.o i386v-nat.o solib.o solib-svr4.o solib-legacy.o

View File

@ -1,3 +1,3 @@
# Target: Intel 386 running SVR4
TDEPFILES= i386-tdep.o i387-tdep.o solib.o solib-svr4.o
TDEPFILES= i386-tdep.o i387-tdep.o solib.o solib-svr4.o solib-legacy.o
TM_FILE= tm-i386sol2.h

View File

@ -6,5 +6,6 @@ XDEPFILES=
XM_CLIBS= -lsocket -lnsl
NAT_FILE= nm-i386v4.h
NATDEPFILES= corelow.o core-regset.o solib.o solib-svr4.o fork-child.o i386v4-nat.o \
NATDEPFILES= corelow.o core-regset.o fork-child.o i386v4-nat.o \
solib.o solib-svr4.o solib-legacy.o \
procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o

View File

@ -8,6 +8,7 @@ XM_CLIBS= -lsocket -lnsl
# we don't want nm-i386v4.h since that defines LOSING_POLL which isn't
# appropriate for i386v42mp
NAT_FILE= nm-i386v42mp.h
NATDEPFILES= corelow.o core-regset.o solib.o solib-svr4.o fork-child.o i386v4-nat.o \
NATDEPFILES= corelow.o core-regset.o fork-child.o i386v4-nat.o \
solib.o solib-svr4.o solib-legacy.o \
procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o uw-thread.o

View File

@ -1,5 +1,6 @@
# Target: Intel 386 running GNU/Linux
TDEPFILES= i386-tdep.o i386-linux-tdep.o i387-tdep.o solib.o solib-svr4.o
TDEPFILES= i386-tdep.o i386-linux-tdep.o i387-tdep.o \
solib.o solib-svr4.o solib-legacy.o
TM_FILE= tm-linux.h
GDBSERVER_DEPFILES= low-linux.o

View File

@ -1,5 +1,6 @@
# Host: Intel 386 running NetBSD
XDEPFILES=
NATDEPFILES= fork-child.o infptrace.o inftarg.o corelow.o i386nbsd-nat.o solib.o solib-svr4.o
NATDEPFILES= fork-child.o infptrace.o inftarg.o corelow.o i386nbsd-nat.o \
solib.o solib-svr4.o solib-legacy.o
XM_FILE= xm-nbsd.h
NAT_FILE= nm-nbsd.h

View File

@ -1,5 +1,5 @@
# Host: Intel 386 running NetBSD
XDEPFILES=
NATDEPFILES= fork-child.o infptrace.o inftarg.o corelow.o i386nbsd-nat.o solib.o solib-svr4.o
NATDEPFILES= fork-child.o infptrace.o inftarg.o corelow.o i386nbsd-nat.o solib.o solib-svr4.o solib-legacy.o
XM_FILE= xm-nbsd.h
NAT_FILE= nm-nbsdelf.h

View File

@ -1,3 +1,3 @@
# Target: Intel 386 running SVR4
TDEPFILES= i386-tdep.o i387-tdep.o solib.o solib-svr4.o
TDEPFILES= i386-tdep.o i387-tdep.o solib.o solib-svr4.o solib-legacy.o
TM_FILE= tm-i386v4.h

View File

@ -1,7 +1,8 @@
# Host: Sequent Symmetry running ptx 1.3, with Weitek 1167 or i387
XM_FILE= xm-ptx4.h
XDEPFILES= inftarg.o fork-child.o symm-nat.o corelow.o core-aout.o solib.o solib-svr4.o core-regset.o
XDEPFILES= inftarg.o fork-child.o symm-nat.o corelow.o core-aout.o \
core-regset.o solib.o solib-svr4.o solib-legacy.o
XM_CLIBS= -lseq
NAT_FILE= nm-ptx4.h

View File

@ -1,3 +1,3 @@
# Target: Sun 386i target configuration file.
TDEPFILES= i386-tdep.o solib.o solib-svr4.o
TDEPFILES= i386-tdep.o solib.o solib-svr4.o solib-legacy.o
TM_FILE= tm-sun386.h

View File

@ -1,5 +1,6 @@
# Target: Intel IA-64 running GNU/Linux
TDEPFILES= ia64-tdep.o ia64-aix-tdep.o ia64-linux-tdep.o solib.o solib-svr4.o
TDEPFILES= ia64-tdep.o ia64-aix-tdep.o ia64-linux-tdep.o \
solib.o solib-svr4.o solib-legacy.o
TM_FILE= tm-linux.h
GDBSERVER_DEPFILES= low-linux.o

View File

@ -1,3 +1,3 @@
# Target: Motorola m68k with a.out and ELF
TDEPFILES= m68k-tdep.o solib.o solib-svr4.o
TDEPFILES= m68k-tdep.o solib.o solib-svr4.o solib-legacy.o
TM_FILE= tm-linux.h

View File

@ -4,5 +4,5 @@ XM_FILE= xm-m68kv4.h
XDEPFILES=
NAT_FILE= nm-sysv4.h
NATDEPFILES= corelow.o core-regset.o solib.o solib-svr4.o fork-child.o procfs.o \
proc-api.o proc-events.o proc-flags.o proc-why.o
NATDEPFILES= corelow.o core-regset.o solib.o solib-svr4.o solib-legacy.o \
fork-child.o procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o

View File

@ -1,5 +1,5 @@
# Host: Motorola m68k running NetBSD
XDEPFILES=
NATDEPFILES= infptrace.o inftarg.o fork-child.o corelow.o m68knbsd-nat.o solib.o solib-svr4.o
NATDEPFILES= infptrace.o inftarg.o fork-child.o corelow.o m68knbsd-nat.o solib.o solib-svr4.o solib-legacy.o
XM_FILE= xm-nbsd.h
NAT_FILE= nm-nbsd.h

View File

@ -1,3 +1,3 @@
# Target: Sun 2, running SunOS 4
TDEPFILES= solib.o solib-svr4.o m68k-tdep.o
TDEPFILES= solib.o solib-svr4.o solib-legacy.o m68k-tdep.o
TM_FILE= tm-sun2os4.h

View File

@ -1,3 +1,3 @@
# Target: Sun 3, running SunOS 4, as a target system
TDEPFILES= solib.o solib-svr4.o m68k-tdep.o
TDEPFILES= solib.o solib-svr4.o solib-legacy.o m68k-tdep.o
TM_FILE= tm-sun3os4.h

View File

@ -4,5 +4,6 @@ XM_FILE= xm-delta88v4.h
XDEPFILES=
NAT_FILE= nm-delta88v4.h
NATDEPFILES= fork-child.o m88k-nat.o corelow.o core-regset.o solib.o solib-svr4.o \
NATDEPFILES= fork-child.o m88k-nat.o corelow.o core-regset.o \
solib.o solib-svr4.o solib-legacy.o \
procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o

View File

@ -1,5 +1,6 @@
# Host: Mips running SVR4
XM_FILE= xm-mipsv4.h
NAT_FILE= ../nm-sysv4.h
NATDEPFILES= fork-child.o mipsv4-nat.o corelow.o core-regset.o solib.o solib-svr4.o \
NATDEPFILES= fork-child.o mipsv4-nat.o corelow.o core-regset.o \
solib.o solib-svr4.o solib-legacy.o \
procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o

View File

@ -1,5 +1,5 @@
# Host: PC532 running NetBSD
XDEPFILES=
NATDEPFILES= fork-child.o infptrace.o inftarg.o corelow.o ns32knbsd-nat.o solib.o solib-svr4.o
NATDEPFILES= fork-child.o infptrace.o inftarg.o corelow.o ns32knbsd-nat.o solib.o solib-svr4.o solib-legacy.o
XM_FILE= xm-nbsd.h
NAT_FILE= nm-nbsd.h

View File

@ -1,3 +1,3 @@
# Target: Motorola PPC on Linux
TDEPFILES= rs6000-tdep.o ppc-linux-tdep.o solib.o solib-svr4.o
TDEPFILES= rs6000-tdep.o ppc-linux-tdep.o solib.o solib-svr4.o solib-legacy.o
TM_FILE= tm-linux.h

View File

@ -1,5 +1,5 @@
# Host: PowerPC, running NetBSD
XDEPFILES=
NATDEPFILES= fork-child.o infptrace.o inftarg.o corelow.o ppcnbsd-nat.o solib.o solib-svr4.o
NATDEPFILES= fork-child.o infptrace.o inftarg.o corelow.o ppcnbsd-nat.o solib.o solib-svr4.o solib-legacy.o
XM_FILE= xm-nbsd.h
NAT_FILE= nm-nbsd.h

View File

@ -5,8 +5,8 @@ XDEPFILES=
XM_CLIBS= -lsocket -lnsl
NAT_FILE= nm-solaris.h
NATDEPFILES= corelow.o core-sol2.o solib.o solib-svr4.o fork-child.o procfs.o \
proc-api.o proc-events.o proc-flags.o proc-why.o
NATDEPFILES= corelow.o core-sol2.o solib.o solib-svr4.o solib-legacy.o \
fork-child.o procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o
# If you are compiling with Sun's compiler, add the -xs option to CC
# (e.g. `make CC="cc -xs"').

View File

@ -1,5 +1,5 @@
# Target: Hitachi Super-H running GNU/Linux
TDEPFILES= sh-tdep.o monitor.o sh3-rom.o remote-e7000.o ser-e7kpc.o dsrec.o solib.o solib-svr4.o
TDEPFILES= sh-tdep.o monitor.o sh3-rom.o remote-e7000.o ser-e7kpc.o dsrec.o solib.o solib-svr4.o solib-legacy.o
TM_FILE= tm-linux.h
SIM_OBS = remote-sim.o

View File

@ -1,3 +1,3 @@
# Target: Sparcstation, running Linux
TDEPFILES= sparc-tdep.o solib.o solib-svr4.o
TDEPFILES= sparc-tdep.o solib.o solib-svr4.o solib-legacy.o
TM_FILE= tm-linux.h

View File

@ -1,6 +1,6 @@
# Host: Sun 4 or Sparcstation, running NetBSD
XDEPFILES=
NATDEPFILES= fork-child.o infptrace.o inftarg.o corelow.o sparc-nat.o solib.o solib-svr4.o
NATDEPFILES= fork-child.o infptrace.o inftarg.o corelow.o sparc-nat.o solib.o solib-svr4.o solib-legacy.o
XM_FILE= xm-nbsd.h
NAT_FILE= nm-nbsd.h
HOST_IPC=-DBSD_IPC

View File

@ -1,6 +1,6 @@
# Host: Sun 4 or Sparcstation, running NetBSD
XDEPFILES=
NATDEPFILES= fork-child.o infptrace.o inftarg.o corelow.o sparc-nat.o solib.o solib-svr4.o
NATDEPFILES= fork-child.o infptrace.o inftarg.o corelow.o sparc-nat.o solib.o solib-svr4.o solib-legacy.o
XM_FILE= xm-nbsd.h
NAT_FILE= nm-nbsdelf.h
HOST_IPC=-DBSD_IPC

View File

@ -1,3 +1,3 @@
# Target: UltraSPARC, running Linux 64bit programs
TDEPFILES= sparc-tdep.o solib.o solib-svr4.o
TDEPFILES= sparc-tdep.o solib.o solib-svr4.o solib-legacy.o
TM_FILE= tm-sp64linux.h

View File

@ -1,3 +1,3 @@
# Target: Sun 4 or Sparcstation, running SunOS 4
TDEPFILES= sparc-tdep.o solib.o solib-svr4.o
TDEPFILES= sparc-tdep.o solib.o solib-svr4.o solib-legacy.o
TM_FILE= tm-sun4os4.h

View File

@ -5,8 +5,8 @@ XDEPFILES=
XM_CLIBS= -lsocket -lnsl
NAT_FILE= nm-sun4sol2.h
NATDEPFILES= corelow.o core-sol2.o solib.o solib-svr4.o fork-child.o procfs.o \
proc-api.o proc-events.o proc-flags.o proc-why.o
NATDEPFILES= corelow.o core-sol2.o solib.o solib-svr4.o solib-legacy.o \
fork-child.o procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o
# /usr/include/v9 is needed only by core-sol2.c when including
# v9/sys/privregs.h, or rather the headers it in turn includes.

127
gdb/solib-legacy.c Normal file
View File

@ -0,0 +1,127 @@
/* Provide legacy r_debug and link_map support for SVR4-like native targets.
Copyright 2000, 2001
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 2 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, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#define _SYSCALL32 /* for Sparc64 cross Sparc32 */
#include "defs.h"
#include "gdbcore.h"
#include "solib-svr4.h"
#ifdef HAVE_LINK_H
#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 SVR4_SHARED_LIBS
lmo.r_debug_size = sizeof (struct r_debug);
lmo.r_map_offset = offsetof (struct r_debug, r_map);
lmo.r_map_size = fieldsize (struct r_debug, r_map);
lmo.link_map_size = sizeof (struct link_map);
lmo.l_addr_offset = offsetof (struct link_map, l_addr);
lmo.l_addr_size = fieldsize (struct link_map, l_addr);
lmo.l_next_offset = offsetof (struct link_map, l_next);
lmo.l_next_size = fieldsize (struct link_map, l_next);
lmo.l_prev_offset = offsetof (struct link_map, l_prev);
lmo.l_prev_size = fieldsize (struct link_map, l_prev);
lmo.l_name_offset = offsetof (struct link_map, l_name);
lmo.l_name_size = fieldsize (struct link_map, l_name);
#else /* !SVR4_SHARED_LIBS */
lmo.link_map_size = sizeof (struct link_map);
lmo.l_addr_offset = offsetof (struct link_map, lm_addr);
lmo.l_addr_size = fieldsize (struct link_map, lm_addr);
lmo.l_next_offset = offsetof (struct link_map, lm_next);
lmo.l_next_size = fieldsize (struct link_map, lm_next);
lmo.l_name_offset = offsetof (struct link_map, lm_name);
lmo.l_name_size = fieldsize (struct link_map, lm_name);
#endif /* SVR4_SHARED_LIBS */
}
#if defined (HAVE_STRUCT_LINK_MAP32)
if (lmp32 == 0)
{
lmp32 = &lmo32;
lmo32.r_debug_size = sizeof (struct r_debug32);
lmo32.r_map_offset = offsetof (struct r_debug32, r_map);
lmo32.r_map_size = fieldsize (struct r_debug32, r_map);
lmo32.link_map_size = sizeof (struct link_map32);
lmo32.l_addr_offset = offsetof (struct link_map32, l_addr);
lmo32.l_addr_size = fieldsize (struct link_map32, l_addr);
lmo32.l_next_offset = offsetof (struct link_map32, l_next);
lmo32.l_next_size = fieldsize (struct link_map32, l_next);
lmo32.l_prev_offset = offsetof (struct link_map32, l_prev);
lmo32.l_prev_size = fieldsize (struct link_map32, l_prev);
lmo32.l_name_offset = offsetof (struct link_map32, l_name);
lmo32.l_name_size = fieldsize (struct link_map32, l_name);
}
#endif /* defined (HAVE_STRUCT_LINK_MAP32) */
#if defined (HAVE_STRUCT_LINK_MAP32)
if (bfd_get_arch_size (exec_bfd) == 32)
return lmp32;
else
#endif
return lmp;
}
#endif /* HAVE_LINK_H */
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 */
}

View File

@ -20,7 +20,6 @@
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#define _SYSCALL32 /* for Sparc64 cross Sparc32 */
#include "defs.h"
#include "regcache.h"
@ -34,12 +33,10 @@
#ifndef SVR4_SHARED_LIBS
/* SunOS shared libs need the nlist structure. */
#include <a.out.h>
#include <link.h>
#else
#include "elf/external.h"
#endif
#ifdef HAVE_LINK_H
#include <link.h>
#include "elf/common.h"
#endif
#include "symtab.h"
@ -59,6 +56,19 @@
#include "solist.h"
#include "solib-svr4.h"
#ifndef SVR4_FETCH_LINK_MAP_OFFSETS
#define SVR4_FETCH_LINK_MAP_OFFSETS() fetch_link_map_offsets ()
#endif
static struct link_map_offsets *default_svr4_fetch_link_map_offsets (void);
static struct link_map_offsets *(*fetch_link_map_offsets)(void) =
default_svr4_fetch_link_map_offsets;
/* legacy_svr4_fetch_link_map_offsets_hook is a pointer to a function
which is used to fetch link map offsets. It will only be set
by solib-legacy.c, if at all. */
struct link_map_offsets *(*legacy_svr4_fetch_link_map_offsets_hook)(void) = 0;
/* Link map info to include in an allocated so_list entry */
struct lm_info
@ -122,101 +132,24 @@ static char *main_name_list[] =
/* Fetch (and possibly build) an appropriate link_map_offsets structure
for native targets using struct definitions from link.h. */
for native targets using struct definitions from link.h.
Note: For non-native targets (i.e. cross-debugging situations),
you need to define a target specific fetch_link_map_offsets()
function and call set_solib_svr4_fetch_link_map_offsets () to
register this function. */
struct link_map_offsets *
static struct link_map_offsets *
default_svr4_fetch_link_map_offsets (void)
{
#ifdef HAVE_LINK_H
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 SVR4_SHARED_LIBS
lmo.r_debug_size = sizeof (struct r_debug);
lmo.r_map_offset = offsetof (struct r_debug, r_map);
lmo.r_map_size = fieldsize (struct r_debug, r_map);
lmo.link_map_size = sizeof (struct link_map);
lmo.l_addr_offset = offsetof (struct link_map, l_addr);
lmo.l_addr_size = fieldsize (struct link_map, l_addr);
lmo.l_next_offset = offsetof (struct link_map, l_next);
lmo.l_next_size = fieldsize (struct link_map, l_next);
lmo.l_prev_offset = offsetof (struct link_map, l_prev);
lmo.l_prev_size = fieldsize (struct link_map, l_prev);
lmo.l_name_offset = offsetof (struct link_map, l_name);
lmo.l_name_size = fieldsize (struct link_map, l_name);
#else /* !SVR4_SHARED_LIBS */
lmo.link_map_size = sizeof (struct link_map);
lmo.l_addr_offset = offsetof (struct link_map, lm_addr);
lmo.l_addr_size = fieldsize (struct link_map, lm_addr);
lmo.l_next_offset = offsetof (struct link_map, lm_next);
lmo.l_next_size = fieldsize (struct link_map, lm_next);
lmo.l_name_offset = offsetof (struct link_map, lm_name);
lmo.l_name_size = fieldsize (struct link_map, lm_name);
#endif /* SVR4_SHARED_LIBS */
}
#if defined (HAVE_STRUCT_LINK_MAP32)
if (lmp32 == 0)
{
lmp32 = &lmo32;
lmo32.r_debug_size = sizeof (struct r_debug32);
lmo32.r_map_offset = offsetof (struct r_debug32, r_map);
lmo32.r_map_size = fieldsize (struct r_debug32, r_map);
lmo32.link_map_size = sizeof (struct link_map32);
lmo32.l_addr_offset = offsetof (struct link_map32, l_addr);
lmo32.l_addr_size = fieldsize (struct link_map32, l_addr);
lmo32.l_next_offset = offsetof (struct link_map32, l_next);
lmo32.l_next_size = fieldsize (struct link_map32, l_next);
lmo32.l_prev_offset = offsetof (struct link_map32, l_prev);
lmo32.l_prev_size = fieldsize (struct link_map32, l_prev);
lmo32.l_name_offset = offsetof (struct link_map32, l_name);
lmo32.l_name_size = fieldsize (struct link_map32, l_name);
}
#endif /* defined (HAVE_STRUCT_LINK_MAP32) */
#if defined (HAVE_STRUCT_LINK_MAP32)
if (bfd_get_arch_size (exec_bfd) == 32)
return lmp32;
if (legacy_svr4_fetch_link_map_offsets_hook)
return legacy_svr4_fetch_link_map_offsets_hook ();
else
#endif
return lmp;
#else
internal_error (__FILE__, __LINE__,
"default_svr4_fetch_link_map_offsets called without HAVE_LINK_H defined.");
return 0;
#endif /* HAVE_LINK_H */
{
internal_error (__FILE__, __LINE__,
"default_svr4_fetch_link_map_offsets called without legacy link_map support enabled.");
return 0;
}
}
/* Macro to extract an address from a solib structure.
@ -951,7 +884,7 @@ open_symbol_file_object (void *from_ttyp)
#else
static int
open_symbol_file_object (int *from_ttyp)
open_symbol_file_object (void *from_ttyp)
{
return 1;
}
@ -1688,11 +1621,27 @@ svr4_relocate_section_addresses (struct so_list *so,
sec->endaddr += LM_ADDR (so);
}
void
set_solib_svr4_fetch_link_map_offsets (struct link_map_offsets *(*flmo) (void))
{
fetch_link_map_offsets = flmo;
}
static void
init_fetch_link_map_offsets (void)
{
set_solib_svr4_fetch_link_map_offsets (default_svr4_fetch_link_map_offsets);
}
static struct target_so_ops svr4_so_ops;
void
_initialize_svr4_solib (void)
{
register_gdbarch_swap (&fetch_link_map_offsets,
sizeof (fetch_link_map_offsets),
init_fetch_link_map_offsets);
svr4_so_ops.relocate_section_addresses = svr4_relocate_section_addresses;
svr4_so_ops.free_so = svr4_free_so;
svr4_so_ops.clear_solib = svr4_clear_solib;
@ -1700,7 +1649,6 @@ _initialize_svr4_solib (void)
svr4_so_ops.special_symbol_handling = svr4_special_symbol_handling;
svr4_so_ops.current_sos = svr4_current_sos;
svr4_so_ops.open_symbol_file_object = open_symbol_file_object;
svr4_so_ops.open_symbol_file_object = open_symbol_file_object;
svr4_so_ops.in_dynsym_resolve_code = svr4_in_dynsym_resolve_code;
/* FIXME: Don't do this here. *_gdbarch_init() should set so_ops. */

View File

@ -64,7 +64,10 @@ struct link_map_offsets
int l_name_size;
};
#ifndef SVR4_FETCH_LINK_MAP_OFFSETS
extern struct link_map_offsets *default_svr4_fetch_link_map_offsets (void);
#define SVR4_FETCH_LINK_MAP_OFFSETS() default_svr4_fetch_link_map_offsets ()
#endif
extern void set_solib_svr4_fetch_link_map_offsets (
struct link_map_offsets *(*func) (void));
/* legacy_svr4_fetch_link_map_offsets_hook is a pointer to a function
which is used to fetch link map offsets. It will only be set
by solib-legacy.c, if at all. */
extern struct link_map_offsets *(*legacy_svr4_fetch_link_map_offsets_hook)(void);