* ax-gdb.c (gen_exp_binop_rest) [BINOP_SUBSCRIPT]: Error out if
[binutils-gdb.git] / gdb / solib-sunos.c
blobe8a1f32488d139c717f8ca4420ce3dd72cc8d930
1 /* Handle SunOS shared libraries for GDB, the GNU Debugger.
3 Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000,
4 2001, 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #include "defs.h"
23 #include <sys/types.h>
24 #include <signal.h>
25 #include "gdb_string.h"
26 #include <sys/param.h>
27 #include <fcntl.h>
29 /* SunOS shared libs need the nlist structure. */
30 #include <a.out.h>
31 #include <link.h>
33 #include "symtab.h"
34 #include "bfd.h"
35 #include "symfile.h"
36 #include "objfiles.h"
37 #include "gdbcore.h"
38 #include "inferior.h"
39 #include "gdbthread.h"
40 #include "solist.h"
41 #include "bcache.h"
42 #include "regcache.h"
44 /* The shared library implementation found on BSD a.out systems is
45 very similar to the SunOS implementation. However, the data
46 structures defined in <link.h> are named very differently. Make up
47 for those differences here. */
49 #ifdef HAVE_STRUCT_SO_MAP_WITH_SOM_MEMBERS
51 /* FIXME: Temporary until the equivalent defines have been removed
52 from all nm-*bsd*.h files. */
53 #ifndef link_dynamic
55 /* Map `struct link_map' and its members. */
56 #define link_map so_map
57 #define lm_addr som_addr
58 #define lm_name som_path
59 #define lm_next som_next
61 /* Map `struct link_dynamic_2' and its members. */
62 #define link_dynamic_2 section_dispatch_table
63 #define ld_loaded sdt_loaded
65 /* Map `struct rtc_symb' and its members. */
66 #define rtc_symb rt_symbol
67 #define rtc_sp rt_sp
68 #define rtc_next rt_next
70 /* Map `struct ld_debug' and its members. */
71 #define ld_debug so_debug
72 #define ldd_in_debugger dd_in_debugger
73 #define ldd_bp_addr dd_bpt_addr
74 #define ldd_bp_inst dd_bpt_shadow
75 #define ldd_cp dd_cc
77 /* Map `struct link_dynamic' and its members. */
78 #define link_dynamic _dynamic
79 #define ld_version d_version
80 #define ldd d_debug
81 #define ld_un d_un
82 #define ld_2 d_sdt
84 #endif
86 #endif
88 /* Link map info to include in an allocated so_list entry */
90 struct lm_info
92 /* Pointer to copy of link map from inferior. The type is char *
93 rather than void *, so that we may use byte offsets to find the
94 various fields without the need for a cast. */
95 char *lm;
99 /* Symbols which are used to locate the base of the link map structures. */
101 static char *debug_base_symbols[] =
103 "_DYNAMIC",
104 "_DYNAMIC__MGC",
105 NULL
108 static char *main_name_list[] =
110 "main_$main",
111 NULL
114 /* Macro to extract an address from a solib structure. When GDB is
115 configured for some 32-bit targets (e.g. Solaris 2.7 sparc), BFD is
116 configured to handle 64-bit targets, so CORE_ADDR is 64 bits. We
117 have to extract only the significant bits of addresses to get the
118 right address when accessing the core file BFD.
120 Assume that the address is unsigned. */
122 #define SOLIB_EXTRACT_ADDRESS(MEMBER) \
123 extract_unsigned_integer (&(MEMBER), sizeof (MEMBER), \
124 gdbarch_byte_order (target_gdbarch))
126 /* local data declarations */
128 static struct link_dynamic dynamic_copy;
129 static struct link_dynamic_2 ld_2_copy;
130 static struct ld_debug debug_copy;
131 static CORE_ADDR debug_addr;
132 static CORE_ADDR flag_addr;
134 #ifndef offsetof
135 #define offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER)
136 #endif
137 #define fieldsize(TYPE, MEMBER) (sizeof (((TYPE *)0)->MEMBER))
139 /* link map access functions */
141 static CORE_ADDR
142 LM_ADDR (struct so_list *so)
144 enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
145 int lm_addr_offset = offsetof (struct link_map, lm_addr);
146 int lm_addr_size = fieldsize (struct link_map, lm_addr);
148 return (CORE_ADDR) extract_signed_integer (so->lm_info->lm + lm_addr_offset,
149 lm_addr_size, byte_order);
152 static CORE_ADDR
153 LM_NEXT (struct so_list *so)
155 enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
156 int lm_next_offset = offsetof (struct link_map, lm_next);
157 int lm_next_size = fieldsize (struct link_map, lm_next);
159 /* Assume that the address is unsigned. */
160 return extract_unsigned_integer (so->lm_info->lm + lm_next_offset,
161 lm_next_size, byte_order);
164 static CORE_ADDR
165 LM_NAME (struct so_list *so)
167 enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
168 int lm_name_offset = offsetof (struct link_map, lm_name);
169 int lm_name_size = fieldsize (struct link_map, lm_name);
171 /* Assume that the address is unsigned. */
172 return extract_unsigned_integer (so->lm_info->lm + lm_name_offset,
173 lm_name_size, byte_order);
176 static CORE_ADDR debug_base; /* Base of dynamic linker structures */
178 /* Local function prototypes */
180 static int match_main (char *);
182 /* Allocate the runtime common object file. */
184 static void
185 allocate_rt_common_objfile (void)
187 struct objfile *objfile;
188 struct objfile *last_one;
190 objfile = (struct objfile *) xmalloc (sizeof (struct objfile));
191 memset (objfile, 0, sizeof (struct objfile));
192 objfile->psymbol_cache = bcache_xmalloc ();
193 objfile->macro_cache = bcache_xmalloc ();
194 objfile->filename_cache = bcache_xmalloc ();
195 obstack_init (&objfile->objfile_obstack);
196 objfile->name = xstrdup ("rt_common");
198 /* Add this file onto the tail of the linked list of other such files. */
200 objfile->next = NULL;
201 if (object_files == NULL)
202 object_files = objfile;
203 else
205 for (last_one = object_files;
206 last_one->next;
207 last_one = last_one->next);
208 last_one->next = objfile;
211 rt_common_objfile = objfile;
214 /* Read all dynamically loaded common symbol definitions from the inferior
215 and put them into the minimal symbol table for the runtime common
216 objfile. */
218 static void
219 solib_add_common_symbols (CORE_ADDR rtc_symp)
221 struct rtc_symb inferior_rtc_symb;
222 struct nlist inferior_rtc_nlist;
223 int len;
224 char *name;
226 /* Remove any runtime common symbols from previous runs. */
228 if (rt_common_objfile != NULL && rt_common_objfile->minimal_symbol_count)
230 obstack_free (&rt_common_objfile->objfile_obstack, 0);
231 obstack_init (&rt_common_objfile->objfile_obstack);
232 rt_common_objfile->minimal_symbol_count = 0;
233 rt_common_objfile->msymbols = NULL;
234 terminate_minimal_symbol_table (rt_common_objfile);
237 init_minimal_symbol_collection ();
238 make_cleanup_discard_minimal_symbols ();
240 while (rtc_symp)
242 read_memory (rtc_symp,
243 (char *) &inferior_rtc_symb,
244 sizeof (inferior_rtc_symb));
245 read_memory (SOLIB_EXTRACT_ADDRESS (inferior_rtc_symb.rtc_sp),
246 (char *) &inferior_rtc_nlist,
247 sizeof (inferior_rtc_nlist));
248 if (inferior_rtc_nlist.n_type == N_COMM)
250 /* FIXME: The length of the symbol name is not available, but in the
251 current implementation the common symbol is allocated immediately
252 behind the name of the symbol. */
253 len = inferior_rtc_nlist.n_value - inferior_rtc_nlist.n_un.n_strx;
255 name = xmalloc (len);
256 read_memory (SOLIB_EXTRACT_ADDRESS (inferior_rtc_nlist.n_un.n_name),
257 name, len);
259 /* Allocate the runtime common objfile if necessary. */
260 if (rt_common_objfile == NULL)
261 allocate_rt_common_objfile ();
263 prim_record_minimal_symbol (name, inferior_rtc_nlist.n_value,
264 mst_bss, rt_common_objfile);
265 xfree (name);
267 rtc_symp = SOLIB_EXTRACT_ADDRESS (inferior_rtc_symb.rtc_next);
270 /* Install any minimal symbols that have been collected as the current
271 minimal symbols for the runtime common objfile. */
273 install_minimal_symbols (rt_common_objfile);
279 LOCAL FUNCTION
281 locate_base -- locate the base address of dynamic linker structs
283 SYNOPSIS
285 CORE_ADDR locate_base (void)
287 DESCRIPTION
289 For both the SunOS and SVR4 shared library implementations, if the
290 inferior executable has been linked dynamically, there is a single
291 address somewhere in the inferior's data space which is the key to
292 locating all of the dynamic linker's runtime structures. This
293 address is the value of the debug base symbol. The job of this
294 function is to find and return that address, or to return 0 if there
295 is no such address (the executable is statically linked for example).
297 For SunOS, the job is almost trivial, since the dynamic linker and
298 all of it's structures are statically linked to the executable at
299 link time. Thus the symbol for the address we are looking for has
300 already been added to the minimal symbol table for the executable's
301 objfile at the time the symbol file's symbols were read, and all we
302 have to do is look it up there. Note that we explicitly do NOT want
303 to find the copies in the shared library.
305 The SVR4 version is a bit more complicated because the address
306 is contained somewhere in the dynamic info section. We have to go
307 to a lot more work to discover the address of the debug base symbol.
308 Because of this complexity, we cache the value we find and return that
309 value on subsequent invocations. Note there is no copy in the
310 executable symbol tables.
314 static CORE_ADDR
315 locate_base (void)
317 struct minimal_symbol *msymbol;
318 CORE_ADDR address = 0;
319 char **symbolp;
321 /* For SunOS, we want to limit the search for the debug base symbol to the
322 executable being debugged, since there is a duplicate named symbol in the
323 shared library. We don't want the shared library versions. */
325 for (symbolp = debug_base_symbols; *symbolp != NULL; symbolp++)
327 msymbol = lookup_minimal_symbol (*symbolp, NULL, symfile_objfile);
328 if ((msymbol != NULL) && (SYMBOL_VALUE_ADDRESS (msymbol) != 0))
330 address = SYMBOL_VALUE_ADDRESS (msymbol);
331 return (address);
334 return (0);
339 LOCAL FUNCTION
341 first_link_map_member -- locate first member in dynamic linker's map
343 SYNOPSIS
345 static CORE_ADDR first_link_map_member (void)
347 DESCRIPTION
349 Find the first element in the inferior's dynamic link map, and
350 return its address in the inferior. This function doesn't copy the
351 link map entry itself into our address space; current_sos actually
352 does the reading. */
354 static CORE_ADDR
355 first_link_map_member (void)
357 CORE_ADDR lm = 0;
359 read_memory (debug_base, (char *) &dynamic_copy, sizeof (dynamic_copy));
360 if (dynamic_copy.ld_version >= 2)
362 /* It is a version that we can deal with, so read in the secondary
363 structure and find the address of the link map list from it. */
364 read_memory (SOLIB_EXTRACT_ADDRESS (dynamic_copy.ld_un.ld_2),
365 (char *) &ld_2_copy, sizeof (struct link_dynamic_2));
366 lm = SOLIB_EXTRACT_ADDRESS (ld_2_copy.ld_loaded);
368 return (lm);
371 static int
372 open_symbol_file_object (void *from_ttyp)
374 return 1;
378 /* LOCAL FUNCTION
380 current_sos -- build a list of currently loaded shared objects
382 SYNOPSIS
384 struct so_list *current_sos ()
386 DESCRIPTION
388 Build a list of `struct so_list' objects describing the shared
389 objects currently loaded in the inferior. This list does not
390 include an entry for the main executable file.
392 Note that we only gather information directly available from the
393 inferior --- we don't examine any of the shared library files
394 themselves. The declaration of `struct so_list' says which fields
395 we provide values for. */
397 static struct so_list *
398 sunos_current_sos (void)
400 CORE_ADDR lm;
401 struct so_list *head = 0;
402 struct so_list **link_ptr = &head;
403 int errcode;
404 char *buffer;
406 /* Make sure we've looked up the inferior's dynamic linker's base
407 structure. */
408 if (! debug_base)
410 debug_base = locate_base ();
412 /* If we can't find the dynamic linker's base structure, this
413 must not be a dynamically linked executable. Hmm. */
414 if (! debug_base)
415 return 0;
418 /* Walk the inferior's link map list, and build our list of
419 `struct so_list' nodes. */
420 lm = first_link_map_member ();
421 while (lm)
423 struct so_list *new
424 = (struct so_list *) xmalloc (sizeof (struct so_list));
425 struct cleanup *old_chain = make_cleanup (xfree, new);
427 memset (new, 0, sizeof (*new));
429 new->lm_info = xmalloc (sizeof (struct lm_info));
430 make_cleanup (xfree, new->lm_info);
432 new->lm_info->lm = xmalloc (sizeof (struct link_map));
433 make_cleanup (xfree, new->lm_info->lm);
434 memset (new->lm_info->lm, 0, sizeof (struct link_map));
436 read_memory (lm, new->lm_info->lm, sizeof (struct link_map));
438 lm = LM_NEXT (new);
440 /* Extract this shared object's name. */
441 target_read_string (LM_NAME (new), &buffer,
442 SO_NAME_MAX_PATH_SIZE - 1, &errcode);
443 if (errcode != 0)
444 warning (_("Can't read pathname for load map: %s."),
445 safe_strerror (errcode));
446 else
448 strncpy (new->so_name, buffer, SO_NAME_MAX_PATH_SIZE - 1);
449 new->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
450 xfree (buffer);
451 strcpy (new->so_original_name, new->so_name);
454 /* If this entry has no name, or its name matches the name
455 for the main executable, don't include it in the list. */
456 if (! new->so_name[0]
457 || match_main (new->so_name))
458 free_so (new);
459 else
461 new->next = 0;
462 *link_ptr = new;
463 link_ptr = &new->next;
466 discard_cleanups (old_chain);
469 return head;
473 /* On some systems, the only way to recognize the link map entry for
474 the main executable file is by looking at its name. Return
475 non-zero iff SONAME matches one of the known main executable names. */
477 static int
478 match_main (char *soname)
480 char **mainp;
482 for (mainp = main_name_list; *mainp != NULL; mainp++)
484 if (strcmp (soname, *mainp) == 0)
485 return (1);
488 return (0);
492 static int
493 sunos_in_dynsym_resolve_code (CORE_ADDR pc)
495 return 0;
500 LOCAL FUNCTION
502 disable_break -- remove the "mapping changed" breakpoint
504 SYNOPSIS
506 static int disable_break ()
508 DESCRIPTION
510 Removes the breakpoint that gets hit when the dynamic linker
511 completes a mapping change.
515 static int
516 disable_break (void)
518 CORE_ADDR breakpoint_addr; /* Address where end bkpt is set */
520 int in_debugger = 0;
522 /* Read the debugger structure from the inferior to retrieve the
523 address of the breakpoint and the original contents of the
524 breakpoint address. Remove the breakpoint by writing the original
525 contents back. */
527 read_memory (debug_addr, (char *) &debug_copy, sizeof (debug_copy));
529 /* Set `in_debugger' to zero now. */
531 write_memory (flag_addr, (char *) &in_debugger, sizeof (in_debugger));
533 breakpoint_addr = SOLIB_EXTRACT_ADDRESS (debug_copy.ldd_bp_addr);
534 write_memory (breakpoint_addr, (char *) &debug_copy.ldd_bp_inst,
535 sizeof (debug_copy.ldd_bp_inst));
537 /* For the SVR4 version, we always know the breakpoint address. For the
538 SunOS version we don't know it until the above code is executed.
539 Grumble if we are stopped anywhere besides the breakpoint address. */
541 if (stop_pc != breakpoint_addr)
543 warning (_("stopped at unknown breakpoint while handling shared libraries"));
546 return 1;
552 LOCAL FUNCTION
554 enable_break -- arrange for dynamic linker to hit breakpoint
556 SYNOPSIS
558 int enable_break (void)
560 DESCRIPTION
562 Both the SunOS and the SVR4 dynamic linkers have, as part of their
563 debugger interface, support for arranging for the inferior to hit
564 a breakpoint after mapping in the shared libraries. This function
565 enables that breakpoint.
567 For SunOS, there is a special flag location (in_debugger) which we
568 set to 1. When the dynamic linker sees this flag set, it will set
569 a breakpoint at a location known only to itself, after saving the
570 original contents of that place and the breakpoint address itself,
571 in it's own internal structures. When we resume the inferior, it
572 will eventually take a SIGTRAP when it runs into the breakpoint.
573 We handle this (in a different place) by restoring the contents of
574 the breakpointed location (which is only known after it stops),
575 chasing around to locate the shared libraries that have been
576 loaded, then resuming.
578 For SVR4, the debugger interface structure contains a member (r_brk)
579 which is statically initialized at the time the shared library is
580 built, to the offset of a function (_r_debug_state) which is guaran-
581 teed to be called once before mapping in a library, and again when
582 the mapping is complete. At the time we are examining this member,
583 it contains only the unrelocated offset of the function, so we have
584 to do our own relocation. Later, when the dynamic linker actually
585 runs, it relocates r_brk to be the actual address of _r_debug_state().
587 The debugger interface structure also contains an enumeration which
588 is set to either RT_ADD or RT_DELETE prior to changing the mapping,
589 depending upon whether or not the library is being mapped or unmapped,
590 and then set to RT_CONSISTENT after the library is mapped/unmapped.
593 static int
594 enable_break (void)
596 int success = 0;
597 int j;
598 int in_debugger;
600 /* Get link_dynamic structure */
602 j = target_read_memory (debug_base, (char *) &dynamic_copy,
603 sizeof (dynamic_copy));
604 if (j)
606 /* unreadable */
607 return (0);
610 /* Calc address of debugger interface structure */
612 debug_addr = SOLIB_EXTRACT_ADDRESS (dynamic_copy.ldd);
614 /* Calc address of `in_debugger' member of debugger interface structure */
616 flag_addr = debug_addr + (CORE_ADDR) ((char *) &debug_copy.ldd_in_debugger -
617 (char *) &debug_copy);
619 /* Write a value of 1 to this member. */
621 in_debugger = 1;
622 write_memory (flag_addr, (char *) &in_debugger, sizeof (in_debugger));
623 success = 1;
625 return (success);
630 LOCAL FUNCTION
632 special_symbol_handling -- additional shared library symbol handling
634 SYNOPSIS
636 void special_symbol_handling ()
638 DESCRIPTION
640 Once the symbols from a shared object have been loaded in the usual
641 way, we are called to do any system specific symbol handling that
642 is needed.
644 For SunOS4, this consists of grunging around in the dynamic
645 linkers structures to find symbol definitions for "common" symbols
646 and adding them to the minimal symbol table for the runtime common
647 objfile.
651 static void
652 sunos_special_symbol_handling (void)
654 int j;
656 if (debug_addr == 0)
658 /* Get link_dynamic structure */
660 j = target_read_memory (debug_base, (char *) &dynamic_copy,
661 sizeof (dynamic_copy));
662 if (j)
664 /* unreadable */
665 return;
668 /* Calc address of debugger interface structure */
669 /* FIXME, this needs work for cross-debugging of core files
670 (byteorder, size, alignment, etc). */
672 debug_addr = SOLIB_EXTRACT_ADDRESS (dynamic_copy.ldd);
675 /* Read the debugger structure from the inferior, just to make sure
676 we have a current copy. */
678 j = target_read_memory (debug_addr, (char *) &debug_copy,
679 sizeof (debug_copy));
680 if (j)
681 return; /* unreadable */
683 /* Get common symbol definitions for the loaded object. */
685 if (debug_copy.ldd_cp)
687 solib_add_common_symbols (SOLIB_EXTRACT_ADDRESS (debug_copy.ldd_cp));
693 GLOBAL FUNCTION
695 sunos_solib_create_inferior_hook -- shared library startup support
697 SYNOPSIS
699 void sunos_solib_create_inferior_hook ()
701 DESCRIPTION
703 When gdb starts up the inferior, it nurses it along (through the
704 shell) until it is ready to execute it's first instruction. At this
705 point, this function gets called via expansion of the macro
706 SOLIB_CREATE_INFERIOR_HOOK.
708 For SunOS executables, this first instruction is typically the
709 one at "_start", or a similar text label, regardless of whether
710 the executable is statically or dynamically linked. The runtime
711 startup code takes care of dynamically linking in any shared
712 libraries, once gdb allows the inferior to continue.
714 For SVR4 executables, this first instruction is either the first
715 instruction in the dynamic linker (for dynamically linked
716 executables) or the instruction at "start" for statically linked
717 executables. For dynamically linked executables, the system
718 first exec's /lib/libc.so.N, which contains the dynamic linker,
719 and starts it running. The dynamic linker maps in any needed
720 shared libraries, maps in the actual user executable, and then
721 jumps to "start" in the user executable.
723 For both SunOS shared libraries, and SVR4 shared libraries, we
724 can arrange to cooperate with the dynamic linker to discover the
725 names of shared libraries that are dynamically linked, and the
726 base addresses to which they are linked.
728 This function is responsible for discovering those names and
729 addresses, and saving sufficient information about them to allow
730 their symbols to be read at a later time.
732 FIXME
734 Between enable_break() and disable_break(), this code does not
735 properly handle hitting breakpoints which the user might have
736 set in the startup code or in the dynamic linker itself. Proper
737 handling will probably have to wait until the implementation is
738 changed to use the "breakpoint handler function" method.
740 Also, what if child has exit()ed? Must exit loop somehow.
743 static void
744 sunos_solib_create_inferior_hook (int from_tty)
746 struct thread_info *tp;
747 struct inferior *inf;
749 if ((debug_base = locate_base ()) == 0)
751 /* Can't find the symbol or the executable is statically linked. */
752 return;
755 if (!enable_break ())
757 warning (_("shared library handler failed to enable breakpoint"));
758 return;
761 /* SCO and SunOS need the loop below, other systems should be using the
762 special shared library breakpoints and the shared library breakpoint
763 service routine.
765 Now run the target. It will eventually hit the breakpoint, at
766 which point all of the libraries will have been mapped in and we
767 can go groveling around in the dynamic linker structures to find
768 out what we need to know about them. */
770 inf = current_inferior ();
771 tp = inferior_thread ();
773 clear_proceed_status ();
775 inf->stop_soon = STOP_QUIETLY;
776 tp->stop_signal = TARGET_SIGNAL_0;
779 target_resume (pid_to_ptid (-1), 0, tp->stop_signal);
780 wait_for_inferior (0);
782 while (tp->stop_signal != TARGET_SIGNAL_TRAP);
783 inf->stop_soon = NO_STOP_QUIETLY;
785 /* We are now either at the "mapping complete" breakpoint (or somewhere
786 else, a condition we aren't prepared to deal with anyway), so adjust
787 the PC as necessary after a breakpoint, disable the breakpoint, and
788 add any shared libraries that were mapped in.
790 Note that adjust_pc_after_break did not perform any PC adjustment,
791 as the breakpoint the inferior just hit was not inserted by GDB,
792 but by the dynamic loader itself, and is therefore not found on
793 the GDB software break point list. Thus we have to adjust the
794 PC here. */
796 if (gdbarch_decr_pc_after_break (target_gdbarch))
798 stop_pc -= gdbarch_decr_pc_after_break (target_gdbarch);
799 regcache_write_pc (get_current_regcache (), stop_pc);
802 if (!disable_break ())
804 warning (_("shared library handler failed to disable breakpoint"));
807 solib_add ((char *) 0, 0, (struct target_ops *) 0, auto_solib_add);
810 static void
811 sunos_clear_solib (void)
813 debug_base = 0;
816 static void
817 sunos_free_so (struct so_list *so)
819 xfree (so->lm_info->lm);
820 xfree (so->lm_info);
823 static void
824 sunos_relocate_section_addresses (struct so_list *so,
825 struct target_section *sec)
827 sec->addr += LM_ADDR (so);
828 sec->endaddr += LM_ADDR (so);
831 static struct target_so_ops sunos_so_ops;
833 void
834 _initialize_sunos_solib (void)
836 sunos_so_ops.relocate_section_addresses = sunos_relocate_section_addresses;
837 sunos_so_ops.free_so = sunos_free_so;
838 sunos_so_ops.clear_solib = sunos_clear_solib;
839 sunos_so_ops.solib_create_inferior_hook = sunos_solib_create_inferior_hook;
840 sunos_so_ops.special_symbol_handling = sunos_special_symbol_handling;
841 sunos_so_ops.current_sos = sunos_current_sos;
842 sunos_so_ops.open_symbol_file_object = open_symbol_file_object;
843 sunos_so_ops.in_dynsym_resolve_code = sunos_in_dynsym_resolve_code;
844 sunos_so_ops.bfd_open = solib_bfd_open;
846 /* FIXME: Don't do this here. *_gdbarch_init() should set so_ops. */
847 current_target_so_ops = &sunos_so_ops;