1 /* Handle SunOS and SVR4 shared libraries for GDB, the GNU Debugger.
2 Copyright 1990, 91, 92, 93, 94, 95, 96, 98, 1999, 2000, 2001
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 (__FILE__
, __LINE__
,
214 "default_svr4_fetch_link_map_offsets called without HAVE_LINK_H defined.");
217 #endif /* HAVE_LINK_H */
220 /* Macro to extract an address from a solib structure.
221 When GDB is configured for some 32-bit targets (e.g. Solaris 2.7
222 sparc), BFD is configured to handle 64-bit targets, so CORE_ADDR is
223 64 bits. We have to extract only the significant bits of addresses
224 to get the right address when accessing the core file BFD. */
226 #define SOLIB_EXTRACT_ADDRESS(MEMBER) \
227 extract_address (&(MEMBER), sizeof (MEMBER))
229 /* local data declarations */
231 #ifndef SVR4_SHARED_LIBS
233 /* NOTE: converted the macros LM_ADDR, LM_NEXT, LM_NAME and
234 IGNORE_FIRST_LINK_MAP_ENTRY into functions (see below).
237 static struct link_dynamic dynamic_copy
;
238 static struct link_dynamic_2 ld_2_copy
;
239 static struct ld_debug debug_copy
;
240 static CORE_ADDR debug_addr
;
241 static CORE_ADDR flag_addr
;
243 #endif /* !SVR4_SHARED_LIBS */
245 /* link map access functions */
248 LM_ADDR (struct so_list
*so
)
250 struct link_map_offsets
*lmo
= SVR4_FETCH_LINK_MAP_OFFSETS ();
252 return (CORE_ADDR
) extract_signed_integer (so
->lm_info
->lm
+ lmo
->l_addr_offset
,
257 LM_NEXT (struct so_list
*so
)
259 struct link_map_offsets
*lmo
= SVR4_FETCH_LINK_MAP_OFFSETS ();
261 return extract_address (so
->lm_info
->lm
+ lmo
->l_next_offset
, lmo
->l_next_size
);
265 LM_NAME (struct so_list
*so
)
267 struct link_map_offsets
*lmo
= SVR4_FETCH_LINK_MAP_OFFSETS ();
269 return extract_address (so
->lm_info
->lm
+ lmo
->l_name_offset
, lmo
->l_name_size
);
272 #ifndef SVR4_SHARED_LIBS
275 IGNORE_FIRST_LINK_MAP_ENTRY (struct so_list
*so
)
280 #else /* SVR4_SHARED_LIBS */
283 IGNORE_FIRST_LINK_MAP_ENTRY (struct so_list
*so
)
285 struct link_map_offsets
*lmo
= SVR4_FETCH_LINK_MAP_OFFSETS ();
287 return extract_address (so
->lm_info
->lm
+ lmo
->l_prev_offset
,
288 lmo
->l_prev_size
) == 0;
291 #endif /* !SVR4_SHARED_LIBS */
293 static CORE_ADDR debug_base
; /* Base of dynamic linker structures */
294 static CORE_ADDR breakpoint_addr
; /* Address where end bkpt is set */
296 /* Local function prototypes */
298 static int match_main (char *);
300 #ifndef SVR4_SHARED_LIBS
302 /* Allocate the runtime common object file. */
305 allocate_rt_common_objfile (void)
307 struct objfile
*objfile
;
308 struct objfile
*last_one
;
310 objfile
= (struct objfile
*) xmalloc (sizeof (struct objfile
));
311 memset (objfile
, 0, sizeof (struct objfile
));
313 obstack_specify_allocation (&objfile
->psymbol_cache
.cache
, 0, 0,
315 obstack_specify_allocation (&objfile
->psymbol_obstack
, 0, 0, xmalloc
,
317 obstack_specify_allocation (&objfile
->symbol_obstack
, 0, 0, xmalloc
,
319 obstack_specify_allocation (&objfile
->type_obstack
, 0, 0, xmalloc
,
321 objfile
->name
= mstrsave (objfile
->md
, "rt_common");
323 /* Add this file onto the tail of the linked list of other such files. */
325 objfile
->next
= NULL
;
326 if (object_files
== NULL
)
327 object_files
= objfile
;
330 for (last_one
= object_files
;
332 last_one
= last_one
->next
);
333 last_one
->next
= objfile
;
336 rt_common_objfile
= objfile
;
339 /* Read all dynamically loaded common symbol definitions from the inferior
340 and put them into the minimal symbol table for the runtime common
344 solib_add_common_symbols (CORE_ADDR rtc_symp
)
346 struct rtc_symb inferior_rtc_symb
;
347 struct nlist inferior_rtc_nlist
;
351 /* Remove any runtime common symbols from previous runs. */
353 if (rt_common_objfile
!= NULL
&& rt_common_objfile
->minimal_symbol_count
)
355 obstack_free (&rt_common_objfile
->symbol_obstack
, 0);
356 obstack_specify_allocation (&rt_common_objfile
->symbol_obstack
, 0, 0,
358 rt_common_objfile
->minimal_symbol_count
= 0;
359 rt_common_objfile
->msymbols
= NULL
;
362 init_minimal_symbol_collection ();
363 make_cleanup_discard_minimal_symbols ();
367 read_memory (rtc_symp
,
368 (char *) &inferior_rtc_symb
,
369 sizeof (inferior_rtc_symb
));
370 read_memory (SOLIB_EXTRACT_ADDRESS (inferior_rtc_symb
.rtc_sp
),
371 (char *) &inferior_rtc_nlist
,
372 sizeof (inferior_rtc_nlist
));
373 if (inferior_rtc_nlist
.n_type
== N_COMM
)
375 /* FIXME: The length of the symbol name is not available, but in the
376 current implementation the common symbol is allocated immediately
377 behind the name of the symbol. */
378 len
= inferior_rtc_nlist
.n_value
- inferior_rtc_nlist
.n_un
.n_strx
;
380 name
= xmalloc (len
);
381 read_memory (SOLIB_EXTRACT_ADDRESS (inferior_rtc_nlist
.n_un
.n_name
),
384 /* Allocate the runtime common objfile if necessary. */
385 if (rt_common_objfile
== NULL
)
386 allocate_rt_common_objfile ();
388 prim_record_minimal_symbol (name
, inferior_rtc_nlist
.n_value
,
389 mst_bss
, rt_common_objfile
);
392 rtc_symp
= SOLIB_EXTRACT_ADDRESS (inferior_rtc_symb
.rtc_next
);
395 /* Install any minimal symbols that have been collected as the current
396 minimal symbols for the runtime common objfile. */
398 install_minimal_symbols (rt_common_objfile
);
401 #endif /* SVR4_SHARED_LIBS */
404 #ifdef SVR4_SHARED_LIBS
406 static CORE_ADDR
bfd_lookup_symbol (bfd
*, char *);
412 bfd_lookup_symbol -- lookup the value for a specific symbol
416 CORE_ADDR bfd_lookup_symbol (bfd *abfd, char *symname)
420 An expensive way to lookup the value of a single symbol for
421 bfd's that are only temporary anyway. This is used by the
422 shared library support to find the address of the debugger
423 interface structures in the shared library.
425 Note that 0 is specifically allowed as an error return (no
430 bfd_lookup_symbol (bfd
*abfd
, char *symname
)
432 unsigned int storage_needed
;
434 asymbol
**symbol_table
;
435 unsigned int number_of_symbols
;
437 struct cleanup
*back_to
;
438 CORE_ADDR symaddr
= 0;
440 storage_needed
= bfd_get_symtab_upper_bound (abfd
);
442 if (storage_needed
> 0)
444 symbol_table
= (asymbol
**) xmalloc (storage_needed
);
445 back_to
= make_cleanup (xfree
, (PTR
) symbol_table
);
446 number_of_symbols
= bfd_canonicalize_symtab (abfd
, symbol_table
);
448 for (i
= 0; i
< number_of_symbols
; i
++)
450 sym
= *symbol_table
++;
451 if (STREQ (sym
->name
, symname
))
453 /* Bfd symbols are section relative. */
454 symaddr
= sym
->value
+ sym
->section
->vma
;
458 do_cleanups (back_to
);
464 /* On FreeBSD, the dynamic linker is stripped by default. So we'll
465 have to check the dynamic string table too. */
467 storage_needed
= bfd_get_dynamic_symtab_upper_bound (abfd
);
469 if (storage_needed
> 0)
471 symbol_table
= (asymbol
**) xmalloc (storage_needed
);
472 back_to
= make_cleanup (xfree
, (PTR
) symbol_table
);
473 number_of_symbols
= bfd_canonicalize_dynamic_symtab (abfd
, symbol_table
);
475 for (i
= 0; i
< number_of_symbols
; i
++)
477 sym
= *symbol_table
++;
478 if (STREQ (sym
->name
, symname
))
480 /* Bfd symbols are section relative. */
481 symaddr
= sym
->value
+ sym
->section
->vma
;
485 do_cleanups (back_to
);
491 #ifdef HANDLE_SVR4_EXEC_EMULATORS
494 Solaris BCP (the part of Solaris which allows it to run SunOS4
495 a.out files) throws in another wrinkle. Solaris does not fill
496 in the usual a.out link map structures when running BCP programs,
497 the only way to get at them is via groping around in the dynamic
499 The dynamic linker and it's structures are located in the shared
500 C library, which gets run as the executable's "interpreter" by
503 Note that we can assume nothing about the process state at the time
504 we need to find these structures. We may be stopped on the first
505 instruction of the interpreter (C shared library), the first
506 instruction of the executable itself, or somewhere else entirely
507 (if we attached to the process for example).
510 static char *debug_base_symbols
[] =
512 "r_debug", /* Solaris 2.3 */
513 "_r_debug", /* Solaris 2.1, 2.2 */
517 static int look_for_base (int, CORE_ADDR
);
523 look_for_base -- examine file for each mapped address segment
527 static int look_for_base (int fd, CORE_ADDR baseaddr)
531 This function is passed to proc_iterate_over_mappings, which
532 causes it to get called once for each mapped address space, with
533 an open file descriptor for the file mapped to that space, and the
534 base address of that mapped space.
536 Our job is to find the debug base symbol in the file that this
537 fd is open on, if it exists, and if so, initialize the dynamic
538 linker structure base address debug_base.
540 Note that this is a computationally expensive proposition, since
541 we basically have to open a bfd on every call, so we specifically
542 avoid opening the exec file.
546 look_for_base (int fd
, CORE_ADDR baseaddr
)
549 CORE_ADDR address
= 0;
552 /* If the fd is -1, then there is no file that corresponds to this
553 mapped memory segment, so skip it. Also, if the fd corresponds
554 to the exec file, skip it as well. */
558 && fdmatch (fileno ((FILE *) (exec_bfd
->iostream
)), fd
)))
563 /* Try to open whatever random file this fd corresponds to. Note that
564 we have no way currently to find the filename. Don't gripe about
565 any problems we might have, just fail. */
567 if ((interp_bfd
= bfd_fdopenr ("unnamed", gnutarget
, fd
)) == NULL
)
571 if (!bfd_check_format (interp_bfd
, bfd_object
))
573 /* FIXME-leak: on failure, might not free all memory associated with
575 bfd_close (interp_bfd
);
579 /* Now try to find our debug base symbol in this file, which we at
580 least know to be a valid ELF executable or shared library. */
582 for (symbolp
= debug_base_symbols
; *symbolp
!= NULL
; symbolp
++)
584 address
= bfd_lookup_symbol (interp_bfd
, *symbolp
);
592 /* FIXME-leak: on failure, might not free all memory associated with
594 bfd_close (interp_bfd
);
598 /* Eureka! We found the symbol. But now we may need to relocate it
599 by the base address. If the symbol's value is less than the base
600 address of the shared library, then it hasn't yet been relocated
601 by the dynamic linker, and we have to do it ourself. FIXME: Note
602 that we make the assumption that the first segment that corresponds
603 to the shared library has the base address to which the library
606 if (address
< baseaddr
)
610 debug_base
= address
;
611 /* FIXME-leak: on failure, might not free all memory associated with
613 bfd_close (interp_bfd
);
616 #endif /* HANDLE_SVR4_EXEC_EMULATORS */
622 elf_locate_base -- locate the base address of dynamic linker structs
623 for SVR4 elf targets.
627 CORE_ADDR elf_locate_base (void)
631 For SVR4 elf targets the address of the dynamic linker's runtime
632 structure is contained within the dynamic info section in the
633 executable file. The dynamic section is also mapped into the
634 inferior address space. Because the runtime loader fills in the
635 real address before starting the inferior, we have to read in the
636 dynamic info section from the inferior address space.
637 If there are any errors while trying to find the address, we
638 silently return 0, otherwise the found address is returned.
643 elf_locate_base (void)
645 sec_ptr dyninfo_sect
;
646 int dyninfo_sect_size
;
647 CORE_ADDR dyninfo_addr
;
652 /* Find the start address of the .dynamic section. */
653 dyninfo_sect
= bfd_get_section_by_name (exec_bfd
, ".dynamic");
654 if (dyninfo_sect
== NULL
)
656 dyninfo_addr
= bfd_section_vma (exec_bfd
, dyninfo_sect
);
658 /* Read in .dynamic section, silently ignore errors. */
659 dyninfo_sect_size
= bfd_section_size (exec_bfd
, dyninfo_sect
);
660 buf
= alloca (dyninfo_sect_size
);
661 if (target_read_memory (dyninfo_addr
, buf
, dyninfo_sect_size
))
664 /* Find the DT_DEBUG entry in the the .dynamic section.
665 For mips elf we look for DT_MIPS_RLD_MAP, mips elf apparently has
666 no DT_DEBUG entries. */
668 arch_size
= bfd_get_arch_size (exec_bfd
);
669 if (arch_size
== -1) /* failure */
674 for (bufend
= buf
+ dyninfo_sect_size
;
676 buf
+= sizeof (Elf32_External_Dyn
))
678 Elf32_External_Dyn
*x_dynp
= (Elf32_External_Dyn
*) buf
;
682 dyn_tag
= bfd_h_get_32 (exec_bfd
, (bfd_byte
*) x_dynp
->d_tag
);
683 if (dyn_tag
== DT_NULL
)
685 else if (dyn_tag
== DT_DEBUG
)
687 dyn_ptr
= bfd_h_get_32 (exec_bfd
,
688 (bfd_byte
*) x_dynp
->d_un
.d_ptr
);
691 #ifdef DT_MIPS_RLD_MAP
692 else if (dyn_tag
== DT_MIPS_RLD_MAP
)
696 pbuf
= alloca (TARGET_PTR_BIT
/ HOST_CHAR_BIT
);
697 /* DT_MIPS_RLD_MAP contains a pointer to the address
698 of the dynamic link structure. */
699 dyn_ptr
= bfd_h_get_32 (exec_bfd
,
700 (bfd_byte
*) x_dynp
->d_un
.d_ptr
);
701 if (target_read_memory (dyn_ptr
, pbuf
, sizeof (pbuf
)))
703 return extract_unsigned_integer (pbuf
, sizeof (pbuf
));
708 else /* 64-bit elf */
710 for (bufend
= buf
+ dyninfo_sect_size
;
712 buf
+= sizeof (Elf64_External_Dyn
))
714 Elf64_External_Dyn
*x_dynp
= (Elf64_External_Dyn
*) buf
;
718 dyn_tag
= bfd_h_get_64 (exec_bfd
, (bfd_byte
*) x_dynp
->d_tag
);
719 if (dyn_tag
== DT_NULL
)
721 else if (dyn_tag
== DT_DEBUG
)
723 dyn_ptr
= bfd_h_get_64 (exec_bfd
,
724 (bfd_byte
*) x_dynp
->d_un
.d_ptr
);
730 /* DT_DEBUG entry not found. */
734 #endif /* SVR4_SHARED_LIBS */
740 locate_base -- locate the base address of dynamic linker structs
744 CORE_ADDR locate_base (void)
748 For both the SunOS and SVR4 shared library implementations, if the
749 inferior executable has been linked dynamically, there is a single
750 address somewhere in the inferior's data space which is the key to
751 locating all of the dynamic linker's runtime structures. This
752 address is the value of the debug base symbol. The job of this
753 function is to find and return that address, or to return 0 if there
754 is no such address (the executable is statically linked for example).
756 For SunOS, the job is almost trivial, since the dynamic linker and
757 all of it's structures are statically linked to the executable at
758 link time. Thus the symbol for the address we are looking for has
759 already been added to the minimal symbol table for the executable's
760 objfile at the time the symbol file's symbols were read, and all we
761 have to do is look it up there. Note that we explicitly do NOT want
762 to find the copies in the shared library.
764 The SVR4 version is a bit more complicated because the address
765 is contained somewhere in the dynamic info section. We have to go
766 to a lot more work to discover the address of the debug base symbol.
767 Because of this complexity, we cache the value we find and return that
768 value on subsequent invocations. Note there is no copy in the
769 executable symbol tables.
777 #ifndef SVR4_SHARED_LIBS
779 struct minimal_symbol
*msymbol
;
780 CORE_ADDR address
= 0;
783 /* For SunOS, we want to limit the search for the debug base symbol to the
784 executable being debugged, since there is a duplicate named symbol in the
785 shared library. We don't want the shared library versions. */
787 for (symbolp
= debug_base_symbols
; *symbolp
!= NULL
; symbolp
++)
789 msymbol
= lookup_minimal_symbol (*symbolp
, NULL
, symfile_objfile
);
790 if ((msymbol
!= NULL
) && (SYMBOL_VALUE_ADDRESS (msymbol
) != 0))
792 address
= SYMBOL_VALUE_ADDRESS (msymbol
);
798 #else /* SVR4_SHARED_LIBS */
800 /* Check to see if we have a currently valid address, and if so, avoid
801 doing all this work again and just return the cached address. If
802 we have no cached address, try to locate it in the dynamic info
803 section for ELF executables. */
808 && bfd_get_flavour (exec_bfd
) == bfd_target_elf_flavour
)
809 debug_base
= elf_locate_base ();
810 #ifdef HANDLE_SVR4_EXEC_EMULATORS
811 /* Try it the hard way for emulated executables. */
812 else if (inferior_pid
!= 0 && target_has_execution
)
813 proc_iterate_over_mappings (look_for_base
);
818 #endif /* !SVR4_SHARED_LIBS */
826 first_link_map_member -- locate first member in dynamic linker's map
830 static CORE_ADDR first_link_map_member (void)
834 Find the first element in the inferior's dynamic link map, and
835 return its address in the inferior. This function doesn't copy the
836 link map entry itself into our address space; current_sos actually
840 first_link_map_member (void)
844 #ifndef SVR4_SHARED_LIBS
846 read_memory (debug_base
, (char *) &dynamic_copy
, sizeof (dynamic_copy
));
847 if (dynamic_copy
.ld_version
>= 2)
849 /* It is a version that we can deal with, so read in the secondary
850 structure and find the address of the link map list from it. */
851 read_memory (SOLIB_EXTRACT_ADDRESS (dynamic_copy
.ld_un
.ld_2
),
852 (char *) &ld_2_copy
, sizeof (struct link_dynamic_2
));
853 lm
= SOLIB_EXTRACT_ADDRESS (ld_2_copy
.ld_loaded
);
856 #else /* SVR4_SHARED_LIBS */
857 struct link_map_offsets
*lmo
= SVR4_FETCH_LINK_MAP_OFFSETS ();
858 char *r_map_buf
= xmalloc (lmo
->r_map_size
);
859 struct cleanup
*cleanups
= make_cleanup (xfree
, r_map_buf
);
861 read_memory (debug_base
+ lmo
->r_map_offset
, r_map_buf
, lmo
->r_map_size
);
863 lm
= extract_address (r_map_buf
, lmo
->r_map_size
);
865 /* FIXME: Perhaps we should validate the info somehow, perhaps by
866 checking r_version for a known version number, or r_state for
869 do_cleanups (cleanups
);
871 #endif /* !SVR4_SHARED_LIBS */
876 #ifdef SVR4_SHARED_LIBS
881 open_symbol_file_object
885 void open_symbol_file_object (void *from_tty)
889 If no open symbol file, attempt to locate and open the main symbol
890 file. On SVR4 systems, this is the first link map entry. If its
891 name is here, we can open it. Useful when attaching to a process
892 without first loading its symbol file.
894 If FROM_TTYP dereferences to a non-zero integer, allow messages to
895 be printed. This parameter is a pointer rather than an int because
896 open_symbol_file_object() is called via catch_errors() and
897 catch_errors() requires a pointer argument. */
900 open_symbol_file_object (void *from_ttyp
)
902 CORE_ADDR lm
, l_name
;
905 int from_tty
= *(int *)from_ttyp
;
906 struct link_map_offsets
*lmo
= SVR4_FETCH_LINK_MAP_OFFSETS ();
907 char *l_name_buf
= xmalloc (lmo
->l_name_size
);
908 struct cleanup
*cleanups
= make_cleanup (xfree
, l_name_buf
);
911 if (!query ("Attempt to reload symbols from process? "))
914 if ((debug_base
= locate_base ()) == 0)
915 return 0; /* failed somehow... */
917 /* First link map member should be the executable. */
918 if ((lm
= first_link_map_member ()) == 0)
919 return 0; /* failed somehow... */
921 /* Read address of name from target memory to GDB. */
922 read_memory (lm
+ lmo
->l_name_offset
, l_name_buf
, lmo
->l_name_size
);
924 /* Convert the address to host format. */
925 l_name
= extract_address (l_name_buf
, lmo
->l_name_size
);
927 /* Free l_name_buf. */
928 do_cleanups (cleanups
);
931 return 0; /* No filename. */
933 /* Now fetch the filename from target memory. */
934 target_read_string (l_name
, &filename
, SO_NAME_MAX_PATH_SIZE
- 1, &errcode
);
938 warning ("failed to read exec filename from attached file: %s",
939 safe_strerror (errcode
));
943 make_cleanup (xfree
, filename
);
944 /* Have a pathname: read the symbol file. */
945 symbol_file_add_main (filename
, from_tty
);
952 open_symbol_file_object (int *from_ttyp
)
957 #endif /* SVR4_SHARED_LIBS */
962 current_sos -- build a list of currently loaded shared objects
966 struct so_list *current_sos ()
970 Build a list of `struct so_list' objects describing the shared
971 objects currently loaded in the inferior. This list does not
972 include an entry for the main executable file.
974 Note that we only gather information directly available from the
975 inferior --- we don't examine any of the shared library files
976 themselves. The declaration of `struct so_list' says which fields
977 we provide values for. */
979 static struct so_list
*
980 svr4_current_sos (void)
983 struct so_list
*head
= 0;
984 struct so_list
**link_ptr
= &head
;
986 /* Make sure we've looked up the inferior's dynamic linker's base
990 debug_base
= locate_base ();
992 /* If we can't find the dynamic linker's base structure, this
993 must not be a dynamically linked executable. Hmm. */
998 /* Walk the inferior's link map list, and build our list of
999 `struct so_list' nodes. */
1000 lm
= first_link_map_member ();
1003 struct link_map_offsets
*lmo
= SVR4_FETCH_LINK_MAP_OFFSETS ();
1005 = (struct so_list
*) xmalloc (sizeof (struct so_list
));
1006 struct cleanup
*old_chain
= make_cleanup (xfree
, new);
1008 memset (new, 0, sizeof (*new));
1010 new->lm_info
= xmalloc (sizeof (struct lm_info
));
1011 make_cleanup (xfree
, new->lm_info
);
1013 new->lm_info
->lm
= xmalloc (lmo
->link_map_size
);
1014 make_cleanup (xfree
, new->lm_info
->lm
);
1015 memset (new->lm_info
->lm
, 0, lmo
->link_map_size
);
1017 read_memory (lm
, new->lm_info
->lm
, lmo
->link_map_size
);
1021 /* For SVR4 versions, the first entry in the link map is for the
1022 inferior executable, so we must ignore it. For some versions of
1023 SVR4, it has no name. For others (Solaris 2.3 for example), it
1024 does have a name, so we can no longer use a missing name to
1025 decide when to ignore it. */
1026 if (IGNORE_FIRST_LINK_MAP_ENTRY (new))
1033 /* Extract this shared object's name. */
1034 target_read_string (LM_NAME (new), &buffer
,
1035 SO_NAME_MAX_PATH_SIZE
- 1, &errcode
);
1038 warning ("current_sos: Can't read pathname for load map: %s\n",
1039 safe_strerror (errcode
));
1043 strncpy (new->so_name
, buffer
, SO_NAME_MAX_PATH_SIZE
- 1);
1044 new->so_name
[SO_NAME_MAX_PATH_SIZE
- 1] = '\0';
1046 strcpy (new->so_original_name
, new->so_name
);
1049 /* If this entry has no name, or its name matches the name
1050 for the main executable, don't include it in the list. */
1051 if (! new->so_name
[0]
1052 || match_main (new->so_name
))
1058 link_ptr
= &new->next
;
1062 discard_cleanups (old_chain
);
1069 /* On some systems, the only way to recognize the link map entry for
1070 the main executable file is by looking at its name. Return
1071 non-zero iff SONAME matches one of the known main executable names. */
1074 match_main (char *soname
)
1078 for (mainp
= main_name_list
; *mainp
!= NULL
; mainp
++)
1080 if (strcmp (soname
, *mainp
) == 0)
1088 #ifdef SVR4_SHARED_LIBS
1090 /* Return 1 if PC lies in the dynamic symbol resolution code of the
1091 SVR4 run time loader. */
1093 static CORE_ADDR interp_text_sect_low
;
1094 static CORE_ADDR interp_text_sect_high
;
1095 static CORE_ADDR interp_plt_sect_low
;
1096 static CORE_ADDR interp_plt_sect_high
;
1099 in_svr4_dynsym_resolve_code (CORE_ADDR pc
)
1101 return ((pc
>= interp_text_sect_low
&& pc
< interp_text_sect_high
)
1102 || (pc
>= interp_plt_sect_low
&& pc
< interp_plt_sect_high
)
1103 || in_plt_section (pc
, NULL
));
1111 disable_break -- remove the "mapping changed" breakpoint
1115 static int disable_break ()
1119 Removes the breakpoint that gets hit when the dynamic linker
1120 completes a mapping change.
1124 #ifndef SVR4_SHARED_LIBS
1127 disable_break (void)
1131 int in_debugger
= 0;
1133 /* Read the debugger structure from the inferior to retrieve the
1134 address of the breakpoint and the original contents of the
1135 breakpoint address. Remove the breakpoint by writing the original
1138 read_memory (debug_addr
, (char *) &debug_copy
, sizeof (debug_copy
));
1140 /* Set `in_debugger' to zero now. */
1142 write_memory (flag_addr
, (char *) &in_debugger
, sizeof (in_debugger
));
1144 breakpoint_addr
= SOLIB_EXTRACT_ADDRESS (debug_copy
.ldd_bp_addr
);
1145 write_memory (breakpoint_addr
, (char *) &debug_copy
.ldd_bp_inst
,
1146 sizeof (debug_copy
.ldd_bp_inst
));
1148 /* For the SVR4 version, we always know the breakpoint address. For the
1149 SunOS version we don't know it until the above code is executed.
1150 Grumble if we are stopped anywhere besides the breakpoint address. */
1152 if (stop_pc
!= breakpoint_addr
)
1154 warning ("stopped at unknown breakpoint while handling shared libraries");
1160 #endif /* #ifdef SVR4_SHARED_LIBS */
1166 enable_break -- arrange for dynamic linker to hit breakpoint
1170 int enable_break (void)
1174 Both the SunOS and the SVR4 dynamic linkers have, as part of their
1175 debugger interface, support for arranging for the inferior to hit
1176 a breakpoint after mapping in the shared libraries. This function
1177 enables that breakpoint.
1179 For SunOS, there is a special flag location (in_debugger) which we
1180 set to 1. When the dynamic linker sees this flag set, it will set
1181 a breakpoint at a location known only to itself, after saving the
1182 original contents of that place and the breakpoint address itself,
1183 in it's own internal structures. When we resume the inferior, it
1184 will eventually take a SIGTRAP when it runs into the breakpoint.
1185 We handle this (in a different place) by restoring the contents of
1186 the breakpointed location (which is only known after it stops),
1187 chasing around to locate the shared libraries that have been
1188 loaded, then resuming.
1190 For SVR4, the debugger interface structure contains a member (r_brk)
1191 which is statically initialized at the time the shared library is
1192 built, to the offset of a function (_r_debug_state) which is guaran-
1193 teed to be called once before mapping in a library, and again when
1194 the mapping is complete. At the time we are examining this member,
1195 it contains only the unrelocated offset of the function, so we have
1196 to do our own relocation. Later, when the dynamic linker actually
1197 runs, it relocates r_brk to be the actual address of _r_debug_state().
1199 The debugger interface structure also contains an enumeration which
1200 is set to either RT_ADD or RT_DELETE prior to changing the mapping,
1201 depending upon whether or not the library is being mapped or unmapped,
1202 and then set to RT_CONSISTENT after the library is mapped/unmapped.
1210 #ifndef SVR4_SHARED_LIBS
1215 /* Get link_dynamic structure */
1217 j
= target_read_memory (debug_base
, (char *) &dynamic_copy
,
1218 sizeof (dynamic_copy
));
1225 /* Calc address of debugger interface structure */
1227 debug_addr
= SOLIB_EXTRACT_ADDRESS (dynamic_copy
.ldd
);
1229 /* Calc address of `in_debugger' member of debugger interface structure */
1231 flag_addr
= debug_addr
+ (CORE_ADDR
) ((char *) &debug_copy
.ldd_in_debugger
-
1232 (char *) &debug_copy
);
1234 /* Write a value of 1 to this member. */
1237 write_memory (flag_addr
, (char *) &in_debugger
, sizeof (in_debugger
));
1240 #else /* SVR4_SHARED_LIBS */
1242 #ifdef BKPT_AT_SYMBOL
1244 struct minimal_symbol
*msymbol
;
1246 asection
*interp_sect
;
1248 /* First, remove all the solib event breakpoints. Their addresses
1249 may have changed since the last time we ran the program. */
1250 remove_solib_event_breakpoints ();
1252 #ifdef SVR4_SHARED_LIBS
1253 interp_text_sect_low
= interp_text_sect_high
= 0;
1254 interp_plt_sect_low
= interp_plt_sect_high
= 0;
1256 /* Find the .interp section; if not found, warn the user and drop
1257 into the old breakpoint at symbol code. */
1258 interp_sect
= bfd_get_section_by_name (exec_bfd
, ".interp");
1261 unsigned int interp_sect_size
;
1263 CORE_ADDR load_addr
;
1264 bfd
*tmp_bfd
= NULL
;
1266 char *tmp_pathname
= NULL
;
1267 CORE_ADDR sym_addr
= 0;
1269 /* Read the contents of the .interp section into a local buffer;
1270 the contents specify the dynamic linker this program uses. */
1271 interp_sect_size
= bfd_section_size (exec_bfd
, interp_sect
);
1272 buf
= alloca (interp_sect_size
);
1273 bfd_get_section_contents (exec_bfd
, interp_sect
,
1274 buf
, 0, interp_sect_size
);
1276 /* Now we need to figure out where the dynamic linker was
1277 loaded so that we can load its symbols and place a breakpoint
1278 in the dynamic linker itself.
1280 This address is stored on the stack. However, I've been unable
1281 to find any magic formula to find it for Solaris (appears to
1282 be trivial on GNU/Linux). Therefore, we have to try an alternate
1283 mechanism to find the dynamic linker's base address. */
1285 tmp_fd
= solib_open (buf
, &tmp_pathname
);
1287 tmp_bfd
= bfd_fdopenr (tmp_pathname
, gnutarget
, tmp_fd
);
1289 if (tmp_bfd
== NULL
)
1290 goto bkpt_at_symbol
;
1292 /* Make sure the dynamic linker's really a useful object. */
1293 if (!bfd_check_format (tmp_bfd
, bfd_object
))
1295 warning ("Unable to grok dynamic linker %s as an object file", buf
);
1296 bfd_close (tmp_bfd
);
1297 goto bkpt_at_symbol
;
1300 /* We find the dynamic linker's base address by examining the
1301 current pc (which point at the entry point for the dynamic
1302 linker) and subtracting the offset of the entry point. */
1303 load_addr
= read_pc () - tmp_bfd
->start_address
;
1305 /* Record the relocated start and end address of the dynamic linker
1306 text and plt section for in_svr4_dynsym_resolve_code. */
1307 interp_sect
= bfd_get_section_by_name (tmp_bfd
, ".text");
1310 interp_text_sect_low
=
1311 bfd_section_vma (tmp_bfd
, interp_sect
) + load_addr
;
1312 interp_text_sect_high
=
1313 interp_text_sect_low
+ bfd_section_size (tmp_bfd
, interp_sect
);
1315 interp_sect
= bfd_get_section_by_name (tmp_bfd
, ".plt");
1318 interp_plt_sect_low
=
1319 bfd_section_vma (tmp_bfd
, interp_sect
) + load_addr
;
1320 interp_plt_sect_high
=
1321 interp_plt_sect_low
+ bfd_section_size (tmp_bfd
, interp_sect
);
1324 /* Now try to set a breakpoint in the dynamic linker. */
1325 for (bkpt_namep
= solib_break_names
; *bkpt_namep
!= NULL
; bkpt_namep
++)
1327 sym_addr
= bfd_lookup_symbol (tmp_bfd
, *bkpt_namep
);
1332 /* We're done with the temporary bfd. */
1333 bfd_close (tmp_bfd
);
1337 create_solib_event_breakpoint (load_addr
+ sym_addr
);
1341 /* For whatever reason we couldn't set a breakpoint in the dynamic
1342 linker. Warn and drop into the old code. */
1344 warning ("Unable to find dynamic linker breakpoint function.\nGDB will be unable to debug shared library initializers\nand track explicitly loaded dynamic code.");
1348 /* Scan through the list of symbols, trying to look up the symbol and
1349 set a breakpoint there. Terminate loop when we/if we succeed. */
1351 breakpoint_addr
= 0;
1352 for (bkpt_namep
= bkpt_names
; *bkpt_namep
!= NULL
; bkpt_namep
++)
1354 msymbol
= lookup_minimal_symbol (*bkpt_namep
, NULL
, symfile_objfile
);
1355 if ((msymbol
!= NULL
) && (SYMBOL_VALUE_ADDRESS (msymbol
) != 0))
1357 create_solib_event_breakpoint (SYMBOL_VALUE_ADDRESS (msymbol
));
1362 /* Nothing good happened. */
1365 #endif /* BKPT_AT_SYMBOL */
1367 #endif /* !SVR4_SHARED_LIBS */
1376 special_symbol_handling -- additional shared library symbol handling
1380 void special_symbol_handling ()
1384 Once the symbols from a shared object have been loaded in the usual
1385 way, we are called to do any system specific symbol handling that
1388 For SunOS4, this consists of grunging around in the dynamic
1389 linkers structures to find symbol definitions for "common" symbols
1390 and adding them to the minimal symbol table for the runtime common
1396 svr4_special_symbol_handling (void)
1398 #ifndef SVR4_SHARED_LIBS
1401 if (debug_addr
== 0)
1403 /* Get link_dynamic structure */
1405 j
= target_read_memory (debug_base
, (char *) &dynamic_copy
,
1406 sizeof (dynamic_copy
));
1413 /* Calc address of debugger interface structure */
1414 /* FIXME, this needs work for cross-debugging of core files
1415 (byteorder, size, alignment, etc). */
1417 debug_addr
= SOLIB_EXTRACT_ADDRESS (dynamic_copy
.ldd
);
1420 /* Read the debugger structure from the inferior, just to make sure
1421 we have a current copy. */
1423 j
= target_read_memory (debug_addr
, (char *) &debug_copy
,
1424 sizeof (debug_copy
));
1426 return; /* unreadable */
1428 /* Get common symbol definitions for the loaded object. */
1430 if (debug_copy
.ldd_cp
)
1432 solib_add_common_symbols (SOLIB_EXTRACT_ADDRESS (debug_copy
.ldd_cp
));
1435 #endif /* !SVR4_SHARED_LIBS */
1438 /* Relocate the main executable. This function should be called upon
1439 stopping the inferior process at the entry point to the program.
1440 The entry point from BFD is compared to the PC and if they are
1441 different, the main executable is relocated by the proper amount.
1443 As written it will only attempt to relocate executables which
1444 lack interpreter sections. It seems likely that only dynamic
1445 linker executables will get relocated, though it should work
1446 properly for a position-independent static executable as well. */
1449 svr4_relocate_main_executable (void)
1451 asection
*interp_sect
;
1452 CORE_ADDR pc
= read_pc ();
1454 /* Decide if the objfile needs to be relocated. As indicated above,
1455 we will only be here when execution is stopped at the beginning
1456 of the program. Relocation is necessary if the address at which
1457 we are presently stopped differs from the start address stored in
1458 the executable AND there's no interpreter section. The condition
1459 regarding the interpreter section is very important because if
1460 there *is* an interpreter section, execution will begin there
1461 instead. When there is an interpreter section, the start address
1462 is (presumably) used by the interpreter at some point to start
1463 execution of the program.
1465 If there is an interpreter, it is normal for it to be set to an
1466 arbitrary address at the outset. The job of finding it is
1467 handled in enable_break().
1469 So, to summarize, relocations are necessary when there is no
1470 interpreter section and the start address obtained from the
1471 executable is different from the address at which GDB is
1474 [ The astute reader will note that we also test to make sure that
1475 the executable in question has the DYNAMIC flag set. It is my
1476 opinion that this test is unnecessary (undesirable even). It
1477 was added to avoid inadvertent relocation of an executable
1478 whose e_type member in the ELF header is not ET_DYN. There may
1479 be a time in the future when it is desirable to do relocations
1480 on other types of files as well in which case this condition
1481 should either be removed or modified to accomodate the new file
1482 type. (E.g, an ET_EXEC executable which has been built to be
1483 position-independent could safely be relocated by the OS if
1484 desired. It is true that this violates the ABI, but the ABI
1485 has been known to be bent from time to time.) - Kevin, Nov 2000. ]
1488 interp_sect
= bfd_get_section_by_name (exec_bfd
, ".interp");
1489 if (interp_sect
== NULL
1490 && (bfd_get_file_flags (exec_bfd
) & DYNAMIC
) != 0
1491 && bfd_get_start_address (exec_bfd
) != pc
)
1493 struct cleanup
*old_chain
;
1494 struct section_offsets
*new_offsets
;
1496 CORE_ADDR displacement
;
1498 /* It is necessary to relocate the objfile. The amount to
1499 relocate by is simply the address at which we are stopped
1500 minus the starting address from the executable.
1502 We relocate all of the sections by the same amount. This
1503 behavior is mandated by recent editions of the System V ABI.
1504 According to the System V Application Binary Interface,
1505 Edition 4.1, page 5-5:
1507 ... Though the system chooses virtual addresses for
1508 individual processes, it maintains the segments' relative
1509 positions. Because position-independent code uses relative
1510 addressesing between segments, the difference between
1511 virtual addresses in memory must match the difference
1512 between virtual addresses in the file. The difference
1513 between the virtual address of any segment in memory and
1514 the corresponding virtual address in the file is thus a
1515 single constant value for any one executable or shared
1516 object in a given process. This difference is the base
1517 address. One use of the base address is to relocate the
1518 memory image of the program during dynamic linking.
1520 The same language also appears in Edition 4.0 of the System V
1521 ABI and is left unspecified in some of the earlier editions. */
1523 displacement
= pc
- bfd_get_start_address (exec_bfd
);
1526 new_offsets
= xcalloc (sizeof (struct section_offsets
),
1527 symfile_objfile
->num_sections
);
1528 old_chain
= make_cleanup (xfree
, new_offsets
);
1530 for (i
= 0; i
< symfile_objfile
->num_sections
; i
++)
1532 if (displacement
!= ANOFFSET (symfile_objfile
->section_offsets
, i
))
1534 new_offsets
->offsets
[i
] = displacement
;
1538 objfile_relocate (symfile_objfile
, new_offsets
);
1540 do_cleanups (old_chain
);
1548 svr4_solib_create_inferior_hook -- shared library startup support
1552 void svr4_solib_create_inferior_hook()
1556 When gdb starts up the inferior, it nurses it along (through the
1557 shell) until it is ready to execute it's first instruction. At this
1558 point, this function gets called via expansion of the macro
1559 SOLIB_CREATE_INFERIOR_HOOK.
1561 For SunOS executables, this first instruction is typically the
1562 one at "_start", or a similar text label, regardless of whether
1563 the executable is statically or dynamically linked. The runtime
1564 startup code takes care of dynamically linking in any shared
1565 libraries, once gdb allows the inferior to continue.
1567 For SVR4 executables, this first instruction is either the first
1568 instruction in the dynamic linker (for dynamically linked
1569 executables) or the instruction at "start" for statically linked
1570 executables. For dynamically linked executables, the system
1571 first exec's /lib/libc.so.N, which contains the dynamic linker,
1572 and starts it running. The dynamic linker maps in any needed
1573 shared libraries, maps in the actual user executable, and then
1574 jumps to "start" in the user executable.
1576 For both SunOS shared libraries, and SVR4 shared libraries, we
1577 can arrange to cooperate with the dynamic linker to discover the
1578 names of shared libraries that are dynamically linked, and the
1579 base addresses to which they are linked.
1581 This function is responsible for discovering those names and
1582 addresses, and saving sufficient information about them to allow
1583 their symbols to be read at a later time.
1587 Between enable_break() and disable_break(), this code does not
1588 properly handle hitting breakpoints which the user might have
1589 set in the startup code or in the dynamic linker itself. Proper
1590 handling will probably have to wait until the implementation is
1591 changed to use the "breakpoint handler function" method.
1593 Also, what if child has exit()ed? Must exit loop somehow.
1597 svr4_solib_create_inferior_hook (void)
1599 /* Relocate the main executable if necessary. */
1600 svr4_relocate_main_executable ();
1602 /* If we are using the BKPT_AT_SYMBOL code, then we don't need the base
1603 yet. In fact, in the case of a SunOS4 executable being run on
1604 Solaris, we can't get it yet. current_sos will get it when it needs
1606 #if !(defined (SVR4_SHARED_LIBS) && defined (BKPT_AT_SYMBOL))
1607 if ((debug_base
= locate_base ()) == 0)
1609 /* Can't find the symbol or the executable is statically linked. */
1614 if (!enable_break ())
1616 warning ("shared library handler failed to enable breakpoint");
1620 #if !defined(SVR4_SHARED_LIBS) || defined(_SCO_DS)
1621 /* SCO and SunOS need the loop below, other systems should be using the
1622 special shared library breakpoints and the shared library breakpoint
1625 Now run the target. It will eventually hit the breakpoint, at
1626 which point all of the libraries will have been mapped in and we
1627 can go groveling around in the dynamic linker structures to find
1628 out what we need to know about them. */
1630 clear_proceed_status ();
1631 stop_soon_quietly
= 1;
1632 stop_signal
= TARGET_SIGNAL_0
;
1635 target_resume (-1, 0, stop_signal
);
1636 wait_for_inferior ();
1638 while (stop_signal
!= TARGET_SIGNAL_TRAP
);
1639 stop_soon_quietly
= 0;
1641 #if !defined(_SCO_DS)
1642 /* We are now either at the "mapping complete" breakpoint (or somewhere
1643 else, a condition we aren't prepared to deal with anyway), so adjust
1644 the PC as necessary after a breakpoint, disable the breakpoint, and
1645 add any shared libraries that were mapped in. */
1647 if (DECR_PC_AFTER_BREAK
)
1649 stop_pc
-= DECR_PC_AFTER_BREAK
;
1650 write_register (PC_REGNUM
, stop_pc
);
1653 if (!disable_break ())
1655 warning ("shared library handler failed to disable breakpoint");
1659 solib_add ((char *) 0, 0, (struct target_ops
*) 0);
1660 #endif /* ! _SCO_DS */
1665 svr4_clear_solib (void)
1671 svr4_free_so (struct so_list
*so
)
1673 xfree (so
->lm_info
->lm
);
1674 xfree (so
->lm_info
);
1678 svr4_relocate_section_addresses (struct so_list
*so
,
1679 struct section_table
*sec
)
1681 sec
->addr
+= LM_ADDR (so
);
1682 sec
->endaddr
+= LM_ADDR (so
);
1685 static struct target_so_ops svr4_so_ops
;
1688 _initialize_svr4_solib (void)
1690 svr4_so_ops
.relocate_section_addresses
= svr4_relocate_section_addresses
;
1691 svr4_so_ops
.free_so
= svr4_free_so
;
1692 svr4_so_ops
.clear_solib
= svr4_clear_solib
;
1693 svr4_so_ops
.solib_create_inferior_hook
= svr4_solib_create_inferior_hook
;
1694 svr4_so_ops
.special_symbol_handling
= svr4_special_symbol_handling
;
1695 svr4_so_ops
.current_sos
= svr4_current_sos
;
1696 svr4_so_ops
.open_symbol_file_object
= open_symbol_file_object
;
1698 /* FIXME: Don't do this here. *_gdbarch_init() should set so_ops. */
1699 current_target_so_ops
= &svr4_so_ops
;