1 /* Handle SOM shared libraries for GDB, the GNU Debugger.
3 Copyright 2004 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. */
32 #include "hppa-tdep.h"
37 /* These ought to be defined in some public interface, but aren't. They
38 define the meaning of the various bits in the distinguished __dld_flags
39 variable that is declared in every debuggable a.out on HP-UX, and that
40 is shared between the debugger and the dynamic linker.
42 #define DLD_FLAGS_MAPPRIVATE 0x1
43 #define DLD_FLAGS_HOOKVALID 0x2
44 #define DLD_FLAGS_LISTVALID 0x4
45 #define DLD_FLAGS_BOR_ENABLE 0x8
49 /* Version of this structure (it is expected to change again in hpux10). */
50 unsigned char struct_version;
52 /* Binding mode for this library. */
53 unsigned char bind_mode;
55 /* Version of this library. */
56 short library_version;
58 /* Start of text address,
59 link-time text location (length of text area),
60 end of text address. */
62 CORE_ADDR text_link_addr;
65 /* Start of data, start of bss and end of data. */
70 /* Value of linkage pointer (%r19). */
73 /* Address in target of offset from thread-local register of
74 start of this thread's data. I.e., the first thread-local
75 variable in this shared library starts at *(tsd_start_addr)
76 from that area pointed to by cr27 (mpsfu_hi).
78 We do the indirection as soon as we read it, so from then
79 on it's the offset itself. */
80 CORE_ADDR tsd_start_addr;
82 /* Address of the link map entry in the loader. */
86 /* These addresses should be filled in by som_solib_create_inferior_hook.
87 They are also used elsewhere in this module.
92 struct unwind_table_entry *unwind;
96 /* When adding fields, be sure to clear them in _initialize_som_solib. */
100 addr_and_unwind_t hook;
101 addr_and_unwind_t hook_stub;
102 addr_and_unwind_t load;
103 addr_and_unwind_t load_stub;
104 addr_and_unwind_t unload;
105 addr_and_unwind_t unload2;
106 addr_and_unwind_t unload_stub;
111 som_relocate_section_addresses (struct so_list *so,
112 struct section_table *sec)
114 flagword aflag = bfd_get_section_flags(so->abfd, sec->the_bfd_section);
116 /* solib.c does something similar, but it only recognizes ".text", SOM calls
117 the text section "$CODE$". */
118 if (strcmp (sec->the_bfd_section->name, "$CODE$") == 0)
120 so->textsection = sec;
123 if (aflag & SEC_CODE)
125 sec->addr += so->lm_info->text_addr - so->lm_info->text_link_addr;
126 sec->endaddr += so->lm_info->text_addr - so->lm_info->text_link_addr;
128 else if (aflag & SEC_DATA)
130 sec->addr += so->lm_info->data_start;
131 sec->endaddr += so->lm_info->data_start;
137 /* This hook gets called just before the first instruction in the
138 inferior process is executed.
140 This is our opportunity to set magic flags in the inferior so
141 that GDB can be notified when a shared library is mapped in and
142 to tell the dynamic linker that a private copy of the library is
143 needed (so GDB can set breakpoints in the library).
145 __dld_flags is the location of the magic flags; as of this implementation
146 there are 3 flags of interest:
148 bit 0 when set indicates that private copies of the libraries are needed
149 bit 1 when set indicates that the callback hook routine is valid
150 bit 2 when set indicates that the dynamic linker should maintain the
151 __dld_list structure when loading/unloading libraries.
153 Note that shared libraries are not mapped in at this time, so we have
154 run the inferior until the libraries are mapped in. Typically this
155 means running until the "_start" is called. */
158 som_solib_create_inferior_hook (void)
160 struct minimal_symbol *msymbol;
161 unsigned int dld_flags, status, have_endo;
162 asection *shlib_info;
164 struct objfile *objfile;
167 /* First, remove all the solib event breakpoints. Their addresses
168 may have changed since the last time we ran the program. */
169 remove_solib_event_breakpoints ();
171 if (symfile_objfile == NULL)
174 /* First see if the objfile was dynamically linked. */
175 shlib_info = bfd_get_section_by_name (symfile_objfile->obfd, "$SHLIB_INFO$");
179 /* It's got a $SHLIB_INFO$ section, make sure it's not empty. */
180 if (bfd_section_size (symfile_objfile->obfd, shlib_info) == 0)
184 /* Slam the pid of the process into __d_pid.
186 We used to warn when this failed, but that warning is only useful
187 on very old HP systems (hpux9 and older). The warnings are an
188 annoyance to users of modern systems and foul up the testsuite as
189 well. As a result, the warnings have been disabled. */
190 msymbol = lookup_minimal_symbol ("__d_pid", NULL, symfile_objfile);
194 anaddr = SYMBOL_VALUE_ADDRESS (msymbol);
195 store_unsigned_integer (buf, 4, PIDGET (inferior_ptid));
196 status = target_write_memory (anaddr, buf, 4);
199 warning ("Unable to write __d_pid");
200 warning ("Suggest linking with /opt/langtools/lib/end.o.");
201 warning ("GDB will be unable to track shl_load/shl_unload calls");
205 /* Get the value of _DLD_HOOK (an export stub) and put it in __dld_hook;
206 This will force the dynamic linker to call __d_trap when significant
209 Note that the above is the pre-HP-UX 9.0 behaviour. At 9.0 and above,
210 the dld provides an export stub named "__d_trap" as well as the
211 function named "__d_trap" itself, but doesn't provide "_DLD_HOOK".
212 We'll look first for the old flavor and then the new.
214 msymbol = lookup_minimal_symbol ("_DLD_HOOK", NULL, symfile_objfile);
216 msymbol = lookup_minimal_symbol ("__d_trap", NULL, symfile_objfile);
219 warning ("Unable to find _DLD_HOOK symbol in object file.");
220 warning ("Suggest linking with /opt/langtools/lib/end.o.");
221 warning ("GDB will be unable to track shl_load/shl_unload calls");
224 anaddr = SYMBOL_VALUE_ADDRESS (msymbol);
225 dld_cache.hook.address = anaddr;
227 /* Grrr, this might not be an export symbol! We have to find the
229 ALL_OBJFILES (objfile)
231 struct unwind_table_entry *u;
232 struct minimal_symbol *msymbol2;
236 lookup_minimal_symbol_solib_trampoline (SYMBOL_LINKAGE_NAME (msymbol),
238 /* Found a symbol with the right name. */
241 struct unwind_table_entry *u;
242 /* It must be a shared library trampoline. */
243 if (SYMBOL_TYPE (msymbol2) != mst_solib_trampoline)
246 /* It must also be an export stub. */
247 u = find_unwind_entry (SYMBOL_VALUE (msymbol2));
248 if (!u || u->stub_unwind.stub_type != EXPORT)
251 /* OK. Looks like the correct import stub. */
252 anaddr = SYMBOL_VALUE (msymbol2);
253 dld_cache.hook_stub.address = anaddr;
256 store_unsigned_integer (buf, 4, anaddr);
258 msymbol = lookup_minimal_symbol ("__dld_hook", NULL, symfile_objfile);
261 warning ("Unable to find __dld_hook symbol in object file.");
262 warning ("Suggest linking with /opt/langtools/lib/end.o.");
263 warning ("GDB will be unable to track shl_load/shl_unload calls");
266 anaddr = SYMBOL_VALUE_ADDRESS (msymbol);
267 status = target_write_memory (anaddr, buf, 4);
269 /* Now set a shlib_event breakpoint at __d_trap so we can track
270 significant shared library events. */
271 msymbol = lookup_minimal_symbol ("__d_trap", NULL, symfile_objfile);
274 warning ("Unable to find __dld_d_trap symbol in object file.");
275 warning ("Suggest linking with /opt/langtools/lib/end.o.");
276 warning ("GDB will be unable to track shl_load/shl_unload calls");
279 create_solib_event_breakpoint (SYMBOL_VALUE_ADDRESS (msymbol));
281 /* We have all the support usually found in end.o, so we can track
282 shl_load and shl_unload calls. */
287 /* Get the address of __dld_flags, if no such symbol exists, then we can
288 not debug the shared code. */
289 msymbol = lookup_minimal_symbol ("__dld_flags", NULL, NULL);
292 error ("Unable to find __dld_flags symbol in object file.\n");
295 anaddr = SYMBOL_VALUE_ADDRESS (msymbol);
297 /* Read the current contents. */
298 status = target_read_memory (anaddr, buf, 4);
301 error ("Unable to read __dld_flags\n");
303 dld_flags = extract_unsigned_integer (buf, 4);
305 /* Turn on the flags we care about. */
306 dld_flags |= DLD_FLAGS_MAPPRIVATE;
308 dld_flags |= DLD_FLAGS_HOOKVALID;
309 store_unsigned_integer (buf, 4, dld_flags);
310 status = target_write_memory (anaddr, buf, 4);
313 error ("Unable to write __dld_flags\n");
316 /* Now find the address of _start and set a breakpoint there.
317 We still need this code for two reasons:
319 * Not all sites have /opt/langtools/lib/end.o, so it's not always
320 possible to track the dynamic linker's events.
322 * At this time no events are triggered for shared libraries
323 loaded at startup time (what a crock). */
325 msymbol = lookup_minimal_symbol ("_start", NULL, symfile_objfile);
328 error ("Unable to find _start symbol in object file.\n");
331 anaddr = SYMBOL_VALUE_ADDRESS (msymbol);
333 /* Make the breakpoint at "_start" a shared library event breakpoint. */
334 create_solib_event_breakpoint (anaddr);
336 clear_symtab_users ();
339 /* This operation removes the "hook" between GDB and the dynamic linker,
340 which causes the dld to notify GDB of shared library events.
342 After this operation completes, the dld will no longer notify GDB of
343 shared library events. To resume notifications, GDB must call
344 som_solib_create_inferior_hook.
346 This operation does not remove any knowledge of shared libraries which
347 GDB may already have been notified of.
350 som_solib_remove_inferior_hook (int pid)
353 struct minimal_symbol *msymbol;
355 char dld_flags_buffer[4];
356 unsigned int dld_flags_value;
357 struct cleanup *old_cleanups = save_inferior_ptid ();
359 /* Ensure that we're really operating on the specified process. */
360 inferior_ptid = pid_to_ptid (pid);
362 /* We won't bother to remove the solib breakpoints from this process.
364 In fact, on PA64 the breakpoint is hard-coded into the dld callback,
365 and thus we're not supposed to remove it.
367 Rather, we'll merely clear the dld_flags bit that enables callbacks.
369 msymbol = lookup_minimal_symbol ("__dld_flags", NULL, NULL);
371 addr = SYMBOL_VALUE_ADDRESS (msymbol);
372 status = target_read_memory (addr, dld_flags_buffer, 4);
374 dld_flags_value = extract_unsigned_integer (dld_flags_buffer, 4);
376 dld_flags_value &= ~DLD_FLAGS_HOOKVALID;
377 store_unsigned_integer (dld_flags_buffer, 4, dld_flags_value);
378 status = target_write_memory (addr, dld_flags_buffer, 4);
380 do_cleanups (old_cleanups);
384 som_special_symbol_handling (void)
389 som_solib_desire_dynamic_linker_symbols (void)
391 struct objfile *objfile;
392 struct unwind_table_entry *u;
393 struct minimal_symbol *dld_msymbol;
395 /* Do we already know the value of these symbols? If so, then
398 (If you add clauses to this test, be sure to likewise update the
399 test within the loop.)
401 if (dld_cache.is_valid)
404 ALL_OBJFILES (objfile)
406 dld_msymbol = lookup_minimal_symbol ("shl_load", NULL, objfile);
407 if (dld_msymbol != NULL)
409 dld_cache.load.address = SYMBOL_VALUE (dld_msymbol);
410 dld_cache.load.unwind = find_unwind_entry (dld_cache.load.address);
413 dld_msymbol = lookup_minimal_symbol_solib_trampoline ("shl_load",
415 if (dld_msymbol != NULL)
417 if (SYMBOL_TYPE (dld_msymbol) == mst_solib_trampoline)
419 u = find_unwind_entry (SYMBOL_VALUE (dld_msymbol));
420 if ((u != NULL) && (u->stub_unwind.stub_type == EXPORT))
422 dld_cache.load_stub.address = SYMBOL_VALUE (dld_msymbol);
423 dld_cache.load_stub.unwind = u;
428 dld_msymbol = lookup_minimal_symbol ("shl_unload", NULL, objfile);
429 if (dld_msymbol != NULL)
431 dld_cache.unload.address = SYMBOL_VALUE (dld_msymbol);
432 dld_cache.unload.unwind = find_unwind_entry (dld_cache.unload.address);
434 /* ??rehrauer: I'm not sure exactly what this is, but it appears
435 that on some HPUX 10.x versions, there's two unwind regions to
436 cover the body of "shl_unload", the second being 4 bytes past
437 the end of the first. This is a large hack to handle that
438 case, but since I don't seem to have any legitimate way to
439 look for this thing via the symbol table...
441 if (dld_cache.unload.unwind != NULL)
443 u = find_unwind_entry (dld_cache.unload.unwind->region_end + 4);
446 dld_cache.unload2.address = u->region_start;
447 dld_cache.unload2.unwind = u;
452 dld_msymbol = lookup_minimal_symbol_solib_trampoline ("shl_unload",
454 if (dld_msymbol != NULL)
456 if (SYMBOL_TYPE (dld_msymbol) == mst_solib_trampoline)
458 u = find_unwind_entry (SYMBOL_VALUE (dld_msymbol));
459 if ((u != NULL) && (u->stub_unwind.stub_type == EXPORT))
461 dld_cache.unload_stub.address = SYMBOL_VALUE (dld_msymbol);
462 dld_cache.unload_stub.unwind = u;
467 /* Did we find everything we were looking for? If so, stop. */
468 if ((dld_cache.load.address != 0)
469 && (dld_cache.load_stub.address != 0)
470 && (dld_cache.unload.address != 0)
471 && (dld_cache.unload_stub.address != 0))
473 dld_cache.is_valid = 1;
478 dld_cache.hook.unwind = find_unwind_entry (dld_cache.hook.address);
479 dld_cache.hook_stub.unwind = find_unwind_entry (dld_cache.hook_stub.address);
481 /* We're prepared not to find some of these symbols, which is why
482 this function is a "desire" operation, and not a "require".
487 som_in_dynsym_resolve_code (CORE_ADDR pc)
489 struct unwind_table_entry *u_pc;
491 /* Are we in the dld itself?
493 ??rehrauer: Large hack -- We'll assume that any address in a
494 shared text region is the dld's text. This would obviously
495 fall down if the user attached to a process, whose shlibs
496 weren't mapped to a (writeable) private region. However, in
497 that case the debugger probably isn't able to set the fundamental
498 breakpoint in the dld callback anyways, so this hack should be
501 if ((pc & (CORE_ADDR) 0xc0000000) == (CORE_ADDR) 0xc0000000)
504 /* Cache the address of some symbols that are part of the dynamic
505 linker, if not already known.
507 som_solib_desire_dynamic_linker_symbols ();
509 /* Are we in the dld callback? Or its export stub? */
510 u_pc = find_unwind_entry (pc);
514 if ((u_pc == dld_cache.hook.unwind) || (u_pc == dld_cache.hook_stub.unwind))
517 /* Or the interface of the dld (i.e., "shl_load" or friends)? */
518 if ((u_pc == dld_cache.load.unwind)
519 || (u_pc == dld_cache.unload.unwind)
520 || (u_pc == dld_cache.unload2.unwind)
521 || (u_pc == dld_cache.load_stub.unwind)
522 || (u_pc == dld_cache.unload_stub.unwind))
525 /* Apparently this address isn't part of the dld's text. */
530 som_clear_solib (void)
538 char text_link_addr[4];
545 char tsd_start_addr_ptr[4];
549 link_map_start (void)
551 struct minimal_symbol *sym;
554 unsigned int dld_flags;
556 sym = lookup_minimal_symbol ("__dld_flags", NULL, NULL);
559 error ("Unable to find __dld_flags symbol in object file.\n");
562 addr = SYMBOL_VALUE_ADDRESS (sym);
563 read_memory (addr, buf, 4);
564 dld_flags = extract_unsigned_integer (buf, 4);
565 if ((dld_flags & DLD_FLAGS_LISTVALID) == 0)
567 error ("__dld_list is not valid according to __dld_flags.\n");
571 /* If the libraries were not mapped private, warn the user. */
572 if ((dld_flags & DLD_FLAGS_MAPPRIVATE) == 0)
573 warning ("The shared libraries were not privately mapped; setting a\n"
574 "breakpoint in a shared library will not work until you rerun the "
577 sym = lookup_minimal_symbol ("__dld_list", NULL, NULL);
580 /* Older crt0.o files (hpux8) don't have __dld_list as a symbol,
581 but the data is still available if you know where to look. */
582 sym = lookup_minimal_symbol ("__dld_flags", NULL, NULL);
585 error ("Unable to find dynamic library list.\n");
588 addr = SYMBOL_VALUE_ADDRESS (sym) - 8;
591 addr = SYMBOL_VALUE_ADDRESS (sym);
593 read_memory (addr, buf, 4);
594 addr = extract_unsigned_integer (buf, 4);
597 error ("Debugging dynamic executables loaded via the hpux8 dld.sl is not supported.\n");
601 read_memory (addr, buf, 4);
602 return extract_unsigned_integer (buf, 4);
605 /* Does this so's name match the main binary? */
607 match_main (const char *name)
609 return strcmp (name, symfile_objfile->name) == 0;
612 static struct so_list *
613 som_current_sos (void)
616 struct so_list *head = 0;
617 struct so_list **link_ptr = &head;
619 for (lm = link_map_start (); lm; )
624 struct cleanup *old_chain;
626 struct dld_list dbuf;
629 new = (struct so_list *) xmalloc (sizeof (struct so_list));
630 old_chain = make_cleanup (xfree, new);
632 memset (new, 0, sizeof (*new));
633 new->lm_info = xmalloc (sizeof (struct lm_info));
634 make_cleanup (xfree, new->lm_info);
636 read_memory (lm, (char *)&dbuf, sizeof (struct dld_list));
638 addr = extract_unsigned_integer (&dbuf.name, sizeof (dbuf.name));
639 target_read_string (addr, &namebuf, SO_NAME_MAX_PATH_SIZE - 1, &errcode);
642 warning ("current_sos: Can't read pathname for load map: %s\n",
643 safe_strerror (errcode));
647 strncpy (new->so_name, namebuf, SO_NAME_MAX_PATH_SIZE - 1);
648 new->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
650 strcpy (new->so_original_name, new->so_name);
653 if (new->so_name[0] && !match_main (new->so_name))
655 struct lm_info *lmi = new->lm_info;
660 #define EXTRACT(_fld) \
661 extract_unsigned_integer (&dbuf._fld, sizeof (dbuf._fld));
663 lmi->text_addr = EXTRACT (text_addr);
664 tmp = EXTRACT (info);
665 lmi->library_version = (tmp >> 16) & 0xffff;
666 lmi->bind_mode = (tmp >> 8) & 0xff;
667 lmi->struct_version = tmp & 0xff;
668 lmi->text_link_addr = EXTRACT (text_link_addr);
669 lmi->text_end = EXTRACT (text_end);
670 lmi->data_start = EXTRACT (data_start);
671 lmi->bss_start = EXTRACT (bss_start);
672 lmi->data_end = EXTRACT (data_end);
673 lmi->got_value = EXTRACT (got_value);
674 tmp = EXTRACT (tsd_start_addr_ptr);
675 read_memory (tmp, tsdbuf, 4);
676 lmi->tsd_start_addr = extract_unsigned_integer (tsdbuf, 4);
679 printf ("\n+ library \"%s\" is described at 0x%s\n", new->so_name,
681 printf (" 'version' is %d\n", new->lm_info->struct_version);
682 printf (" 'bind_mode' is %d\n", new->lm_info->bind_mode);
683 printf (" 'library_version' is %d\n",
684 new->lm_info->library_version);
685 printf (" 'text_addr' is 0x%s\n",
686 paddr_nz (new->lm_info->text_addr));
687 printf (" 'text_link_addr' is 0x%s\n",
688 paddr_nz (new->lm_info->text_link_addr));
689 printf (" 'text_end' is 0x%s\n",
690 paddr_nz (new->lm_info->text_end));
691 printf (" 'data_start' is 0x%s\n",
692 paddr_nz (new->lm_info->data_start));
693 printf (" 'bss_start' is 0x%s\n",
694 paddr_nz (new->lm_info->bss_start));
695 printf (" 'data_end' is 0x%s\n",
696 paddr_nz (new->lm_info->data_end));
697 printf (" 'got_value' is %s\n",
698 paddr_nz (new->lm_info->got_value));
699 printf (" 'tsd_start_addr' is 0x%s\n",
700 paddr_nz (new->lm_info->tsd_start_addr));
703 /* Link the new object onto the list. */
706 link_ptr = &new->next;
714 discard_cleanups (old_chain);
718 /* TODO: The original somsolib code has logic to detect and eliminate
719 duplicate entries. Do we need that? */
725 som_open_symbol_file_object (void *from_ttyp)
727 CORE_ADDR lm, l_name;
730 int from_tty = *(int *)from_ttyp;
734 if (!query ("Attempt to reload symbols from process? "))
737 /* First link map member should be the executable. */
738 if ((lm = link_map_start ()) == 0)
739 return 0; /* failed somehow... */
741 /* Read address of name from target memory to GDB. */
742 read_memory (lm + offsetof (struct dld_list, name), buf, 4);
744 /* Convert the address to host format. Assume that the address is
746 l_name = extract_unsigned_integer (buf, 4);
749 return 0; /* No filename. */
751 /* Now fetch the filename from target memory. */
752 target_read_string (l_name, &filename, SO_NAME_MAX_PATH_SIZE - 1, &errcode);
756 warning ("failed to read exec filename from attached file: %s",
757 safe_strerror (errcode));
761 make_cleanup (xfree, filename);
762 /* Have a pathname: read the symbol file. */
763 symbol_file_add_main (filename, from_tty);
769 som_free_so (struct so_list *so)
775 som_solib_thread_start_addr (struct so_list *so)
777 return so->lm_info->tsd_start_addr;
780 /* Return the GOT value for the shared library in which ADDR belongs. If
781 ADDR isn't in any known shared library, return zero. */
784 som_solib_get_got_by_pc (CORE_ADDR addr)
786 struct so_list *so_list = master_so_list ();
787 CORE_ADDR got_value = 0;
791 if (so_list->lm_info->text_addr <= addr
792 && so_list->lm_info->text_end > addr)
794 got_value = so_list->lm_info->got_value;
797 so_list = so_list->next;
802 /* Return the address of the handle of the shared library in which ADDR belongs.
803 If ADDR isn't in any known shared library, return zero. */
804 /* this function is used in initialize_hp_cxx_exception_support in
808 som_solib_get_solib_by_pc (CORE_ADDR addr)
810 struct so_list *so_list = master_so_list ();
814 if (so_list->lm_info->text_addr <= addr
815 && so_list->lm_info->text_end > addr)
819 so_list = so_list->next;
822 return so_list->lm_info->lm_addr;
828 static struct target_so_ops som_so_ops;
830 extern initialize_file_ftype _initialize_som_solib; /* -Wmissing-prototypes */
833 _initialize_som_solib (void)
835 som_so_ops.relocate_section_addresses = som_relocate_section_addresses;
836 som_so_ops.free_so = som_free_so;
837 som_so_ops.clear_solib = som_clear_solib;
838 som_so_ops.solib_create_inferior_hook = som_solib_create_inferior_hook;
839 som_so_ops.special_symbol_handling = som_special_symbol_handling;
840 som_so_ops.current_sos = som_current_sos;
841 som_so_ops.open_symbol_file_object = som_open_symbol_file_object;
842 som_so_ops.in_dynsym_resolve_code = som_in_dynsym_resolve_code;
845 void som_solib_select (struct gdbarch_tdep *tdep)
847 current_target_so_ops = &som_so_ops;
849 tdep->solib_thread_start_addr = som_solib_thread_start_addr;
850 tdep->solib_get_got_by_pc = som_solib_get_got_by_pc;
851 tdep->solib_get_solib_by_pc = som_solib_get_solib_by_pc;
854 /* The rest of these functions are not part of the solib interface; they
855 are used by somread.c or hppa-hpux-tdep.c */
858 som_solib_section_offsets (struct objfile *objfile,
859 struct section_offsets *offsets)
861 struct so_list *so_list = master_so_list ();
865 /* Oh what a pain! We need the offsets before so_list->objfile
866 is valid. The BFDs will never match. Make a best guess. */
867 if (strstr (objfile->name, so_list->so_name))
869 asection *private_section;
871 /* The text offset is easy. */
872 offsets->offsets[SECT_OFF_TEXT (objfile)]
873 = (so_list->lm_info->text_addr
874 - so_list->lm_info->text_link_addr);
875 offsets->offsets[SECT_OFF_RODATA (objfile)]
876 = ANOFFSET (offsets, SECT_OFF_TEXT (objfile));
878 /* We should look at presumed_dp in the SOM header, but
879 that's not easily available. This should be OK though. */
880 private_section = bfd_get_section_by_name (objfile->obfd,
882 if (!private_section)
884 warning ("Unable to find $PRIVATE$ in shared library!");
885 offsets->offsets[SECT_OFF_DATA (objfile)] = 0;
886 offsets->offsets[SECT_OFF_BSS (objfile)] = 0;
889 offsets->offsets[SECT_OFF_DATA (objfile)]
890 = (so_list->lm_info->data_start - private_section->vma);
891 offsets->offsets[SECT_OFF_BSS (objfile)]
892 = ANOFFSET (offsets, SECT_OFF_DATA (objfile));
895 so_list = so_list->next;