1 /* Handle SOM shared libraries.
3 Copyright (C) 2004, 2005, 2007, 2008, 2009 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 3 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, see <http://www.gnu.org/licenses/>. */
29 #include "hppa-tdep.h"
32 #include "solib-som.h"
34 #include <sys/utsname.h>
39 /* These ought to be defined in some public interface, but aren't. They
40 define the meaning of the various bits in the distinguished __dld_flags
41 variable that is declared in every debuggable a.out on HP-UX, and that
42 is shared between the debugger and the dynamic linker.
44 #define DLD_FLAGS_MAPPRIVATE 0x1
45 #define DLD_FLAGS_HOOKVALID 0x2
46 #define DLD_FLAGS_LISTVALID 0x4
47 #define DLD_FLAGS_BOR_ENABLE 0x8
51 /* Version of this structure (it is expected to change again in hpux10). */
52 unsigned char struct_version;
54 /* Binding mode for this library. */
55 unsigned char bind_mode;
57 /* Version of this library. */
58 short library_version;
60 /* Start of text address,
61 link-time text location (length of text area),
62 end of text address. */
64 CORE_ADDR text_link_addr;
67 /* Start of data, start of bss and end of data. */
72 /* Value of linkage pointer (%r19). */
75 /* Address in target of offset from thread-local register of
76 start of this thread's data. I.e., the first thread-local
77 variable in this shared library starts at *(tsd_start_addr)
78 from that area pointed to by cr27 (mpsfu_hi).
80 We do the indirection as soon as we read it, so from then
81 on it's the offset itself. */
82 CORE_ADDR tsd_start_addr;
84 /* Address of the link map entry in the loader. */
88 /* These addresses should be filled in by som_solib_create_inferior_hook.
89 They are also used elsewhere in this module.
94 struct unwind_table_entry *unwind;
98 /* When adding fields, be sure to clear them in _initialize_som_solib. */
102 addr_and_unwind_t hook;
103 addr_and_unwind_t hook_stub;
104 addr_and_unwind_t load;
105 addr_and_unwind_t load_stub;
106 addr_and_unwind_t unload;
107 addr_and_unwind_t unload2;
108 addr_and_unwind_t unload_stub;
113 som_relocate_section_addresses (struct so_list *so,
114 struct target_section *sec)
116 flagword aflag = bfd_get_section_flags(so->abfd, sec->the_bfd_section);
118 if (aflag & SEC_CODE)
120 sec->addr += so->lm_info->text_addr - so->lm_info->text_link_addr;
121 sec->endaddr += so->lm_info->text_addr - so->lm_info->text_link_addr;
123 else if (aflag & SEC_DATA)
125 sec->addr += so->lm_info->data_start;
126 sec->endaddr += so->lm_info->data_start;
132 /* Get HP-UX major release number. Returns zero if the
133 release is not known. */
136 get_hpux_major_release (void)
138 static int hpux_major_release = -1;
140 if (hpux_major_release == -1)
146 p = strchr (x.release, '.');
147 hpux_major_release = p ? atoi (p + 1) : 0;
150 return hpux_major_release;
153 /* DL header flag defines. */
154 #define SHLIB_TEXT_PRIVATE_ENABLE 0x4000
156 /* The DL header is documented in <shl.h>. We are only interested
157 in the flags field to determine whether the executable wants shared
158 libraries mapped private. */
164 /* This hook gets called just before the first instruction in the
165 inferior process is executed.
167 This is our opportunity to set magic flags in the inferior so
168 that GDB can be notified when a shared library is mapped in and
169 to tell the dynamic linker that a private copy of the library is
170 needed (so GDB can set breakpoints in the library).
172 __dld_flags is the location of the magic flags; as of this implementation
173 there are 3 flags of interest:
175 bit 0 when set indicates that private copies of the libraries are needed
176 bit 1 when set indicates that the callback hook routine is valid
177 bit 2 when set indicates that the dynamic linker should maintain the
178 __dld_list structure when loading/unloading libraries.
180 Note that shared libraries are not mapped in at this time, so we have
181 run the inferior until the libraries are mapped in. Typically this
182 means running until the "_start" is called. */
185 som_solib_create_inferior_hook (void)
187 enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
188 struct minimal_symbol *msymbol;
189 unsigned int dld_flags, status, have_endo;
190 asection *shlib_info;
194 /* First, remove all the solib event breakpoints. Their addresses
195 may have changed since the last time we ran the program. */
196 remove_solib_event_breakpoints ();
198 if (symfile_objfile == NULL)
201 /* First see if the objfile was dynamically linked. */
202 shlib_info = bfd_get_section_by_name (symfile_objfile->obfd, "$SHLIB_INFO$");
206 /* It's got a $SHLIB_INFO$ section, make sure it's not empty. */
207 if (bfd_section_size (symfile_objfile->obfd, shlib_info) == 0)
210 /* Read the DL header. */
211 bfd_get_section_contents (symfile_objfile->obfd, shlib_info,
212 (char *) &dl_header, 0, sizeof (dl_header));
215 /* Slam the pid of the process into __d_pid.
217 We used to warn when this failed, but that warning is only useful
218 on very old HP systems (hpux9 and older). The warnings are an
219 annoyance to users of modern systems and foul up the testsuite as
220 well. As a result, the warnings have been disabled. */
221 msymbol = lookup_minimal_symbol ("__d_pid", NULL, symfile_objfile);
225 anaddr = SYMBOL_VALUE_ADDRESS (msymbol);
226 store_unsigned_integer (buf, 4, byte_order, PIDGET (inferior_ptid));
227 status = target_write_memory (anaddr, buf, 4);
231 Unable to write __d_pid.\n\
232 Suggest linking with /opt/langtools/lib/end.o.\n\
233 GDB will be unable to track shl_load/shl_unload calls"));
237 /* Get the value of _DLD_HOOK (an export stub) and put it in __dld_hook;
238 This will force the dynamic linker to call __d_trap when significant
241 Note that the above is the pre-HP-UX 9.0 behaviour. At 9.0 and above,
242 the dld provides an export stub named "__d_trap" as well as the
243 function named "__d_trap" itself, but doesn't provide "_DLD_HOOK".
244 We'll look first for the old flavor and then the new.
246 msymbol = lookup_minimal_symbol ("_DLD_HOOK", NULL, symfile_objfile);
248 msymbol = lookup_minimal_symbol ("__d_trap", NULL, symfile_objfile);
252 Unable to find _DLD_HOOK symbol in object file.\n\
253 Suggest linking with /opt/langtools/lib/end.o.\n\
254 GDB will be unable to track shl_load/shl_unload calls"));
257 anaddr = SYMBOL_VALUE_ADDRESS (msymbol);
258 dld_cache.hook.address = anaddr;
260 /* Grrr, this might not be an export symbol! We have to find the
262 msymbol = hppa_lookup_stub_minimal_symbol (SYMBOL_LINKAGE_NAME (msymbol),
266 anaddr = SYMBOL_VALUE (msymbol);
267 dld_cache.hook_stub.address = anaddr;
269 store_unsigned_integer (buf, 4, byte_order, anaddr);
271 msymbol = lookup_minimal_symbol ("__dld_hook", NULL, symfile_objfile);
275 Unable to find __dld_hook symbol in object file.\n\
276 Suggest linking with /opt/langtools/lib/end.o.\n\
277 GDB will be unable to track shl_load/shl_unload calls"));
280 anaddr = SYMBOL_VALUE_ADDRESS (msymbol);
281 status = target_write_memory (anaddr, buf, 4);
283 /* Now set a shlib_event breakpoint at __d_trap so we can track
284 significant shared library events. */
285 msymbol = lookup_minimal_symbol ("__d_trap", NULL, symfile_objfile);
289 Unable to find __dld_d_trap symbol in object file.\n\
290 Suggest linking with /opt/langtools/lib/end.o.\n\
291 GDB will be unable to track shl_load/shl_unload calls"));
294 create_solib_event_breakpoint (target_gdbarch,
295 SYMBOL_VALUE_ADDRESS (msymbol));
297 /* We have all the support usually found in end.o, so we can track
298 shl_load and shl_unload calls. */
303 /* Get the address of __dld_flags, if no such symbol exists, then we can
304 not debug the shared code. */
305 msymbol = lookup_minimal_symbol ("__dld_flags", NULL, NULL);
308 error (_("Unable to find __dld_flags symbol in object file."));
311 anaddr = SYMBOL_VALUE_ADDRESS (msymbol);
313 /* Read the current contents. */
314 status = target_read_memory (anaddr, buf, 4);
316 error (_("Unable to read __dld_flags."));
317 dld_flags = extract_unsigned_integer (buf, 4, byte_order);
319 /* If the libraries were not mapped private on HP-UX 11 and later, warn
320 the user. On HP-UX 10 and earlier, there is no easy way to specify
321 that shared libraries should be privately mapped. So, we just force
323 if (get_hpux_major_release () >= 11
324 && (dl_header.flags & SHLIB_TEXT_PRIVATE_ENABLE) == 0
325 && (dld_flags & DLD_FLAGS_MAPPRIVATE) == 0)
327 (_("Private mapping of shared library text was not specified\n"
328 "by the executable; setting a breakpoint in a shared library which\n"
329 "is not privately mapped will not work. See the HP-UX 11i v3 chatr\n"
330 "manpage for methods to privately map shared library text."));
332 /* Turn on the flags we care about. */
333 if (get_hpux_major_release () < 11)
334 dld_flags |= DLD_FLAGS_MAPPRIVATE;
336 dld_flags |= DLD_FLAGS_HOOKVALID;
337 store_unsigned_integer (buf, 4, byte_order, dld_flags);
338 status = target_write_memory (anaddr, buf, 4);
340 error (_("Unable to write __dld_flags."));
342 /* Now find the address of _start and set a breakpoint there.
343 We still need this code for two reasons:
345 * Not all sites have /opt/langtools/lib/end.o, so it's not always
346 possible to track the dynamic linker's events.
348 * At this time no events are triggered for shared libraries
349 loaded at startup time (what a crock). */
351 msymbol = lookup_minimal_symbol ("_start", NULL, symfile_objfile);
353 error (_("Unable to find _start symbol in object file."));
355 anaddr = SYMBOL_VALUE_ADDRESS (msymbol);
357 /* Make the breakpoint at "_start" a shared library event breakpoint. */
358 create_solib_event_breakpoint (target_gdbarch, anaddr);
360 clear_symtab_users ();
364 som_special_symbol_handling (void)
369 som_solib_desire_dynamic_linker_symbols (void)
371 struct objfile *objfile;
372 struct unwind_table_entry *u;
373 struct minimal_symbol *dld_msymbol;
375 /* Do we already know the value of these symbols? If so, then
378 (If you add clauses to this test, be sure to likewise update the
379 test within the loop.)
381 if (dld_cache.is_valid)
384 ALL_OBJFILES (objfile)
386 dld_msymbol = lookup_minimal_symbol ("shl_load", NULL, objfile);
387 if (dld_msymbol != NULL)
389 dld_cache.load.address = SYMBOL_VALUE (dld_msymbol);
390 dld_cache.load.unwind = find_unwind_entry (dld_cache.load.address);
393 dld_msymbol = lookup_minimal_symbol_solib_trampoline ("shl_load",
395 if (dld_msymbol != NULL)
397 if (MSYMBOL_TYPE (dld_msymbol) == mst_solib_trampoline)
399 u = find_unwind_entry (SYMBOL_VALUE (dld_msymbol));
400 if ((u != NULL) && (u->stub_unwind.stub_type == EXPORT))
402 dld_cache.load_stub.address = SYMBOL_VALUE (dld_msymbol);
403 dld_cache.load_stub.unwind = u;
408 dld_msymbol = lookup_minimal_symbol ("shl_unload", NULL, objfile);
409 if (dld_msymbol != NULL)
411 dld_cache.unload.address = SYMBOL_VALUE (dld_msymbol);
412 dld_cache.unload.unwind = find_unwind_entry (dld_cache.unload.address);
414 /* ??rehrauer: I'm not sure exactly what this is, but it appears
415 that on some HPUX 10.x versions, there's two unwind regions to
416 cover the body of "shl_unload", the second being 4 bytes past
417 the end of the first. This is a large hack to handle that
418 case, but since I don't seem to have any legitimate way to
419 look for this thing via the symbol table...
421 if (dld_cache.unload.unwind != NULL)
423 u = find_unwind_entry (dld_cache.unload.unwind->region_end + 4);
426 dld_cache.unload2.address = u->region_start;
427 dld_cache.unload2.unwind = u;
432 dld_msymbol = lookup_minimal_symbol_solib_trampoline ("shl_unload",
434 if (dld_msymbol != NULL)
436 if (MSYMBOL_TYPE (dld_msymbol) == mst_solib_trampoline)
438 u = find_unwind_entry (SYMBOL_VALUE (dld_msymbol));
439 if ((u != NULL) && (u->stub_unwind.stub_type == EXPORT))
441 dld_cache.unload_stub.address = SYMBOL_VALUE (dld_msymbol);
442 dld_cache.unload_stub.unwind = u;
447 /* Did we find everything we were looking for? If so, stop. */
448 if ((dld_cache.load.address != 0)
449 && (dld_cache.load_stub.address != 0)
450 && (dld_cache.unload.address != 0)
451 && (dld_cache.unload_stub.address != 0))
453 dld_cache.is_valid = 1;
458 dld_cache.hook.unwind = find_unwind_entry (dld_cache.hook.address);
459 dld_cache.hook_stub.unwind = find_unwind_entry (dld_cache.hook_stub.address);
461 /* We're prepared not to find some of these symbols, which is why
462 this function is a "desire" operation, and not a "require".
467 som_in_dynsym_resolve_code (CORE_ADDR pc)
469 struct unwind_table_entry *u_pc;
471 /* Are we in the dld itself?
473 ??rehrauer: Large hack -- We'll assume that any address in a
474 shared text region is the dld's text. This would obviously
475 fall down if the user attached to a process, whose shlibs
476 weren't mapped to a (writeable) private region. However, in
477 that case the debugger probably isn't able to set the fundamental
478 breakpoint in the dld callback anyways, so this hack should be
481 if ((pc & (CORE_ADDR) 0xc0000000) == (CORE_ADDR) 0xc0000000)
484 /* Cache the address of some symbols that are part of the dynamic
485 linker, if not already known.
487 som_solib_desire_dynamic_linker_symbols ();
489 /* Are we in the dld callback? Or its export stub? */
490 u_pc = find_unwind_entry (pc);
494 if ((u_pc == dld_cache.hook.unwind) || (u_pc == dld_cache.hook_stub.unwind))
497 /* Or the interface of the dld (i.e., "shl_load" or friends)? */
498 if ((u_pc == dld_cache.load.unwind)
499 || (u_pc == dld_cache.unload.unwind)
500 || (u_pc == dld_cache.unload2.unwind)
501 || (u_pc == dld_cache.load_stub.unwind)
502 || (u_pc == dld_cache.unload_stub.unwind))
505 /* Apparently this address isn't part of the dld's text. */
510 som_clear_solib (void)
518 char text_link_addr[4];
525 char tsd_start_addr_ptr[4];
529 link_map_start (void)
531 enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
532 struct minimal_symbol *sym;
535 unsigned int dld_flags;
537 sym = lookup_minimal_symbol ("__dld_flags", NULL, NULL);
539 error (_("Unable to find __dld_flags symbol in object file."));
540 addr = SYMBOL_VALUE_ADDRESS (sym);
541 read_memory (addr, buf, 4);
542 dld_flags = extract_unsigned_integer (buf, 4, byte_order);
543 if ((dld_flags & DLD_FLAGS_LISTVALID) == 0)
544 error (_("__dld_list is not valid according to __dld_flags."));
546 sym = lookup_minimal_symbol ("__dld_list", NULL, NULL);
549 /* Older crt0.o files (hpux8) don't have __dld_list as a symbol,
550 but the data is still available if you know where to look. */
551 sym = lookup_minimal_symbol ("__dld_flags", NULL, NULL);
554 error (_("Unable to find dynamic library list."));
557 addr = SYMBOL_VALUE_ADDRESS (sym) - 8;
560 addr = SYMBOL_VALUE_ADDRESS (sym);
562 read_memory (addr, buf, 4);
563 addr = extract_unsigned_integer (buf, 4, byte_order);
567 read_memory (addr, buf, 4);
568 return extract_unsigned_integer (buf, 4, byte_order);
571 /* Does this so's name match the main binary? */
573 match_main (const char *name)
575 return strcmp (name, symfile_objfile->name) == 0;
578 static struct so_list *
579 som_current_sos (void)
581 enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
583 struct so_list *head = 0;
584 struct so_list **link_ptr = &head;
586 for (lm = link_map_start (); lm; )
591 struct cleanup *old_chain;
593 struct dld_list dbuf;
596 new = (struct so_list *) xmalloc (sizeof (struct so_list));
597 old_chain = make_cleanup (xfree, new);
599 memset (new, 0, sizeof (*new));
600 new->lm_info = xmalloc (sizeof (struct lm_info));
601 make_cleanup (xfree, new->lm_info);
603 read_memory (lm, (gdb_byte *)&dbuf, sizeof (struct dld_list));
605 addr = extract_unsigned_integer ((gdb_byte *)&dbuf.name,
606 sizeof (dbuf.name), byte_order);
607 target_read_string (addr, &namebuf, SO_NAME_MAX_PATH_SIZE - 1, &errcode);
609 warning (_("Can't read pathname for load map: %s."),
610 safe_strerror (errcode));
613 strncpy (new->so_name, namebuf, SO_NAME_MAX_PATH_SIZE - 1);
614 new->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
616 strcpy (new->so_original_name, new->so_name);
619 if (new->so_name[0] && !match_main (new->so_name))
621 struct lm_info *lmi = new->lm_info;
626 #define EXTRACT(_fld) \
627 extract_unsigned_integer ((gdb_byte *)&dbuf._fld, \
628 sizeof (dbuf._fld), byte_order);
630 lmi->text_addr = EXTRACT (text_addr);
631 tmp = EXTRACT (info);
632 lmi->library_version = (tmp >> 16) & 0xffff;
633 lmi->bind_mode = (tmp >> 8) & 0xff;
634 lmi->struct_version = tmp & 0xff;
635 lmi->text_link_addr = EXTRACT (text_link_addr);
636 lmi->text_end = EXTRACT (text_end);
637 lmi->data_start = EXTRACT (data_start);
638 lmi->bss_start = EXTRACT (bss_start);
639 lmi->data_end = EXTRACT (data_end);
640 lmi->got_value = EXTRACT (got_value);
641 tmp = EXTRACT (tsd_start_addr_ptr);
642 read_memory (tmp, tsdbuf, 4);
644 = extract_unsigned_integer (tsdbuf, 4, byte_order);
647 printf ("\n+ library \"%s\" is described at %s\n", new->so_name,
648 paddress (target_gdbarch, lm));
649 printf (" 'version' is %d\n", new->lm_info->struct_version);
650 printf (" 'bind_mode' is %d\n", new->lm_info->bind_mode);
651 printf (" 'library_version' is %d\n",
652 new->lm_info->library_version);
653 printf (" 'text_addr' is %s\n",
654 paddress (target_gdbarch, new->lm_info->text_addr));
655 printf (" 'text_link_addr' is %s\n",
656 paddress (target_gdbarch, new->lm_info->text_link_addr));
657 printf (" 'text_end' is %s\n",
658 paddress (target_gdbarch, new->lm_info->text_end));
659 printf (" 'data_start' is %s\n",
660 paddress (target_gdbarch, new->lm_info->data_start));
661 printf (" 'bss_start' is %s\n",
662 paddress (target_gdbarch, new->lm_info->bss_start));
663 printf (" 'data_end' is %s\n",
664 paddress (target_gdbarch, new->lm_info->data_end));
665 printf (" 'got_value' is %s\n",
666 paddress (target_gdbarch, new->lm_info->got_value));
667 printf (" 'tsd_start_addr' is %s\n",
668 paddress (target_gdbarch, new->lm_info->tsd_start_addr));
671 new->addr_low = lmi->text_addr;
672 new->addr_high = lmi->text_end;
674 /* Link the new object onto the list. */
677 link_ptr = &new->next;
685 discard_cleanups (old_chain);
689 /* TODO: The original somsolib code has logic to detect and eliminate
690 duplicate entries. Do we need that? */
696 som_open_symbol_file_object (void *from_ttyp)
698 enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
699 CORE_ADDR lm, l_name;
702 int from_tty = *(int *)from_ttyp;
706 if (!query (_("Attempt to reload symbols from process? ")))
709 /* First link map member should be the executable. */
710 if ((lm = link_map_start ()) == 0)
711 return 0; /* failed somehow... */
713 /* Read address of name from target memory to GDB. */
714 read_memory (lm + offsetof (struct dld_list, name), buf, 4);
716 /* Convert the address to host format. Assume that the address is
718 l_name = extract_unsigned_integer (buf, 4, byte_order);
721 return 0; /* No filename. */
723 /* Now fetch the filename from target memory. */
724 target_read_string (l_name, &filename, SO_NAME_MAX_PATH_SIZE - 1, &errcode);
728 warning (_("failed to read exec filename from attached file: %s"),
729 safe_strerror (errcode));
733 make_cleanup (xfree, filename);
734 /* Have a pathname: read the symbol file. */
735 symbol_file_add_main (filename, from_tty);
741 som_free_so (struct so_list *so)
747 som_solib_thread_start_addr (struct so_list *so)
749 return so->lm_info->tsd_start_addr;
752 /* Return the GOT value for the shared library in which ADDR belongs. If
753 ADDR isn't in any known shared library, return zero. */
756 som_solib_get_got_by_pc (CORE_ADDR addr)
758 struct so_list *so_list = master_so_list ();
759 CORE_ADDR got_value = 0;
763 if (so_list->lm_info->text_addr <= addr
764 && so_list->lm_info->text_end > addr)
766 got_value = so_list->lm_info->got_value;
769 so_list = so_list->next;
774 /* Return the address of the handle of the shared library in which ADDR belongs.
775 If ADDR isn't in any known shared library, return zero. */
776 /* this function is used in initialize_hp_cxx_exception_support in
780 som_solib_get_solib_by_pc (CORE_ADDR addr)
782 struct so_list *so_list = master_so_list ();
786 if (so_list->lm_info->text_addr <= addr
787 && so_list->lm_info->text_end > addr)
791 so_list = so_list->next;
794 return so_list->lm_info->lm_addr;
800 static struct target_so_ops som_so_ops;
802 extern initialize_file_ftype _initialize_som_solib; /* -Wmissing-prototypes */
805 _initialize_som_solib (void)
807 som_so_ops.relocate_section_addresses = som_relocate_section_addresses;
808 som_so_ops.free_so = som_free_so;
809 som_so_ops.clear_solib = som_clear_solib;
810 som_so_ops.solib_create_inferior_hook = som_solib_create_inferior_hook;
811 som_so_ops.special_symbol_handling = som_special_symbol_handling;
812 som_so_ops.current_sos = som_current_sos;
813 som_so_ops.open_symbol_file_object = som_open_symbol_file_object;
814 som_so_ops.in_dynsym_resolve_code = som_in_dynsym_resolve_code;
815 som_so_ops.bfd_open = solib_bfd_open;
819 som_solib_select (struct gdbarch *gdbarch)
821 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
822 set_solib_ops (gdbarch, &som_so_ops);
824 tdep->solib_thread_start_addr = som_solib_thread_start_addr;
825 tdep->solib_get_got_by_pc = som_solib_get_got_by_pc;
826 tdep->solib_get_solib_by_pc = som_solib_get_solib_by_pc;
829 /* The rest of these functions are not part of the solib interface; they
830 are used by somread.c or hppa-hpux-tdep.c */
833 som_solib_section_offsets (struct objfile *objfile,
834 struct section_offsets *offsets)
836 struct so_list *so_list = master_so_list ();
840 /* Oh what a pain! We need the offsets before so_list->objfile
841 is valid. The BFDs will never match. Make a best guess. */
842 if (strstr (objfile->name, so_list->so_name))
844 asection *private_section;
846 /* The text offset is easy. */
847 offsets->offsets[SECT_OFF_TEXT (objfile)]
848 = (so_list->lm_info->text_addr
849 - so_list->lm_info->text_link_addr);
850 offsets->offsets[SECT_OFF_RODATA (objfile)]
851 = ANOFFSET (offsets, SECT_OFF_TEXT (objfile));
853 /* We should look at presumed_dp in the SOM header, but
854 that's not easily available. This should be OK though. */
855 private_section = bfd_get_section_by_name (objfile->obfd,
857 if (!private_section)
859 warning (_("Unable to find $PRIVATE$ in shared library!"));
860 offsets->offsets[SECT_OFF_DATA (objfile)] = 0;
861 offsets->offsets[SECT_OFF_BSS (objfile)] = 0;
864 offsets->offsets[SECT_OFF_DATA (objfile)]
865 = (so_list->lm_info->data_start - private_section->vma);
866 offsets->offsets[SECT_OFF_BSS (objfile)]
867 = ANOFFSET (offsets, SECT_OFF_DATA (objfile));
870 so_list = so_list->next;