1 /* Handle SunOS and SVR4 shared libraries for GDB, the GNU Debugger.
2 Copyright 1990, 91, 92, 93, 94, 95, 96, 98, 1999, 2000
3 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 #define _SYSCALL32 /* for Sparc64 cross Sparc32 */
26 #include <sys/types.h>
28 #include "gdb_string.h"
29 #include <sys/param.h>
32 #ifndef SVR4_SHARED_LIBS
33 /* SunOS shared libs need the nlist structure. */
36 #include "elf/external.h"
51 #include "gdb_regex.h"
58 #include "solib-svr4.h"
60 /* Link map info to include in an allocated so_list entry */
64 /* Pointer to copy of link map from inferior. The type is char *
65 rather than void *, so that we may use byte offsets to find the
66 various fields without the need for a cast. */
70 /* On SVR4 systems, a list of symbols in the dynamic linker where
71 GDB can try to place a breakpoint to monitor shared library
74 If none of these symbols are found, or other errors occur, then
75 SVR4 systems will fall back to using a symbol as the "startup
76 mapping complete" breakpoint address. */
78 #ifdef SVR4_SHARED_LIBS
79 static char *solib_break_names
[] =
90 #define BKPT_AT_SYMBOL 1
92 #if defined (BKPT_AT_SYMBOL) && defined (SVR4_SHARED_LIBS)
93 static char *bkpt_names
[] =
95 #ifdef SOLIB_BKPT_NAME
96 SOLIB_BKPT_NAME
, /* Prefer configured name if it exists. */
104 /* Symbols which are used to locate the base of the link map structures. */
106 #ifndef SVR4_SHARED_LIBS
107 static char *debug_base_symbols
[] =
115 static char *main_name_list
[] =
122 /* Fetch (and possibly build) an appropriate link_map_offsets structure
123 for native targets using struct definitions from link.h. */
125 struct link_map_offsets
*
126 default_svr4_fetch_link_map_offsets (void)
129 static struct link_map_offsets lmo
;
130 static struct link_map_offsets
*lmp
= 0;
131 #if defined (HAVE_STRUCT_LINK_MAP32)
132 static struct link_map_offsets lmo32
;
133 static struct link_map_offsets
*lmp32
= 0;
137 #define offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER)
139 #define fieldsize(TYPE, MEMBER) (sizeof (((TYPE *)0)->MEMBER))
145 #ifdef SVR4_SHARED_LIBS
146 lmo
.r_debug_size
= sizeof (struct r_debug
);
148 lmo
.r_map_offset
= offsetof (struct r_debug
, r_map
);
149 lmo
.r_map_size
= fieldsize (struct r_debug
, r_map
);
151 lmo
.link_map_size
= sizeof (struct link_map
);
153 lmo
.l_addr_offset
= offsetof (struct link_map
, l_addr
);
154 lmo
.l_addr_size
= fieldsize (struct link_map
, l_addr
);
156 lmo
.l_next_offset
= offsetof (struct link_map
, l_next
);
157 lmo
.l_next_size
= fieldsize (struct link_map
, l_next
);
159 lmo
.l_prev_offset
= offsetof (struct link_map
, l_prev
);
160 lmo
.l_prev_size
= fieldsize (struct link_map
, l_prev
);
162 lmo
.l_name_offset
= offsetof (struct link_map
, l_name
);
163 lmo
.l_name_size
= fieldsize (struct link_map
, l_name
);
164 #else /* !SVR4_SHARED_LIBS */
165 lmo
.link_map_size
= sizeof (struct link_map
);
167 lmo
.l_addr_offset
= offsetof (struct link_map
, lm_addr
);
168 lmo
.l_addr_size
= fieldsize (struct link_map
, lm_addr
);
170 lmo
.l_next_offset
= offsetof (struct link_map
, lm_next
);
171 lmo
.l_next_size
= fieldsize (struct link_map
, lm_next
);
173 lmo
.l_name_offset
= offsetof (struct link_map
, lm_name
);
174 lmo
.l_name_size
= fieldsize (struct link_map
, lm_name
);
175 #endif /* SVR4_SHARED_LIBS */
178 #if defined (HAVE_STRUCT_LINK_MAP32)
183 lmo32
.r_debug_size
= sizeof (struct r_debug32
);
185 lmo32
.r_map_offset
= offsetof (struct r_debug32
, r_map
);
186 lmo32
.r_map_size
= fieldsize (struct r_debug32
, r_map
);
188 lmo32
.link_map_size
= sizeof (struct link_map32
);
190 lmo32
.l_addr_offset
= offsetof (struct link_map32
, l_addr
);
191 lmo32
.l_addr_size
= fieldsize (struct link_map32
, l_addr
);
193 lmo32
.l_next_offset
= offsetof (struct link_map32
, l_next
);
194 lmo32
.l_next_size
= fieldsize (struct link_map32
, l_next
);
196 lmo32
.l_prev_offset
= offsetof (struct link_map32
, l_prev
);
197 lmo32
.l_prev_size
= fieldsize (struct link_map32
, l_prev
);
199 lmo32
.l_name_offset
= offsetof (struct link_map32
, l_name
);
200 lmo32
.l_name_size
= fieldsize (struct link_map32
, l_name
);
202 #endif /* defined (HAVE_STRUCT_LINK_MAP32) */
204 #if defined (HAVE_STRUCT_LINK_MAP32)
205 if (bfd_get_arch_size (exec_bfd
) == 32)
213 internal_error ("default_svr4_fetch_link_map_offsets called without HAVE_LINK_H defined.");
216 #endif /* HAVE_LINK_H */
219 /* Macro to extract an address from a solib structure.
220 When GDB is configured for some 32-bit targets (e.g. Solaris 2.7
221 sparc), BFD is configured to handle 64-bit targets, so CORE_ADDR is
222 64 bits. We have to extract only the significant bits of addresses
223 to get the right address when accessing the core file BFD. */
225 #define SOLIB_EXTRACT_ADDRESS(MEMBER) \
226 extract_address (&(MEMBER), sizeof (MEMBER))
228 /* local data declarations */
230 #ifndef SVR4_SHARED_LIBS
232 /* NOTE: converted the macros LM_ADDR, LM_NEXT, LM_NAME and
233 IGNORE_FIRST_LINK_MAP_ENTRY into functions (see below).
236 static struct link_dynamic dynamic_copy
;
237 static struct link_dynamic_2 ld_2_copy
;
238 static struct ld_debug debug_copy
;
239 static CORE_ADDR debug_addr
;
240 static CORE_ADDR flag_addr
;
242 #endif /* !SVR4_SHARED_LIBS */
244 /* link map access functions */
247 LM_ADDR (struct so_list
*so
)
249 struct link_map_offsets
*lmo
= SVR4_FETCH_LINK_MAP_OFFSETS ();
251 return extract_address (so
->lm_info
->lm
+ lmo
->l_addr_offset
, lmo
->l_addr_size
);
255 LM_NEXT (struct so_list
*so
)
257 struct link_map_offsets
*lmo
= SVR4_FETCH_LINK_MAP_OFFSETS ();
259 return extract_address (so
->lm_info
->lm
+ lmo
->l_next_offset
, lmo
->l_next_size
);
263 LM_NAME (struct so_list
*so
)
265 struct link_map_offsets
*lmo
= SVR4_FETCH_LINK_MAP_OFFSETS ();
267 return extract_address (so
->lm_info
->lm
+ lmo
->l_name_offset
, lmo
->l_name_size
);
270 #ifndef SVR4_SHARED_LIBS
273 IGNORE_FIRST_LINK_MAP_ENTRY (struct so_list
*so
)
278 #else /* SVR4_SHARED_LIBS */
281 IGNORE_FIRST_LINK_MAP_ENTRY (struct so_list
*so
)
283 struct link_map_offsets
*lmo
= SVR4_FETCH_LINK_MAP_OFFSETS ();
285 return extract_address (so
->lm_info
->lm
+ lmo
->l_prev_offset
,
286 lmo
->l_prev_size
) == 0;
289 #endif /* !SVR4_SHARED_LIBS */
291 static CORE_ADDR debug_base
; /* Base of dynamic linker structures */
292 static CORE_ADDR breakpoint_addr
; /* Address where end bkpt is set */
294 /* Local function prototypes */
296 static int match_main (char *);
298 #ifndef SVR4_SHARED_LIBS
300 /* Allocate the runtime common object file. */
303 allocate_rt_common_objfile (void)
305 struct objfile
*objfile
;
306 struct objfile
*last_one
;
308 objfile
= (struct objfile
*) xmalloc (sizeof (struct objfile
));
309 memset (objfile
, 0, sizeof (struct objfile
));
311 obstack_specify_allocation (&objfile
->psymbol_cache
.cache
, 0, 0,
313 obstack_specify_allocation (&objfile
->psymbol_obstack
, 0, 0, xmalloc
,
315 obstack_specify_allocation (&objfile
->symbol_obstack
, 0, 0, xmalloc
,
317 obstack_specify_allocation (&objfile
->type_obstack
, 0, 0, xmalloc
,
319 objfile
->name
= mstrsave (objfile
->md
, "rt_common");
321 /* Add this file onto the tail of the linked list of other such files. */
323 objfile
->next
= NULL
;
324 if (object_files
== NULL
)
325 object_files
= objfile
;
328 for (last_one
= object_files
;
330 last_one
= last_one
->next
);
331 last_one
->next
= objfile
;
334 rt_common_objfile
= objfile
;
337 /* Read all dynamically loaded common symbol definitions from the inferior
338 and put them into the minimal symbol table for the runtime common
342 solib_add_common_symbols (CORE_ADDR rtc_symp
)
344 struct rtc_symb inferior_rtc_symb
;
345 struct nlist inferior_rtc_nlist
;
349 /* Remove any runtime common symbols from previous runs. */
351 if (rt_common_objfile
!= NULL
&& rt_common_objfile
->minimal_symbol_count
)
353 obstack_free (&rt_common_objfile
->symbol_obstack
, 0);
354 obstack_specify_allocation (&rt_common_objfile
->symbol_obstack
, 0, 0,
356 rt_common_objfile
->minimal_symbol_count
= 0;
357 rt_common_objfile
->msymbols
= NULL
;
360 init_minimal_symbol_collection ();
361 make_cleanup_discard_minimal_symbols ();
365 read_memory (rtc_symp
,
366 (char *) &inferior_rtc_symb
,
367 sizeof (inferior_rtc_symb
));
368 read_memory (SOLIB_EXTRACT_ADDRESS (inferior_rtc_symb
.rtc_sp
),
369 (char *) &inferior_rtc_nlist
,
370 sizeof (inferior_rtc_nlist
));
371 if (inferior_rtc_nlist
.n_type
== N_COMM
)
373 /* FIXME: The length of the symbol name is not available, but in the
374 current implementation the common symbol is allocated immediately
375 behind the name of the symbol. */
376 len
= inferior_rtc_nlist
.n_value
- inferior_rtc_nlist
.n_un
.n_strx
;
378 name
= xmalloc (len
);
379 read_memory (SOLIB_EXTRACT_ADDRESS (inferior_rtc_nlist
.n_un
.n_name
),
382 /* Allocate the runtime common objfile if necessary. */
383 if (rt_common_objfile
== NULL
)
384 allocate_rt_common_objfile ();
386 prim_record_minimal_symbol (name
, inferior_rtc_nlist
.n_value
,
387 mst_bss
, rt_common_objfile
);
390 rtc_symp
= SOLIB_EXTRACT_ADDRESS (inferior_rtc_symb
.rtc_next
);
393 /* Install any minimal symbols that have been collected as the current
394 minimal symbols for the runtime common objfile. */
396 install_minimal_symbols (rt_common_objfile
);
399 #endif /* SVR4_SHARED_LIBS */
402 #ifdef SVR4_SHARED_LIBS
404 static CORE_ADDR
bfd_lookup_symbol (bfd
*, char *);
410 bfd_lookup_symbol -- lookup the value for a specific symbol
414 CORE_ADDR bfd_lookup_symbol (bfd *abfd, char *symname)
418 An expensive way to lookup the value of a single symbol for
419 bfd's that are only temporary anyway. This is used by the
420 shared library support to find the address of the debugger
421 interface structures in the shared library.
423 Note that 0 is specifically allowed as an error return (no
428 bfd_lookup_symbol (bfd
*abfd
, char *symname
)
430 unsigned int storage_needed
;
432 asymbol
**symbol_table
;
433 unsigned int number_of_symbols
;
435 struct cleanup
*back_to
;
436 CORE_ADDR symaddr
= 0;
438 storage_needed
= bfd_get_symtab_upper_bound (abfd
);
440 if (storage_needed
> 0)
442 symbol_table
= (asymbol
**) xmalloc (storage_needed
);
443 back_to
= make_cleanup (xfree
, (PTR
) symbol_table
);
444 number_of_symbols
= bfd_canonicalize_symtab (abfd
, symbol_table
);
446 for (i
= 0; i
< number_of_symbols
; i
++)
448 sym
= *symbol_table
++;
449 if (STREQ (sym
->name
, symname
))
451 /* Bfd symbols are section relative. */
452 symaddr
= sym
->value
+ sym
->section
->vma
;
456 do_cleanups (back_to
);
462 /* On FreeBSD, the dynamic linker is stripped by default. So we'll
463 have to check the dynamic string table too. */
465 storage_needed
= bfd_get_dynamic_symtab_upper_bound (abfd
);
467 if (storage_needed
> 0)
469 symbol_table
= (asymbol
**) xmalloc (storage_needed
);
470 back_to
= make_cleanup (xfree
, (PTR
) symbol_table
);
471 number_of_symbols
= bfd_canonicalize_dynamic_symtab (abfd
, symbol_table
);
473 for (i
= 0; i
< number_of_symbols
; i
++)
475 sym
= *symbol_table
++;
476 if (STREQ (sym
->name
, symname
))
478 /* Bfd symbols are section relative. */
479 symaddr
= sym
->value
+ sym
->section
->vma
;
483 do_cleanups (back_to
);
489 #ifdef HANDLE_SVR4_EXEC_EMULATORS
492 Solaris BCP (the part of Solaris which allows it to run SunOS4
493 a.out files) throws in another wrinkle. Solaris does not fill
494 in the usual a.out link map structures when running BCP programs,
495 the only way to get at them is via groping around in the dynamic
497 The dynamic linker and it's structures are located in the shared
498 C library, which gets run as the executable's "interpreter" by
501 Note that we can assume nothing about the process state at the time
502 we need to find these structures. We may be stopped on the first
503 instruction of the interpreter (C shared library), the first
504 instruction of the executable itself, or somewhere else entirely
505 (if we attached to the process for example).
508 static char *debug_base_symbols
[] =
510 "r_debug", /* Solaris 2.3 */
511 "_r_debug", /* Solaris 2.1, 2.2 */
515 static int look_for_base (int, CORE_ADDR
);
521 look_for_base -- examine file for each mapped address segment
525 static int look_for_base (int fd, CORE_ADDR baseaddr)
529 This function is passed to proc_iterate_over_mappings, which
530 causes it to get called once for each mapped address space, with
531 an open file descriptor for the file mapped to that space, and the
532 base address of that mapped space.
534 Our job is to find the debug base symbol in the file that this
535 fd is open on, if it exists, and if so, initialize the dynamic
536 linker structure base address debug_base.
538 Note that this is a computationally expensive proposition, since
539 we basically have to open a bfd on every call, so we specifically
540 avoid opening the exec file.
544 look_for_base (int fd
, CORE_ADDR baseaddr
)
547 CORE_ADDR address
= 0;
550 /* If the fd is -1, then there is no file that corresponds to this
551 mapped memory segment, so skip it. Also, if the fd corresponds
552 to the exec file, skip it as well. */
556 && fdmatch (fileno ((FILE *) (exec_bfd
->iostream
)), fd
)))
561 /* Try to open whatever random file this fd corresponds to. Note that
562 we have no way currently to find the filename. Don't gripe about
563 any problems we might have, just fail. */
565 if ((interp_bfd
= bfd_fdopenr ("unnamed", gnutarget
, fd
)) == NULL
)
569 if (!bfd_check_format (interp_bfd
, bfd_object
))
571 /* FIXME-leak: on failure, might not free all memory associated with
573 bfd_close (interp_bfd
);
577 /* Now try to find our debug base symbol in this file, which we at
578 least know to be a valid ELF executable or shared library. */
580 for (symbolp
= debug_base_symbols
; *symbolp
!= NULL
; symbolp
++)
582 address
= bfd_lookup_symbol (interp_bfd
, *symbolp
);
590 /* FIXME-leak: on failure, might not free all memory associated with
592 bfd_close (interp_bfd
);
596 /* Eureka! We found the symbol. But now we may need to relocate it
597 by the base address. If the symbol's value is less than the base
598 address of the shared library, then it hasn't yet been relocated
599 by the dynamic linker, and we have to do it ourself. FIXME: Note
600 that we make the assumption that the first segment that corresponds
601 to the shared library has the base address to which the library
604 if (address
< baseaddr
)
608 debug_base
= address
;
609 /* FIXME-leak: on failure, might not free all memory associated with
611 bfd_close (interp_bfd
);
614 #endif /* HANDLE_SVR4_EXEC_EMULATORS */
620 elf_locate_base -- locate the base address of dynamic linker structs
621 for SVR4 elf targets.
625 CORE_ADDR elf_locate_base (void)
629 For SVR4 elf targets the address of the dynamic linker's runtime
630 structure is contained within the dynamic info section in the
631 executable file. The dynamic section is also mapped into the
632 inferior address space. Because the runtime loader fills in the
633 real address before starting the inferior, we have to read in the
634 dynamic info section from the inferior address space.
635 If there are any errors while trying to find the address, we
636 silently return 0, otherwise the found address is returned.
641 elf_locate_base (void)
643 sec_ptr dyninfo_sect
;
644 int dyninfo_sect_size
;
645 CORE_ADDR dyninfo_addr
;
650 /* Find the start address of the .dynamic section. */
651 dyninfo_sect
= bfd_get_section_by_name (exec_bfd
, ".dynamic");
652 if (dyninfo_sect
== NULL
)
654 dyninfo_addr
= bfd_section_vma (exec_bfd
, dyninfo_sect
);
656 /* Read in .dynamic section, silently ignore errors. */
657 dyninfo_sect_size
= bfd_section_size (exec_bfd
, dyninfo_sect
);
658 buf
= alloca (dyninfo_sect_size
);
659 if (target_read_memory (dyninfo_addr
, buf
, dyninfo_sect_size
))
662 /* Find the DT_DEBUG entry in the the .dynamic section.
663 For mips elf we look for DT_MIPS_RLD_MAP, mips elf apparently has
664 no DT_DEBUG entries. */
666 arch_size
= bfd_get_arch_size (exec_bfd
);
667 if (arch_size
== -1) /* failure */
672 for (bufend
= buf
+ dyninfo_sect_size
;
674 buf
+= sizeof (Elf32_External_Dyn
))
676 Elf32_External_Dyn
*x_dynp
= (Elf32_External_Dyn
*) buf
;
680 dyn_tag
= bfd_h_get_32 (exec_bfd
, (bfd_byte
*) x_dynp
->d_tag
);
681 if (dyn_tag
== DT_NULL
)
683 else if (dyn_tag
== DT_DEBUG
)
685 dyn_ptr
= bfd_h_get_32 (exec_bfd
,
686 (bfd_byte
*) x_dynp
->d_un
.d_ptr
);
689 #ifdef DT_MIPS_RLD_MAP
690 else if (dyn_tag
== DT_MIPS_RLD_MAP
)
694 pbuf
= alloca (TARGET_PTR_BIT
/ HOST_CHAR_BIT
);
695 /* DT_MIPS_RLD_MAP contains a pointer to the address
696 of the dynamic link structure. */
697 dyn_ptr
= bfd_h_get_32 (exec_bfd
,
698 (bfd_byte
*) x_dynp
->d_un
.d_ptr
);
699 if (target_read_memory (dyn_ptr
, pbuf
, sizeof (pbuf
)))
701 return extract_unsigned_integer (pbuf
, sizeof (pbuf
));
706 else /* 64-bit elf */
708 for (bufend
= buf
+ dyninfo_sect_size
;
710 buf
+= sizeof (Elf64_External_Dyn
))
712 Elf64_External_Dyn
*x_dynp
= (Elf64_External_Dyn
*) buf
;
716 dyn_tag
= bfd_h_get_64 (exec_bfd
, (bfd_byte
*) x_dynp
->d_tag
);
717 if (dyn_tag
== DT_NULL
)
719 else if (dyn_tag
== DT_DEBUG
)
721 dyn_ptr
= bfd_h_get_64 (exec_bfd
,
722 (bfd_byte
*) x_dynp
->d_un
.d_ptr
);
728 /* DT_DEBUG entry not found. */
732 #endif /* SVR4_SHARED_LIBS */
738 locate_base -- locate the base address of dynamic linker structs
742 CORE_ADDR locate_base (void)
746 For both the SunOS and SVR4 shared library implementations, if the
747 inferior executable has been linked dynamically, there is a single
748 address somewhere in the inferior's data space which is the key to
749 locating all of the dynamic linker's runtime structures. This
750 address is the value of the debug base symbol. The job of this
751 function is to find and return that address, or to return 0 if there
752 is no such address (the executable is statically linked for example).
754 For SunOS, the job is almost trivial, since the dynamic linker and
755 all of it's structures are statically linked to the executable at
756 link time. Thus the symbol for the address we are looking for has
757 already been added to the minimal symbol table for the executable's
758 objfile at the time the symbol file's symbols were read, and all we
759 have to do is look it up there. Note that we explicitly do NOT want
760 to find the copies in the shared library.
762 The SVR4 version is a bit more complicated because the address
763 is contained somewhere in the dynamic info section. We have to go
764 to a lot more work to discover the address of the debug base symbol.
765 Because of this complexity, we cache the value we find and return that
766 value on subsequent invocations. Note there is no copy in the
767 executable symbol tables.
775 #ifndef SVR4_SHARED_LIBS
777 struct minimal_symbol
*msymbol
;
778 CORE_ADDR address
= 0;
781 /* For SunOS, we want to limit the search for the debug base symbol to the
782 executable being debugged, since there is a duplicate named symbol in the
783 shared library. We don't want the shared library versions. */
785 for (symbolp
= debug_base_symbols
; *symbolp
!= NULL
; symbolp
++)
787 msymbol
= lookup_minimal_symbol (*symbolp
, NULL
, symfile_objfile
);
788 if ((msymbol
!= NULL
) && (SYMBOL_VALUE_ADDRESS (msymbol
) != 0))
790 address
= SYMBOL_VALUE_ADDRESS (msymbol
);
796 #else /* SVR4_SHARED_LIBS */
798 /* Check to see if we have a currently valid address, and if so, avoid
799 doing all this work again and just return the cached address. If
800 we have no cached address, try to locate it in the dynamic info
801 section for ELF executables. */
806 && bfd_get_flavour (exec_bfd
) == bfd_target_elf_flavour
)
807 debug_base
= elf_locate_base ();
808 #ifdef HANDLE_SVR4_EXEC_EMULATORS
809 /* Try it the hard way for emulated executables. */
810 else if (inferior_pid
!= 0 && target_has_execution
)
811 proc_iterate_over_mappings (look_for_base
);
816 #endif /* !SVR4_SHARED_LIBS */
824 first_link_map_member -- locate first member in dynamic linker's map
828 static CORE_ADDR first_link_map_member (void)
832 Find the first element in the inferior's dynamic link map, and
833 return its address in the inferior. This function doesn't copy the
834 link map entry itself into our address space; current_sos actually
838 first_link_map_member (void)
842 #ifndef SVR4_SHARED_LIBS
844 read_memory (debug_base
, (char *) &dynamic_copy
, sizeof (dynamic_copy
));
845 if (dynamic_copy
.ld_version
>= 2)
847 /* It is a version that we can deal with, so read in the secondary
848 structure and find the address of the link map list from it. */
849 read_memory (SOLIB_EXTRACT_ADDRESS (dynamic_copy
.ld_un
.ld_2
),
850 (char *) &ld_2_copy
, sizeof (struct link_dynamic_2
));
851 lm
= SOLIB_EXTRACT_ADDRESS (ld_2_copy
.ld_loaded
);
854 #else /* SVR4_SHARED_LIBS */
855 struct link_map_offsets
*lmo
= SVR4_FETCH_LINK_MAP_OFFSETS ();
856 char *r_map_buf
= xmalloc (lmo
->r_map_size
);
857 struct cleanup
*cleanups
= make_cleanup (xfree
, r_map_buf
);
859 read_memory (debug_base
+ lmo
->r_map_offset
, r_map_buf
, lmo
->r_map_size
);
861 lm
= extract_address (r_map_buf
, lmo
->r_map_size
);
863 /* FIXME: Perhaps we should validate the info somehow, perhaps by
864 checking r_version for a known version number, or r_state for
867 do_cleanups (cleanups
);
869 #endif /* !SVR4_SHARED_LIBS */
874 #ifdef SVR4_SHARED_LIBS
879 open_symbol_file_object
883 void open_symbol_file_object (void *from_tty)
887 If no open symbol file, attempt to locate and open the main symbol
888 file. On SVR4 systems, this is the first link map entry. If its
889 name is here, we can open it. Useful when attaching to a process
890 without first loading its symbol file.
892 If FROM_TTYP dereferences to a non-zero integer, allow messages to
893 be printed. This parameter is a pointer rather than an int because
894 open_symbol_file_object() is called via catch_errors() and
895 catch_errors() requires a pointer argument. */
898 open_symbol_file_object (void *from_ttyp
)
900 CORE_ADDR lm
, l_name
;
903 int from_tty
= *(int *)from_ttyp
;
904 struct link_map_offsets
*lmo
= SVR4_FETCH_LINK_MAP_OFFSETS ();
905 char *l_name_buf
= xmalloc (lmo
->l_name_size
);
906 struct cleanup
*cleanups
= make_cleanup (xfree
, l_name_buf
);
909 if (!query ("Attempt to reload symbols from process? "))
912 if ((debug_base
= locate_base ()) == 0)
913 return 0; /* failed somehow... */
915 /* First link map member should be the executable. */
916 if ((lm
= first_link_map_member ()) == 0)
917 return 0; /* failed somehow... */
919 /* Read address of name from target memory to GDB. */
920 read_memory (lm
+ lmo
->l_name_offset
, l_name_buf
, lmo
->l_name_size
);
922 /* Convert the address to host format. */
923 l_name
= extract_address (l_name_buf
, lmo
->l_name_size
);
925 /* Free l_name_buf. */
926 do_cleanups (cleanups
);
929 return 0; /* No filename. */
931 /* Now fetch the filename from target memory. */
932 target_read_string (l_name
, &filename
, SO_NAME_MAX_PATH_SIZE
- 1, &errcode
);
936 warning ("failed to read exec filename from attached file: %s",
937 safe_strerror (errcode
));
941 make_cleanup (xfree
, filename
);
942 /* Have a pathname: read the symbol file. */
943 symbol_file_command (filename
, from_tty
);
950 open_symbol_file_object (int *from_ttyp
)
955 #endif /* SVR4_SHARED_LIBS */
960 current_sos -- build a list of currently loaded shared objects
964 struct so_list *current_sos ()
968 Build a list of `struct so_list' objects describing the shared
969 objects currently loaded in the inferior. This list does not
970 include an entry for the main executable file.
972 Note that we only gather information directly available from the
973 inferior --- we don't examine any of the shared library files
974 themselves. The declaration of `struct so_list' says which fields
975 we provide values for. */
977 static struct so_list
*
978 svr4_current_sos (void)
981 struct so_list
*head
= 0;
982 struct so_list
**link_ptr
= &head
;
984 /* Make sure we've looked up the inferior's dynamic linker's base
988 debug_base
= locate_base ();
990 /* If we can't find the dynamic linker's base structure, this
991 must not be a dynamically linked executable. Hmm. */
996 /* Walk the inferior's link map list, and build our list of
997 `struct so_list' nodes. */
998 lm
= first_link_map_member ();
1001 struct link_map_offsets
*lmo
= SVR4_FETCH_LINK_MAP_OFFSETS ();
1003 = (struct so_list
*) xmalloc (sizeof (struct so_list
));
1004 struct cleanup
*old_chain
= make_cleanup (xfree
, new);
1006 memset (new, 0, sizeof (*new));
1008 new->lm_info
= xmalloc (sizeof (struct lm_info
));
1009 make_cleanup (xfree
, new->lm_info
);
1011 new->lm_info
->lm
= xmalloc (lmo
->link_map_size
);
1012 make_cleanup (xfree
, new->lm_info
->lm
);
1013 memset (new->lm_info
->lm
, 0, lmo
->link_map_size
);
1015 read_memory (lm
, new->lm_info
->lm
, lmo
->link_map_size
);
1019 /* For SVR4 versions, the first entry in the link map is for the
1020 inferior executable, so we must ignore it. For some versions of
1021 SVR4, it has no name. For others (Solaris 2.3 for example), it
1022 does have a name, so we can no longer use a missing name to
1023 decide when to ignore it. */
1024 if (IGNORE_FIRST_LINK_MAP_ENTRY (new))
1031 /* Extract this shared object's name. */
1032 target_read_string (LM_NAME (new), &buffer
,
1033 SO_NAME_MAX_PATH_SIZE
- 1, &errcode
);
1036 warning ("current_sos: Can't read pathname for load map: %s\n",
1037 safe_strerror (errcode
));
1041 strncpy (new->so_name
, buffer
, SO_NAME_MAX_PATH_SIZE
- 1);
1042 new->so_name
[SO_NAME_MAX_PATH_SIZE
- 1] = '\0';
1044 strcpy (new->so_original_name
, new->so_name
);
1047 /* If this entry has no name, or its name matches the name
1048 for the main executable, don't include it in the list. */
1049 if (! new->so_name
[0]
1050 || match_main (new->so_name
))
1056 link_ptr
= &new->next
;
1060 discard_cleanups (old_chain
);
1067 /* On some systems, the only way to recognize the link map entry for
1068 the main executable file is by looking at its name. Return
1069 non-zero iff SONAME matches one of the known main executable names. */
1072 match_main (char *soname
)
1076 for (mainp
= main_name_list
; *mainp
!= NULL
; mainp
++)
1078 if (strcmp (soname
, *mainp
) == 0)
1086 #ifdef SVR4_SHARED_LIBS
1088 /* Return 1 if PC lies in the dynamic symbol resolution code of the
1089 SVR4 run time loader. */
1091 static CORE_ADDR interp_text_sect_low
;
1092 static CORE_ADDR interp_text_sect_high
;
1093 static CORE_ADDR interp_plt_sect_low
;
1094 static CORE_ADDR interp_plt_sect_high
;
1097 in_svr4_dynsym_resolve_code (CORE_ADDR pc
)
1099 return ((pc
>= interp_text_sect_low
&& pc
< interp_text_sect_high
)
1100 || (pc
>= interp_plt_sect_low
&& pc
< interp_plt_sect_high
)
1101 || in_plt_section (pc
, NULL
));
1109 disable_break -- remove the "mapping changed" breakpoint
1113 static int disable_break ()
1117 Removes the breakpoint that gets hit when the dynamic linker
1118 completes a mapping change.
1122 #ifndef SVR4_SHARED_LIBS
1125 disable_break (void)
1129 int in_debugger
= 0;
1131 /* Read the debugger structure from the inferior to retrieve the
1132 address of the breakpoint and the original contents of the
1133 breakpoint address. Remove the breakpoint by writing the original
1136 read_memory (debug_addr
, (char *) &debug_copy
, sizeof (debug_copy
));
1138 /* Set `in_debugger' to zero now. */
1140 write_memory (flag_addr
, (char *) &in_debugger
, sizeof (in_debugger
));
1142 breakpoint_addr
= SOLIB_EXTRACT_ADDRESS (debug_copy
.ldd_bp_addr
);
1143 write_memory (breakpoint_addr
, (char *) &debug_copy
.ldd_bp_inst
,
1144 sizeof (debug_copy
.ldd_bp_inst
));
1146 /* For the SVR4 version, we always know the breakpoint address. For the
1147 SunOS version we don't know it until the above code is executed.
1148 Grumble if we are stopped anywhere besides the breakpoint address. */
1150 if (stop_pc
!= breakpoint_addr
)
1152 warning ("stopped at unknown breakpoint while handling shared libraries");
1158 #endif /* #ifdef SVR4_SHARED_LIBS */
1164 enable_break -- arrange for dynamic linker to hit breakpoint
1168 int enable_break (void)
1172 Both the SunOS and the SVR4 dynamic linkers have, as part of their
1173 debugger interface, support for arranging for the inferior to hit
1174 a breakpoint after mapping in the shared libraries. This function
1175 enables that breakpoint.
1177 For SunOS, there is a special flag location (in_debugger) which we
1178 set to 1. When the dynamic linker sees this flag set, it will set
1179 a breakpoint at a location known only to itself, after saving the
1180 original contents of that place and the breakpoint address itself,
1181 in it's own internal structures. When we resume the inferior, it
1182 will eventually take a SIGTRAP when it runs into the breakpoint.
1183 We handle this (in a different place) by restoring the contents of
1184 the breakpointed location (which is only known after it stops),
1185 chasing around to locate the shared libraries that have been
1186 loaded, then resuming.
1188 For SVR4, the debugger interface structure contains a member (r_brk)
1189 which is statically initialized at the time the shared library is
1190 built, to the offset of a function (_r_debug_state) which is guaran-
1191 teed to be called once before mapping in a library, and again when
1192 the mapping is complete. At the time we are examining this member,
1193 it contains only the unrelocated offset of the function, so we have
1194 to do our own relocation. Later, when the dynamic linker actually
1195 runs, it relocates r_brk to be the actual address of _r_debug_state().
1197 The debugger interface structure also contains an enumeration which
1198 is set to either RT_ADD or RT_DELETE prior to changing the mapping,
1199 depending upon whether or not the library is being mapped or unmapped,
1200 and then set to RT_CONSISTENT after the library is mapped/unmapped.
1208 #ifndef SVR4_SHARED_LIBS
1213 /* Get link_dynamic structure */
1215 j
= target_read_memory (debug_base
, (char *) &dynamic_copy
,
1216 sizeof (dynamic_copy
));
1223 /* Calc address of debugger interface structure */
1225 debug_addr
= SOLIB_EXTRACT_ADDRESS (dynamic_copy
.ldd
);
1227 /* Calc address of `in_debugger' member of debugger interface structure */
1229 flag_addr
= debug_addr
+ (CORE_ADDR
) ((char *) &debug_copy
.ldd_in_debugger
-
1230 (char *) &debug_copy
);
1232 /* Write a value of 1 to this member. */
1235 write_memory (flag_addr
, (char *) &in_debugger
, sizeof (in_debugger
));
1238 #else /* SVR4_SHARED_LIBS */
1240 #ifdef BKPT_AT_SYMBOL
1242 struct minimal_symbol
*msymbol
;
1244 asection
*interp_sect
;
1246 /* First, remove all the solib event breakpoints. Their addresses
1247 may have changed since the last time we ran the program. */
1248 remove_solib_event_breakpoints ();
1250 #ifdef SVR4_SHARED_LIBS
1251 interp_text_sect_low
= interp_text_sect_high
= 0;
1252 interp_plt_sect_low
= interp_plt_sect_high
= 0;
1254 /* Find the .interp section; if not found, warn the user and drop
1255 into the old breakpoint at symbol code. */
1256 interp_sect
= bfd_get_section_by_name (exec_bfd
, ".interp");
1259 unsigned int interp_sect_size
;
1261 CORE_ADDR load_addr
;
1262 bfd
*tmp_bfd
= NULL
;
1264 char *tmp_pathname
= NULL
;
1265 CORE_ADDR sym_addr
= 0;
1267 /* Read the contents of the .interp section into a local buffer;
1268 the contents specify the dynamic linker this program uses. */
1269 interp_sect_size
= bfd_section_size (exec_bfd
, interp_sect
);
1270 buf
= alloca (interp_sect_size
);
1271 bfd_get_section_contents (exec_bfd
, interp_sect
,
1272 buf
, 0, interp_sect_size
);
1274 /* Now we need to figure out where the dynamic linker was
1275 loaded so that we can load its symbols and place a breakpoint
1276 in the dynamic linker itself.
1278 This address is stored on the stack. However, I've been unable
1279 to find any magic formula to find it for Solaris (appears to
1280 be trivial on GNU/Linux). Therefore, we have to try an alternate
1281 mechanism to find the dynamic linker's base address. */
1283 tmp_fd
= solib_open (buf
, &tmp_pathname
);
1285 tmp_bfd
= bfd_fdopenr (tmp_pathname
, gnutarget
, tmp_fd
);
1287 if (tmp_bfd
== NULL
)
1288 goto bkpt_at_symbol
;
1290 /* Make sure the dynamic linker's really a useful object. */
1291 if (!bfd_check_format (tmp_bfd
, bfd_object
))
1293 warning ("Unable to grok dynamic linker %s as an object file", buf
);
1294 bfd_close (tmp_bfd
);
1295 goto bkpt_at_symbol
;
1298 /* We find the dynamic linker's base address by examining the
1299 current pc (which point at the entry point for the dynamic
1300 linker) and subtracting the offset of the entry point. */
1301 load_addr
= read_pc () - tmp_bfd
->start_address
;
1303 /* Record the relocated start and end address of the dynamic linker
1304 text and plt section for in_svr4_dynsym_resolve_code. */
1305 interp_sect
= bfd_get_section_by_name (tmp_bfd
, ".text");
1308 interp_text_sect_low
=
1309 bfd_section_vma (tmp_bfd
, interp_sect
) + load_addr
;
1310 interp_text_sect_high
=
1311 interp_text_sect_low
+ bfd_section_size (tmp_bfd
, interp_sect
);
1313 interp_sect
= bfd_get_section_by_name (tmp_bfd
, ".plt");
1316 interp_plt_sect_low
=
1317 bfd_section_vma (tmp_bfd
, interp_sect
) + load_addr
;
1318 interp_plt_sect_high
=
1319 interp_plt_sect_low
+ bfd_section_size (tmp_bfd
, interp_sect
);
1322 /* Now try to set a breakpoint in the dynamic linker. */
1323 for (bkpt_namep
= solib_break_names
; *bkpt_namep
!= NULL
; bkpt_namep
++)
1325 sym_addr
= bfd_lookup_symbol (tmp_bfd
, *bkpt_namep
);
1330 /* We're done with the temporary bfd. */
1331 bfd_close (tmp_bfd
);
1335 create_solib_event_breakpoint (load_addr
+ sym_addr
);
1339 /* For whatever reason we couldn't set a breakpoint in the dynamic
1340 linker. Warn and drop into the old code. */
1342 warning ("Unable to find dynamic linker breakpoint function.\nGDB will be unable to debug shared library initializers\nand track explicitly loaded dynamic code.");
1346 /* Scan through the list of symbols, trying to look up the symbol and
1347 set a breakpoint there. Terminate loop when we/if we succeed. */
1349 breakpoint_addr
= 0;
1350 for (bkpt_namep
= bkpt_names
; *bkpt_namep
!= NULL
; bkpt_namep
++)
1352 msymbol
= lookup_minimal_symbol (*bkpt_namep
, NULL
, symfile_objfile
);
1353 if ((msymbol
!= NULL
) && (SYMBOL_VALUE_ADDRESS (msymbol
) != 0))
1355 create_solib_event_breakpoint (SYMBOL_VALUE_ADDRESS (msymbol
));
1360 /* Nothing good happened. */
1363 #endif /* BKPT_AT_SYMBOL */
1365 #endif /* !SVR4_SHARED_LIBS */
1374 special_symbol_handling -- additional shared library symbol handling
1378 void special_symbol_handling ()
1382 Once the symbols from a shared object have been loaded in the usual
1383 way, we are called to do any system specific symbol handling that
1386 For SunOS4, this consists of grunging around in the dynamic
1387 linkers structures to find symbol definitions for "common" symbols
1388 and adding them to the minimal symbol table for the runtime common
1394 svr4_special_symbol_handling (void)
1396 #ifndef SVR4_SHARED_LIBS
1399 if (debug_addr
== 0)
1401 /* Get link_dynamic structure */
1403 j
= target_read_memory (debug_base
, (char *) &dynamic_copy
,
1404 sizeof (dynamic_copy
));
1411 /* Calc address of debugger interface structure */
1412 /* FIXME, this needs work for cross-debugging of core files
1413 (byteorder, size, alignment, etc). */
1415 debug_addr
= SOLIB_EXTRACT_ADDRESS (dynamic_copy
.ldd
);
1418 /* Read the debugger structure from the inferior, just to make sure
1419 we have a current copy. */
1421 j
= target_read_memory (debug_addr
, (char *) &debug_copy
,
1422 sizeof (debug_copy
));
1424 return; /* unreadable */
1426 /* Get common symbol definitions for the loaded object. */
1428 if (debug_copy
.ldd_cp
)
1430 solib_add_common_symbols (SOLIB_EXTRACT_ADDRESS (debug_copy
.ldd_cp
));
1433 #endif /* !SVR4_SHARED_LIBS */
1436 /* Relocate the main executable. This function should be called upon
1437 stopping the inferior process at the entry point to the program.
1438 The entry point from BFD is compared to the PC and if they are
1439 different, the main executable is relocated by the proper amount.
1441 As written it will only attempt to relocate executables which
1442 lack interpreter sections. It seems likely that only dynamic
1443 linker executables will get relocated, though it should work
1444 properly for a position-independent static executable as well. */
1447 svr4_relocate_main_executable (void)
1449 asection
*interp_sect
;
1450 CORE_ADDR pc
= read_pc ();
1452 /* Decide if the objfile needs to be relocated. As indicated above,
1453 we will only be here when execution is stopped at the beginning
1454 of the program. Relocation is necessary if the address at which
1455 we are presently stopped differs from the start address stored in
1456 the executable AND there's no interpreter section. The condition
1457 regarding the interpreter section is very important because if
1458 there *is* an interpreter section, execution will begin there
1459 instead. When there is an interpreter section, the start address
1460 is (presumably) used by the interpreter at some point to start
1461 execution of the program.
1463 If there is an interpreter, it is normal for it to be set to an
1464 arbitrary address at the outset. The job of finding it is
1465 handled in enable_break().
1467 So, to summarize, relocations are necessary when there is no
1468 interpreter section and the start address obtained from the
1469 executable is different from the address at which GDB is
1472 [ The astute reader will note that we also test to make sure that
1473 the executable in question has the DYNAMIC flag set. It is my
1474 opinion that this test is unnecessary (undesirable even). It
1475 was added to avoid inadvertent relocation of an executable
1476 whose e_type member in the ELF header is not ET_DYN. There may
1477 be a time in the future when it is desirable to do relocations
1478 on other types of files as well in which case this condition
1479 should either be removed or modified to accomodate the new file
1480 type. (E.g, an ET_EXEC executable which has been built to be
1481 position-independent could safely be relocated by the OS if
1482 desired. It is true that this violates the ABI, but the ABI
1483 has been known to be bent from time to time.) - Kevin, Nov 2000. ]
1486 interp_sect
= bfd_get_section_by_name (exec_bfd
, ".interp");
1487 if (interp_sect
== NULL
1488 && (bfd_get_file_flags (exec_bfd
) & DYNAMIC
) != 0
1489 && bfd_get_start_address (exec_bfd
) != pc
)
1491 struct cleanup
*old_chain
;
1492 struct section_offsets
*new_offsets
;
1494 CORE_ADDR displacement
;
1496 /* It is necessary to relocate the objfile. The amount to
1497 relocate by is simply the address at which we are stopped
1498 minus the starting address from the executable.
1500 We relocate all of the sections by the same amount. This
1501 behavior is mandated by recent editions of the System V ABI.
1502 According to the System V Application Binary Interface,
1503 Edition 4.1, page 5-5:
1505 ... Though the system chooses virtual addresses for
1506 individual processes, it maintains the segments' relative
1507 positions. Because position-independent code uses relative
1508 addressesing between segments, the difference between
1509 virtual addresses in memory must match the difference
1510 between virtual addresses in the file. The difference
1511 between the virtual address of any segment in memory and
1512 the corresponding virtual address in the file is thus a
1513 single constant value for any one executable or shared
1514 object in a given process. This difference is the base
1515 address. One use of the base address is to relocate the
1516 memory image of the program during dynamic linking.
1518 The same language also appears in Edition 4.0 of the System V
1519 ABI and is left unspecified in some of the earlier editions. */
1521 displacement
= pc
- bfd_get_start_address (exec_bfd
);
1524 new_offsets
= xcalloc (sizeof (struct section_offsets
),
1525 symfile_objfile
->num_sections
);
1526 old_chain
= make_cleanup (xfree
, new_offsets
);
1528 for (i
= 0; i
< symfile_objfile
->num_sections
; i
++)
1530 if (displacement
!= ANOFFSET (symfile_objfile
->section_offsets
, i
))
1532 new_offsets
->offsets
[i
] = displacement
;
1536 objfile_relocate (symfile_objfile
, new_offsets
);
1538 do_cleanups (old_chain
);
1546 svr4_solib_create_inferior_hook -- shared library startup support
1550 void svr4_solib_create_inferior_hook()
1554 When gdb starts up the inferior, it nurses it along (through the
1555 shell) until it is ready to execute it's first instruction. At this
1556 point, this function gets called via expansion of the macro
1557 SOLIB_CREATE_INFERIOR_HOOK.
1559 For SunOS executables, this first instruction is typically the
1560 one at "_start", or a similar text label, regardless of whether
1561 the executable is statically or dynamically linked. The runtime
1562 startup code takes care of dynamically linking in any shared
1563 libraries, once gdb allows the inferior to continue.
1565 For SVR4 executables, this first instruction is either the first
1566 instruction in the dynamic linker (for dynamically linked
1567 executables) or the instruction at "start" for statically linked
1568 executables. For dynamically linked executables, the system
1569 first exec's /lib/libc.so.N, which contains the dynamic linker,
1570 and starts it running. The dynamic linker maps in any needed
1571 shared libraries, maps in the actual user executable, and then
1572 jumps to "start" in the user executable.
1574 For both SunOS shared libraries, and SVR4 shared libraries, we
1575 can arrange to cooperate with the dynamic linker to discover the
1576 names of shared libraries that are dynamically linked, and the
1577 base addresses to which they are linked.
1579 This function is responsible for discovering those names and
1580 addresses, and saving sufficient information about them to allow
1581 their symbols to be read at a later time.
1585 Between enable_break() and disable_break(), this code does not
1586 properly handle hitting breakpoints which the user might have
1587 set in the startup code or in the dynamic linker itself. Proper
1588 handling will probably have to wait until the implementation is
1589 changed to use the "breakpoint handler function" method.
1591 Also, what if child has exit()ed? Must exit loop somehow.
1595 svr4_solib_create_inferior_hook (void)
1597 /* Relocate the main executable if necessary. */
1598 svr4_relocate_main_executable ();
1600 /* If we are using the BKPT_AT_SYMBOL code, then we don't need the base
1601 yet. In fact, in the case of a SunOS4 executable being run on
1602 Solaris, we can't get it yet. current_sos will get it when it needs
1604 #if !(defined (SVR4_SHARED_LIBS) && defined (BKPT_AT_SYMBOL))
1605 if ((debug_base
= locate_base ()) == 0)
1607 /* Can't find the symbol or the executable is statically linked. */
1612 if (!enable_break ())
1614 warning ("shared library handler failed to enable breakpoint");
1618 #if !defined(SVR4_SHARED_LIBS) || defined(_SCO_DS)
1619 /* SCO and SunOS need the loop below, other systems should be using the
1620 special shared library breakpoints and the shared library breakpoint
1623 Now run the target. It will eventually hit the breakpoint, at
1624 which point all of the libraries will have been mapped in and we
1625 can go groveling around in the dynamic linker structures to find
1626 out what we need to know about them. */
1628 clear_proceed_status ();
1629 stop_soon_quietly
= 1;
1630 stop_signal
= TARGET_SIGNAL_0
;
1633 target_resume (-1, 0, stop_signal
);
1634 wait_for_inferior ();
1636 while (stop_signal
!= TARGET_SIGNAL_TRAP
);
1637 stop_soon_quietly
= 0;
1639 #if !defined(_SCO_DS)
1640 /* We are now either at the "mapping complete" breakpoint (or somewhere
1641 else, a condition we aren't prepared to deal with anyway), so adjust
1642 the PC as necessary after a breakpoint, disable the breakpoint, and
1643 add any shared libraries that were mapped in. */
1645 if (DECR_PC_AFTER_BREAK
)
1647 stop_pc
-= DECR_PC_AFTER_BREAK
;
1648 write_register (PC_REGNUM
, stop_pc
);
1651 if (!disable_break ())
1653 warning ("shared library handler failed to disable breakpoint");
1657 solib_add ((char *) 0, 0, (struct target_ops
*) 0);
1658 #endif /* ! _SCO_DS */
1663 svr4_clear_solib (void)
1669 svr4_free_so (struct so_list
*so
)
1671 xfree (so
->lm_info
->lm
);
1672 xfree (so
->lm_info
);
1676 svr4_relocate_section_addresses (struct so_list
*so
,
1677 struct section_table
*sec
)
1679 sec
->addr
+= LM_ADDR (so
);
1680 sec
->endaddr
+= LM_ADDR (so
);
1683 static struct target_so_ops svr4_so_ops
;
1686 _initialize_svr4_solib (void)
1688 svr4_so_ops
.relocate_section_addresses
= svr4_relocate_section_addresses
;
1689 svr4_so_ops
.free_so
= svr4_free_so
;
1690 svr4_so_ops
.clear_solib
= svr4_clear_solib
;
1691 svr4_so_ops
.solib_create_inferior_hook
= svr4_solib_create_inferior_hook
;
1692 svr4_so_ops
.special_symbol_handling
= svr4_special_symbol_handling
;
1693 svr4_so_ops
.current_sos
= svr4_current_sos
;
1694 svr4_so_ops
.open_symbol_file_object
= open_symbol_file_object
;
1696 /* FIXME: Don't do this here. *_gdbarch_init() should set so_ops. */
1697 current_target_so_ops
= &svr4_so_ops
;