ae3f49ac85bf6ebcb681e5ee74e13756d0533d0b
[deliverable/binutils-gdb.git] / gdb / solib-svr4.c
1 /* Handle SVR4 shared libraries for GDB, the GNU Debugger.
2
3 Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000,
4 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
5 Free Software Foundation, Inc.
6
7 This file is part of GDB.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21
22 #include "defs.h"
23
24 #include "elf/external.h"
25 #include "elf/common.h"
26 #include "elf/mips.h"
27
28 #include "symtab.h"
29 #include "bfd.h"
30 #include "symfile.h"
31 #include "objfiles.h"
32 #include "gdbcore.h"
33 #include "target.h"
34 #include "inferior.h"
35 #include "regcache.h"
36 #include "gdbthread.h"
37 #include "observer.h"
38
39 #include "gdb_assert.h"
40
41 #include "solist.h"
42 #include "solib.h"
43 #include "solib-svr4.h"
44
45 #include "bfd-target.h"
46 #include "elf-bfd.h"
47 #include "exec.h"
48 #include "auxv.h"
49 #include "exceptions.h"
50
51 static struct link_map_offsets *svr4_fetch_link_map_offsets (void);
52 static int svr4_have_link_map_offsets (void);
53 static void svr4_relocate_main_executable (void);
54
55 /* Link map info to include in an allocated so_list entry */
56
57 struct lm_info
58 {
59 /* Pointer to copy of link map from inferior. The type is char *
60 rather than void *, so that we may use byte offsets to find the
61 various fields without the need for a cast. */
62 gdb_byte *lm;
63
64 /* Amount by which addresses in the binary should be relocated to
65 match the inferior. This could most often be taken directly
66 from lm, but when prelinking is involved and the prelink base
67 address changes, we may need a different offset, we want to
68 warn about the difference and compute it only once. */
69 CORE_ADDR l_addr;
70
71 /* The target location of lm. */
72 CORE_ADDR lm_addr;
73 };
74
75 /* On SVR4 systems, a list of symbols in the dynamic linker where
76 GDB can try to place a breakpoint to monitor shared library
77 events.
78
79 If none of these symbols are found, or other errors occur, then
80 SVR4 systems will fall back to using a symbol as the "startup
81 mapping complete" breakpoint address. */
82
83 static char *solib_break_names[] =
84 {
85 "r_debug_state",
86 "_r_debug_state",
87 "_dl_debug_state",
88 "rtld_db_dlactivity",
89 "__dl_rtld_db_dlactivity",
90 "_rtld_debug_state",
91
92 NULL
93 };
94
95 static char *bkpt_names[] =
96 {
97 "_start",
98 "__start",
99 "main",
100 NULL
101 };
102
103 static char *main_name_list[] =
104 {
105 "main_$main",
106 NULL
107 };
108
109 /* Return non-zero if GDB_SO_NAME and INFERIOR_SO_NAME represent
110 the same shared library. */
111
112 static int
113 svr4_same_1 (const char *gdb_so_name, const char *inferior_so_name)
114 {
115 if (strcmp (gdb_so_name, inferior_so_name) == 0)
116 return 1;
117
118 /* On Solaris, when starting inferior we think that dynamic linker is
119 /usr/lib/ld.so.1, but later on, the table of loaded shared libraries
120 contains /lib/ld.so.1. Sometimes one file is a link to another, but
121 sometimes they have identical content, but are not linked to each
122 other. We don't restrict this check for Solaris, but the chances
123 of running into this situation elsewhere are very low. */
124 if (strcmp (gdb_so_name, "/usr/lib/ld.so.1") == 0
125 && strcmp (inferior_so_name, "/lib/ld.so.1") == 0)
126 return 1;
127
128 /* Similarly, we observed the same issue with sparc64, but with
129 different locations. */
130 if (strcmp (gdb_so_name, "/usr/lib/sparcv9/ld.so.1") == 0
131 && strcmp (inferior_so_name, "/lib/sparcv9/ld.so.1") == 0)
132 return 1;
133
134 return 0;
135 }
136
137 static int
138 svr4_same (struct so_list *gdb, struct so_list *inferior)
139 {
140 return (svr4_same_1 (gdb->so_original_name, inferior->so_original_name));
141 }
142
143 /* link map access functions */
144
145 static CORE_ADDR
146 LM_ADDR_FROM_LINK_MAP (struct so_list *so)
147 {
148 struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
149 struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
150
151 return extract_typed_address (so->lm_info->lm + lmo->l_addr_offset,
152 ptr_type);
153 }
154
155 static int
156 HAS_LM_DYNAMIC_FROM_LINK_MAP (void)
157 {
158 struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
159
160 return lmo->l_ld_offset >= 0;
161 }
162
163 static CORE_ADDR
164 LM_DYNAMIC_FROM_LINK_MAP (struct so_list *so)
165 {
166 struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
167 struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
168
169 return extract_typed_address (so->lm_info->lm + lmo->l_ld_offset,
170 ptr_type);
171 }
172
173 static CORE_ADDR
174 LM_ADDR_CHECK (struct so_list *so, bfd *abfd)
175 {
176 if (so->lm_info->l_addr == (CORE_ADDR)-1)
177 {
178 struct bfd_section *dyninfo_sect;
179 CORE_ADDR l_addr, l_dynaddr, dynaddr;
180
181 l_addr = LM_ADDR_FROM_LINK_MAP (so);
182
183 if (! abfd || ! HAS_LM_DYNAMIC_FROM_LINK_MAP ())
184 goto set_addr;
185
186 l_dynaddr = LM_DYNAMIC_FROM_LINK_MAP (so);
187
188 dyninfo_sect = bfd_get_section_by_name (abfd, ".dynamic");
189 if (dyninfo_sect == NULL)
190 goto set_addr;
191
192 dynaddr = bfd_section_vma (abfd, dyninfo_sect);
193
194 if (dynaddr + l_addr != l_dynaddr)
195 {
196 CORE_ADDR align = 0x1000;
197
198 if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
199 {
200 Elf_Internal_Ehdr *ehdr = elf_tdata (abfd)->elf_header;
201 Elf_Internal_Phdr *phdr = elf_tdata (abfd)->phdr;
202 int i;
203
204 align = 1;
205
206 for (i = 0; i < ehdr->e_phnum; i++)
207 if (phdr[i].p_type == PT_LOAD && phdr[i].p_align > align)
208 align = phdr[i].p_align;
209 }
210
211 /* Turn it into a mask. */
212 align--;
213
214 /* If the changes match the alignment requirements, we
215 assume we're using a core file that was generated by the
216 same binary, just prelinked with a different base offset.
217 If it doesn't match, we may have a different binary, the
218 same binary with the dynamic table loaded at an unrelated
219 location, or anything, really. To avoid regressions,
220 don't adjust the base offset in the latter case, although
221 odds are that, if things really changed, debugging won't
222 quite work.
223
224 One could expect more the condition
225 ((l_addr & align) == 0 && ((l_dynaddr - dynaddr) & align) == 0)
226 but the one below is relaxed for PPC. The PPC kernel supports
227 either 4k or 64k page sizes. To be prepared for 64k pages,
228 PPC ELF files are built using an alignment requirement of 64k.
229 However, when running on a kernel supporting 4k pages, the memory
230 mapping of the library may not actually happen on a 64k boundary!
231
232 (In the usual case where (l_addr & align) == 0, this check is
233 equivalent to the possibly expected check above.) */
234
235 if ((l_addr & align) == ((l_dynaddr - dynaddr) & align))
236 {
237 l_addr = l_dynaddr - dynaddr;
238
239 if (info_verbose)
240 {
241 warning (_(".dynamic section for \"%s\" "
242 "is not at the expected address"), so->so_name);
243 warning (_("difference appears to be caused by prelink, "
244 "adjusting expectations"));
245 }
246 }
247 else
248 warning (_(".dynamic section for \"%s\" "
249 "is not at the expected address "
250 "(wrong library or version mismatch?)"), so->so_name);
251 }
252
253 set_addr:
254 so->lm_info->l_addr = l_addr;
255 }
256
257 return so->lm_info->l_addr;
258 }
259
260 static CORE_ADDR
261 LM_NEXT (struct so_list *so)
262 {
263 struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
264 struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
265
266 return extract_typed_address (so->lm_info->lm + lmo->l_next_offset,
267 ptr_type);
268 }
269
270 static CORE_ADDR
271 LM_NAME (struct so_list *so)
272 {
273 struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
274 struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
275
276 return extract_typed_address (so->lm_info->lm + lmo->l_name_offset,
277 ptr_type);
278 }
279
280 static int
281 IGNORE_FIRST_LINK_MAP_ENTRY (struct so_list *so)
282 {
283 struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
284 struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
285
286 /* Assume that everything is a library if the dynamic loader was loaded
287 late by a static executable. */
288 if (exec_bfd && bfd_get_section_by_name (exec_bfd, ".dynamic") == NULL)
289 return 0;
290
291 return extract_typed_address (so->lm_info->lm + lmo->l_prev_offset,
292 ptr_type) == 0;
293 }
294
295 /* Per pspace SVR4 specific data. */
296
297 struct svr4_info
298 {
299 CORE_ADDR debug_base; /* Base of dynamic linker structures */
300
301 /* Validity flag for debug_loader_offset. */
302 int debug_loader_offset_p;
303
304 /* Load address for the dynamic linker, inferred. */
305 CORE_ADDR debug_loader_offset;
306
307 /* Name of the dynamic linker, valid if debug_loader_offset_p. */
308 char *debug_loader_name;
309
310 /* Load map address for the main executable. */
311 CORE_ADDR main_lm_addr;
312
313 CORE_ADDR interp_text_sect_low;
314 CORE_ADDR interp_text_sect_high;
315 CORE_ADDR interp_plt_sect_low;
316 CORE_ADDR interp_plt_sect_high;
317 };
318
319 /* Per-program-space data key. */
320 static const struct program_space_data *solib_svr4_pspace_data;
321
322 static void
323 svr4_pspace_data_cleanup (struct program_space *pspace, void *arg)
324 {
325 struct svr4_info *info;
326
327 info = program_space_data (pspace, solib_svr4_pspace_data);
328 xfree (info);
329 }
330
331 /* Get the current svr4 data. If none is found yet, add it now. This
332 function always returns a valid object. */
333
334 static struct svr4_info *
335 get_svr4_info (void)
336 {
337 struct svr4_info *info;
338
339 info = program_space_data (current_program_space, solib_svr4_pspace_data);
340 if (info != NULL)
341 return info;
342
343 info = XZALLOC (struct svr4_info);
344 set_program_space_data (current_program_space, solib_svr4_pspace_data, info);
345 return info;
346 }
347
348 /* Local function prototypes */
349
350 static int match_main (char *);
351
352 static CORE_ADDR bfd_lookup_symbol (bfd *, char *);
353
354 /*
355
356 LOCAL FUNCTION
357
358 bfd_lookup_symbol -- lookup the value for a specific symbol
359
360 SYNOPSIS
361
362 CORE_ADDR bfd_lookup_symbol (bfd *abfd, char *symname)
363
364 DESCRIPTION
365
366 An expensive way to lookup the value of a single symbol for
367 bfd's that are only temporary anyway. This is used by the
368 shared library support to find the address of the debugger
369 notification routine in the shared library.
370
371 The returned symbol may be in a code or data section; functions
372 will normally be in a code section, but may be in a data section
373 if this architecture uses function descriptors.
374
375 Note that 0 is specifically allowed as an error return (no
376 such symbol).
377 */
378
379 static CORE_ADDR
380 bfd_lookup_symbol (bfd *abfd, char *symname)
381 {
382 long storage_needed;
383 asymbol *sym;
384 asymbol **symbol_table;
385 unsigned int number_of_symbols;
386 unsigned int i;
387 struct cleanup *back_to;
388 CORE_ADDR symaddr = 0;
389
390 storage_needed = bfd_get_symtab_upper_bound (abfd);
391
392 if (storage_needed > 0)
393 {
394 symbol_table = (asymbol **) xmalloc (storage_needed);
395 back_to = make_cleanup (xfree, symbol_table);
396 number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
397
398 for (i = 0; i < number_of_symbols; i++)
399 {
400 sym = *symbol_table++;
401 if (strcmp (sym->name, symname) == 0
402 && (sym->section->flags & (SEC_CODE | SEC_DATA)) != 0)
403 {
404 /* BFD symbols are section relative. */
405 symaddr = sym->value + sym->section->vma;
406 break;
407 }
408 }
409 do_cleanups (back_to);
410 }
411
412 if (symaddr)
413 return symaddr;
414
415 /* On FreeBSD, the dynamic linker is stripped by default. So we'll
416 have to check the dynamic string table too. */
417
418 storage_needed = bfd_get_dynamic_symtab_upper_bound (abfd);
419
420 if (storage_needed > 0)
421 {
422 symbol_table = (asymbol **) xmalloc (storage_needed);
423 back_to = make_cleanup (xfree, symbol_table);
424 number_of_symbols = bfd_canonicalize_dynamic_symtab (abfd, symbol_table);
425
426 for (i = 0; i < number_of_symbols; i++)
427 {
428 sym = *symbol_table++;
429
430 if (strcmp (sym->name, symname) == 0
431 && (sym->section->flags & (SEC_CODE | SEC_DATA)) != 0)
432 {
433 /* BFD symbols are section relative. */
434 symaddr = sym->value + sym->section->vma;
435 break;
436 }
437 }
438 do_cleanups (back_to);
439 }
440
441 return symaddr;
442 }
443
444
445 /* Read program header TYPE from inferior memory. The header is found
446 by scanning the OS auxillary vector.
447
448 Return a pointer to allocated memory holding the program header contents,
449 or NULL on failure. If sucessful, and unless P_SECT_SIZE is NULL, the
450 size of those contents is returned to P_SECT_SIZE. Likewise, the target
451 architecture size (32-bit or 64-bit) is returned to P_ARCH_SIZE. */
452
453 static gdb_byte *
454 read_program_header (int type, int *p_sect_size, int *p_arch_size)
455 {
456 enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
457 CORE_ADDR at_phdr, at_phent, at_phnum;
458 int arch_size, sect_size;
459 CORE_ADDR sect_addr;
460 gdb_byte *buf;
461
462 /* Get required auxv elements from target. */
463 if (target_auxv_search (&current_target, AT_PHDR, &at_phdr) <= 0)
464 return 0;
465 if (target_auxv_search (&current_target, AT_PHENT, &at_phent) <= 0)
466 return 0;
467 if (target_auxv_search (&current_target, AT_PHNUM, &at_phnum) <= 0)
468 return 0;
469 if (!at_phdr || !at_phnum)
470 return 0;
471
472 /* Determine ELF architecture type. */
473 if (at_phent == sizeof (Elf32_External_Phdr))
474 arch_size = 32;
475 else if (at_phent == sizeof (Elf64_External_Phdr))
476 arch_size = 64;
477 else
478 return 0;
479
480 /* Find .dynamic section via the PT_DYNAMIC PHDR. */
481 if (arch_size == 32)
482 {
483 Elf32_External_Phdr phdr;
484 int i;
485
486 /* Search for requested PHDR. */
487 for (i = 0; i < at_phnum; i++)
488 {
489 if (target_read_memory (at_phdr + i * sizeof (phdr),
490 (gdb_byte *)&phdr, sizeof (phdr)))
491 return 0;
492
493 if (extract_unsigned_integer ((gdb_byte *)phdr.p_type,
494 4, byte_order) == type)
495 break;
496 }
497
498 if (i == at_phnum)
499 return 0;
500
501 /* Retrieve address and size. */
502 sect_addr = extract_unsigned_integer ((gdb_byte *)phdr.p_vaddr,
503 4, byte_order);
504 sect_size = extract_unsigned_integer ((gdb_byte *)phdr.p_memsz,
505 4, byte_order);
506 }
507 else
508 {
509 Elf64_External_Phdr phdr;
510 int i;
511
512 /* Search for requested PHDR. */
513 for (i = 0; i < at_phnum; i++)
514 {
515 if (target_read_memory (at_phdr + i * sizeof (phdr),
516 (gdb_byte *)&phdr, sizeof (phdr)))
517 return 0;
518
519 if (extract_unsigned_integer ((gdb_byte *)phdr.p_type,
520 4, byte_order) == type)
521 break;
522 }
523
524 if (i == at_phnum)
525 return 0;
526
527 /* Retrieve address and size. */
528 sect_addr = extract_unsigned_integer ((gdb_byte *)phdr.p_vaddr,
529 8, byte_order);
530 sect_size = extract_unsigned_integer ((gdb_byte *)phdr.p_memsz,
531 8, byte_order);
532 }
533
534 /* Read in requested program header. */
535 buf = xmalloc (sect_size);
536 if (target_read_memory (sect_addr, buf, sect_size))
537 {
538 xfree (buf);
539 return NULL;
540 }
541
542 if (p_arch_size)
543 *p_arch_size = arch_size;
544 if (p_sect_size)
545 *p_sect_size = sect_size;
546
547 return buf;
548 }
549
550
551 /* Return program interpreter string. */
552 static gdb_byte *
553 find_program_interpreter (void)
554 {
555 gdb_byte *buf = NULL;
556
557 /* If we have an exec_bfd, use its section table. */
558 if (exec_bfd
559 && bfd_get_flavour (exec_bfd) == bfd_target_elf_flavour)
560 {
561 struct bfd_section *interp_sect;
562
563 interp_sect = bfd_get_section_by_name (exec_bfd, ".interp");
564 if (interp_sect != NULL)
565 {
566 CORE_ADDR sect_addr = bfd_section_vma (exec_bfd, interp_sect);
567 int sect_size = bfd_section_size (exec_bfd, interp_sect);
568
569 buf = xmalloc (sect_size);
570 bfd_get_section_contents (exec_bfd, interp_sect, buf, 0, sect_size);
571 }
572 }
573
574 /* If we didn't find it, use the target auxillary vector. */
575 if (!buf)
576 buf = read_program_header (PT_INTERP, NULL, NULL);
577
578 return buf;
579 }
580
581
582 /* Scan for DYNTAG in .dynamic section of ABFD. If DYNTAG is found 1 is
583 returned and the corresponding PTR is set. */
584
585 static int
586 scan_dyntag (int dyntag, bfd *abfd, CORE_ADDR *ptr)
587 {
588 int arch_size, step, sect_size;
589 long dyn_tag;
590 CORE_ADDR dyn_ptr, dyn_addr;
591 gdb_byte *bufend, *bufstart, *buf;
592 Elf32_External_Dyn *x_dynp_32;
593 Elf64_External_Dyn *x_dynp_64;
594 struct bfd_section *sect;
595 struct target_section *target_section;
596
597 if (abfd == NULL)
598 return 0;
599
600 if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
601 return 0;
602
603 arch_size = bfd_get_arch_size (abfd);
604 if (arch_size == -1)
605 return 0;
606
607 /* Find the start address of the .dynamic section. */
608 sect = bfd_get_section_by_name (abfd, ".dynamic");
609 if (sect == NULL)
610 return 0;
611
612 for (target_section = current_target_sections->sections;
613 target_section < current_target_sections->sections_end;
614 target_section++)
615 if (sect == target_section->the_bfd_section)
616 break;
617 if (target_section < current_target_sections->sections_end)
618 dyn_addr = target_section->addr;
619 else
620 {
621 /* ABFD may come from OBJFILE acting only as a symbol file without being
622 loaded into the target (see add_symbol_file_command). This case is
623 such fallback to the file VMA address without the possibility of
624 having the section relocated to its actual in-memory address. */
625
626 dyn_addr = bfd_section_vma (abfd, sect);
627 }
628
629 /* Read in .dynamic from the BFD. We will get the actual value
630 from memory later. */
631 sect_size = bfd_section_size (abfd, sect);
632 buf = bufstart = alloca (sect_size);
633 if (!bfd_get_section_contents (abfd, sect,
634 buf, 0, sect_size))
635 return 0;
636
637 /* Iterate over BUF and scan for DYNTAG. If found, set PTR and return. */
638 step = (arch_size == 32) ? sizeof (Elf32_External_Dyn)
639 : sizeof (Elf64_External_Dyn);
640 for (bufend = buf + sect_size;
641 buf < bufend;
642 buf += step)
643 {
644 if (arch_size == 32)
645 {
646 x_dynp_32 = (Elf32_External_Dyn *) buf;
647 dyn_tag = bfd_h_get_32 (abfd, (bfd_byte *) x_dynp_32->d_tag);
648 dyn_ptr = bfd_h_get_32 (abfd, (bfd_byte *) x_dynp_32->d_un.d_ptr);
649 }
650 else
651 {
652 x_dynp_64 = (Elf64_External_Dyn *) buf;
653 dyn_tag = bfd_h_get_64 (abfd, (bfd_byte *) x_dynp_64->d_tag);
654 dyn_ptr = bfd_h_get_64 (abfd, (bfd_byte *) x_dynp_64->d_un.d_ptr);
655 }
656 if (dyn_tag == DT_NULL)
657 return 0;
658 if (dyn_tag == dyntag)
659 {
660 /* If requested, try to read the runtime value of this .dynamic
661 entry. */
662 if (ptr)
663 {
664 struct type *ptr_type;
665 gdb_byte ptr_buf[8];
666 CORE_ADDR ptr_addr;
667
668 ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
669 ptr_addr = dyn_addr + (buf - bufstart) + arch_size / 8;
670 if (target_read_memory (ptr_addr, ptr_buf, arch_size / 8) == 0)
671 dyn_ptr = extract_typed_address (ptr_buf, ptr_type);
672 *ptr = dyn_ptr;
673 }
674 return 1;
675 }
676 }
677
678 return 0;
679 }
680
681 /* Scan for DYNTAG in .dynamic section of the target's main executable,
682 found by consulting the OS auxillary vector. If DYNTAG is found 1 is
683 returned and the corresponding PTR is set. */
684
685 static int
686 scan_dyntag_auxv (int dyntag, CORE_ADDR *ptr)
687 {
688 enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
689 int sect_size, arch_size, step;
690 long dyn_tag;
691 CORE_ADDR dyn_ptr;
692 gdb_byte *bufend, *bufstart, *buf;
693
694 /* Read in .dynamic section. */
695 buf = bufstart = read_program_header (PT_DYNAMIC, &sect_size, &arch_size);
696 if (!buf)
697 return 0;
698
699 /* Iterate over BUF and scan for DYNTAG. If found, set PTR and return. */
700 step = (arch_size == 32) ? sizeof (Elf32_External_Dyn)
701 : sizeof (Elf64_External_Dyn);
702 for (bufend = buf + sect_size;
703 buf < bufend;
704 buf += step)
705 {
706 if (arch_size == 32)
707 {
708 Elf32_External_Dyn *dynp = (Elf32_External_Dyn *) buf;
709 dyn_tag = extract_unsigned_integer ((gdb_byte *) dynp->d_tag,
710 4, byte_order);
711 dyn_ptr = extract_unsigned_integer ((gdb_byte *) dynp->d_un.d_ptr,
712 4, byte_order);
713 }
714 else
715 {
716 Elf64_External_Dyn *dynp = (Elf64_External_Dyn *) buf;
717 dyn_tag = extract_unsigned_integer ((gdb_byte *) dynp->d_tag,
718 8, byte_order);
719 dyn_ptr = extract_unsigned_integer ((gdb_byte *) dynp->d_un.d_ptr,
720 8, byte_order);
721 }
722 if (dyn_tag == DT_NULL)
723 break;
724
725 if (dyn_tag == dyntag)
726 {
727 if (ptr)
728 *ptr = dyn_ptr;
729
730 xfree (bufstart);
731 return 1;
732 }
733 }
734
735 xfree (bufstart);
736 return 0;
737 }
738
739
740 /*
741
742 LOCAL FUNCTION
743
744 elf_locate_base -- locate the base address of dynamic linker structs
745 for SVR4 elf targets.
746
747 SYNOPSIS
748
749 CORE_ADDR elf_locate_base (void)
750
751 DESCRIPTION
752
753 For SVR4 elf targets the address of the dynamic linker's runtime
754 structure is contained within the dynamic info section in the
755 executable file. The dynamic section is also mapped into the
756 inferior address space. Because the runtime loader fills in the
757 real address before starting the inferior, we have to read in the
758 dynamic info section from the inferior address space.
759 If there are any errors while trying to find the address, we
760 silently return 0, otherwise the found address is returned.
761
762 */
763
764 static CORE_ADDR
765 elf_locate_base (void)
766 {
767 struct minimal_symbol *msymbol;
768 CORE_ADDR dyn_ptr;
769
770 /* Look for DT_MIPS_RLD_MAP first. MIPS executables use this
771 instead of DT_DEBUG, although they sometimes contain an unused
772 DT_DEBUG. */
773 if (scan_dyntag (DT_MIPS_RLD_MAP, exec_bfd, &dyn_ptr)
774 || scan_dyntag_auxv (DT_MIPS_RLD_MAP, &dyn_ptr))
775 {
776 struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
777 gdb_byte *pbuf;
778 int pbuf_size = TYPE_LENGTH (ptr_type);
779 pbuf = alloca (pbuf_size);
780 /* DT_MIPS_RLD_MAP contains a pointer to the address
781 of the dynamic link structure. */
782 if (target_read_memory (dyn_ptr, pbuf, pbuf_size))
783 return 0;
784 return extract_typed_address (pbuf, ptr_type);
785 }
786
787 /* Find DT_DEBUG. */
788 if (scan_dyntag (DT_DEBUG, exec_bfd, &dyn_ptr)
789 || scan_dyntag_auxv (DT_DEBUG, &dyn_ptr))
790 return dyn_ptr;
791
792 /* This may be a static executable. Look for the symbol
793 conventionally named _r_debug, as a last resort. */
794 msymbol = lookup_minimal_symbol ("_r_debug", NULL, symfile_objfile);
795 if (msymbol != NULL)
796 return SYMBOL_VALUE_ADDRESS (msymbol);
797
798 /* DT_DEBUG entry not found. */
799 return 0;
800 }
801
802 /*
803
804 LOCAL FUNCTION
805
806 locate_base -- locate the base address of dynamic linker structs
807
808 SYNOPSIS
809
810 CORE_ADDR locate_base (struct svr4_info *)
811
812 DESCRIPTION
813
814 For both the SunOS and SVR4 shared library implementations, if the
815 inferior executable has been linked dynamically, there is a single
816 address somewhere in the inferior's data space which is the key to
817 locating all of the dynamic linker's runtime structures. This
818 address is the value of the debug base symbol. The job of this
819 function is to find and return that address, or to return 0 if there
820 is no such address (the executable is statically linked for example).
821
822 For SunOS, the job is almost trivial, since the dynamic linker and
823 all of it's structures are statically linked to the executable at
824 link time. Thus the symbol for the address we are looking for has
825 already been added to the minimal symbol table for the executable's
826 objfile at the time the symbol file's symbols were read, and all we
827 have to do is look it up there. Note that we explicitly do NOT want
828 to find the copies in the shared library.
829
830 The SVR4 version is a bit more complicated because the address
831 is contained somewhere in the dynamic info section. We have to go
832 to a lot more work to discover the address of the debug base symbol.
833 Because of this complexity, we cache the value we find and return that
834 value on subsequent invocations. Note there is no copy in the
835 executable symbol tables.
836
837 */
838
839 static CORE_ADDR
840 locate_base (struct svr4_info *info)
841 {
842 /* Check to see if we have a currently valid address, and if so, avoid
843 doing all this work again and just return the cached address. If
844 we have no cached address, try to locate it in the dynamic info
845 section for ELF executables. There's no point in doing any of this
846 though if we don't have some link map offsets to work with. */
847
848 if (info->debug_base == 0 && svr4_have_link_map_offsets ())
849 info->debug_base = elf_locate_base ();
850 return info->debug_base;
851 }
852
853 /* Find the first element in the inferior's dynamic link map, and
854 return its address in the inferior.
855
856 FIXME: Perhaps we should validate the info somehow, perhaps by
857 checking r_version for a known version number, or r_state for
858 RT_CONSISTENT. */
859
860 static CORE_ADDR
861 solib_svr4_r_map (struct svr4_info *info)
862 {
863 struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
864 struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
865
866 return read_memory_typed_address (info->debug_base + lmo->r_map_offset,
867 ptr_type);
868 }
869
870 /* Find r_brk from the inferior's debug base. */
871
872 static CORE_ADDR
873 solib_svr4_r_brk (struct svr4_info *info)
874 {
875 struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
876 struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
877
878 return read_memory_typed_address (info->debug_base + lmo->r_brk_offset,
879 ptr_type);
880 }
881
882 /* Find the link map for the dynamic linker (if it is not in the
883 normal list of loaded shared objects). */
884
885 static CORE_ADDR
886 solib_svr4_r_ldsomap (struct svr4_info *info)
887 {
888 struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
889 struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
890 enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
891 ULONGEST version;
892
893 /* Check version, and return zero if `struct r_debug' doesn't have
894 the r_ldsomap member. */
895 version
896 = read_memory_unsigned_integer (info->debug_base + lmo->r_version_offset,
897 lmo->r_version_size, byte_order);
898 if (version < 2 || lmo->r_ldsomap_offset == -1)
899 return 0;
900
901 return read_memory_typed_address (info->debug_base + lmo->r_ldsomap_offset,
902 ptr_type);
903 }
904
905 /* On Solaris systems with some versions of the dynamic linker,
906 ld.so's l_name pointer points to the SONAME in the string table
907 rather than into writable memory. So that GDB can find shared
908 libraries when loading a core file generated by gcore, ensure that
909 memory areas containing the l_name string are saved in the core
910 file. */
911
912 static int
913 svr4_keep_data_in_core (CORE_ADDR vaddr, unsigned long size)
914 {
915 struct svr4_info *info;
916 CORE_ADDR ldsomap;
917 struct so_list *new;
918 struct cleanup *old_chain;
919 struct link_map_offsets *lmo;
920 CORE_ADDR lm_name;
921
922 info = get_svr4_info ();
923
924 info->debug_base = 0;
925 locate_base (info);
926 if (!info->debug_base)
927 return 0;
928
929 ldsomap = solib_svr4_r_ldsomap (info);
930 if (!ldsomap)
931 return 0;
932
933 lmo = svr4_fetch_link_map_offsets ();
934 new = XZALLOC (struct so_list);
935 old_chain = make_cleanup (xfree, new);
936 new->lm_info = xmalloc (sizeof (struct lm_info));
937 make_cleanup (xfree, new->lm_info);
938 new->lm_info->l_addr = (CORE_ADDR)-1;
939 new->lm_info->lm_addr = ldsomap;
940 new->lm_info->lm = xzalloc (lmo->link_map_size);
941 make_cleanup (xfree, new->lm_info->lm);
942 read_memory (ldsomap, new->lm_info->lm, lmo->link_map_size);
943 lm_name = LM_NAME (new);
944 do_cleanups (old_chain);
945
946 return (lm_name >= vaddr && lm_name < vaddr + size);
947 }
948
949 /*
950
951 LOCAL FUNCTION
952
953 open_symbol_file_object
954
955 SYNOPSIS
956
957 void open_symbol_file_object (void *from_tty)
958
959 DESCRIPTION
960
961 If no open symbol file, attempt to locate and open the main symbol
962 file. On SVR4 systems, this is the first link map entry. If its
963 name is here, we can open it. Useful when attaching to a process
964 without first loading its symbol file.
965
966 If FROM_TTYP dereferences to a non-zero integer, allow messages to
967 be printed. This parameter is a pointer rather than an int because
968 open_symbol_file_object() is called via catch_errors() and
969 catch_errors() requires a pointer argument. */
970
971 static int
972 open_symbol_file_object (void *from_ttyp)
973 {
974 CORE_ADDR lm, l_name;
975 char *filename;
976 int errcode;
977 int from_tty = *(int *)from_ttyp;
978 struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
979 struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
980 int l_name_size = TYPE_LENGTH (ptr_type);
981 gdb_byte *l_name_buf = xmalloc (l_name_size);
982 struct cleanup *cleanups = make_cleanup (xfree, l_name_buf);
983 struct svr4_info *info = get_svr4_info ();
984
985 if (symfile_objfile)
986 if (!query (_("Attempt to reload symbols from process? ")))
987 return 0;
988
989 /* Always locate the debug struct, in case it has moved. */
990 info->debug_base = 0;
991 if (locate_base (info) == 0)
992 return 0; /* failed somehow... */
993
994 /* First link map member should be the executable. */
995 lm = solib_svr4_r_map (info);
996 if (lm == 0)
997 return 0; /* failed somehow... */
998
999 /* Read address of name from target memory to GDB. */
1000 read_memory (lm + lmo->l_name_offset, l_name_buf, l_name_size);
1001
1002 /* Convert the address to host format. */
1003 l_name = extract_typed_address (l_name_buf, ptr_type);
1004
1005 /* Free l_name_buf. */
1006 do_cleanups (cleanups);
1007
1008 if (l_name == 0)
1009 return 0; /* No filename. */
1010
1011 /* Now fetch the filename from target memory. */
1012 target_read_string (l_name, &filename, SO_NAME_MAX_PATH_SIZE - 1, &errcode);
1013 make_cleanup (xfree, filename);
1014
1015 if (errcode)
1016 {
1017 warning (_("failed to read exec filename from attached file: %s"),
1018 safe_strerror (errcode));
1019 return 0;
1020 }
1021
1022 /* Have a pathname: read the symbol file. */
1023 symbol_file_add_main (filename, from_tty);
1024
1025 return 1;
1026 }
1027
1028 /* If no shared library information is available from the dynamic
1029 linker, build a fallback list from other sources. */
1030
1031 static struct so_list *
1032 svr4_default_sos (void)
1033 {
1034 struct svr4_info *info = get_svr4_info ();
1035
1036 struct so_list *head = NULL;
1037 struct so_list **link_ptr = &head;
1038
1039 if (info->debug_loader_offset_p)
1040 {
1041 struct so_list *new = XZALLOC (struct so_list);
1042
1043 new->lm_info = xmalloc (sizeof (struct lm_info));
1044
1045 /* Nothing will ever check the cached copy of the link
1046 map if we set l_addr. */
1047 new->lm_info->l_addr = info->debug_loader_offset;
1048 new->lm_info->lm_addr = 0;
1049 new->lm_info->lm = NULL;
1050
1051 strncpy (new->so_name, info->debug_loader_name,
1052 SO_NAME_MAX_PATH_SIZE - 1);
1053 new->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
1054 strcpy (new->so_original_name, new->so_name);
1055
1056 *link_ptr = new;
1057 link_ptr = &new->next;
1058 }
1059
1060 return head;
1061 }
1062
1063 /* LOCAL FUNCTION
1064
1065 current_sos -- build a list of currently loaded shared objects
1066
1067 SYNOPSIS
1068
1069 struct so_list *current_sos ()
1070
1071 DESCRIPTION
1072
1073 Build a list of `struct so_list' objects describing the shared
1074 objects currently loaded in the inferior. This list does not
1075 include an entry for the main executable file.
1076
1077 Note that we only gather information directly available from the
1078 inferior --- we don't examine any of the shared library files
1079 themselves. The declaration of `struct so_list' says which fields
1080 we provide values for. */
1081
1082 static struct so_list *
1083 svr4_current_sos (void)
1084 {
1085 CORE_ADDR lm;
1086 struct so_list *head = 0;
1087 struct so_list **link_ptr = &head;
1088 CORE_ADDR ldsomap = 0;
1089 struct svr4_info *info;
1090
1091 info = get_svr4_info ();
1092
1093 /* Always locate the debug struct, in case it has moved. */
1094 info->debug_base = 0;
1095 locate_base (info);
1096
1097 /* If we can't find the dynamic linker's base structure, this
1098 must not be a dynamically linked executable. Hmm. */
1099 if (! info->debug_base)
1100 return svr4_default_sos ();
1101
1102 /* Walk the inferior's link map list, and build our list of
1103 `struct so_list' nodes. */
1104 lm = solib_svr4_r_map (info);
1105
1106 while (lm)
1107 {
1108 struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
1109 struct so_list *new = XZALLOC (struct so_list);
1110 struct cleanup *old_chain = make_cleanup (xfree, new);
1111
1112 new->lm_info = xmalloc (sizeof (struct lm_info));
1113 make_cleanup (xfree, new->lm_info);
1114
1115 new->lm_info->l_addr = (CORE_ADDR)-1;
1116 new->lm_info->lm_addr = lm;
1117 new->lm_info->lm = xzalloc (lmo->link_map_size);
1118 make_cleanup (xfree, new->lm_info->lm);
1119
1120 read_memory (lm, new->lm_info->lm, lmo->link_map_size);
1121
1122 lm = LM_NEXT (new);
1123
1124 /* For SVR4 versions, the first entry in the link map is for the
1125 inferior executable, so we must ignore it. For some versions of
1126 SVR4, it has no name. For others (Solaris 2.3 for example), it
1127 does have a name, so we can no longer use a missing name to
1128 decide when to ignore it. */
1129 if (IGNORE_FIRST_LINK_MAP_ENTRY (new) && ldsomap == 0)
1130 {
1131 info->main_lm_addr = new->lm_info->lm_addr;
1132 free_so (new);
1133 }
1134 else
1135 {
1136 int errcode;
1137 char *buffer;
1138
1139 /* Extract this shared object's name. */
1140 target_read_string (LM_NAME (new), &buffer,
1141 SO_NAME_MAX_PATH_SIZE - 1, &errcode);
1142 if (errcode != 0)
1143 warning (_("Can't read pathname for load map: %s."),
1144 safe_strerror (errcode));
1145 else
1146 {
1147 strncpy (new->so_name, buffer, SO_NAME_MAX_PATH_SIZE - 1);
1148 new->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
1149 strcpy (new->so_original_name, new->so_name);
1150 }
1151 xfree (buffer);
1152
1153 /* If this entry has no name, or its name matches the name
1154 for the main executable, don't include it in the list. */
1155 if (! new->so_name[0]
1156 || match_main (new->so_name))
1157 free_so (new);
1158 else
1159 {
1160 new->next = 0;
1161 *link_ptr = new;
1162 link_ptr = &new->next;
1163 }
1164 }
1165
1166 /* On Solaris, the dynamic linker is not in the normal list of
1167 shared objects, so make sure we pick it up too. Having
1168 symbol information for the dynamic linker is quite crucial
1169 for skipping dynamic linker resolver code. */
1170 if (lm == 0 && ldsomap == 0)
1171 lm = ldsomap = solib_svr4_r_ldsomap (info);
1172
1173 discard_cleanups (old_chain);
1174 }
1175
1176 if (head == NULL)
1177 return svr4_default_sos ();
1178
1179 return head;
1180 }
1181
1182 /* Get the address of the link_map for a given OBJFILE. */
1183
1184 CORE_ADDR
1185 svr4_fetch_objfile_link_map (struct objfile *objfile)
1186 {
1187 struct so_list *so;
1188 struct svr4_info *info = get_svr4_info ();
1189
1190 /* Cause svr4_current_sos() to be run if it hasn't been already. */
1191 if (info->main_lm_addr == 0)
1192 solib_add (NULL, 0, &current_target, auto_solib_add);
1193
1194 /* svr4_current_sos() will set main_lm_addr for the main executable. */
1195 if (objfile == symfile_objfile)
1196 return info->main_lm_addr;
1197
1198 /* The other link map addresses may be found by examining the list
1199 of shared libraries. */
1200 for (so = master_so_list (); so; so = so->next)
1201 if (so->objfile == objfile)
1202 return so->lm_info->lm_addr;
1203
1204 /* Not found! */
1205 return 0;
1206 }
1207
1208 /* On some systems, the only way to recognize the link map entry for
1209 the main executable file is by looking at its name. Return
1210 non-zero iff SONAME matches one of the known main executable names. */
1211
1212 static int
1213 match_main (char *soname)
1214 {
1215 char **mainp;
1216
1217 for (mainp = main_name_list; *mainp != NULL; mainp++)
1218 {
1219 if (strcmp (soname, *mainp) == 0)
1220 return (1);
1221 }
1222
1223 return (0);
1224 }
1225
1226 /* Return 1 if PC lies in the dynamic symbol resolution code of the
1227 SVR4 run time loader. */
1228
1229 int
1230 svr4_in_dynsym_resolve_code (CORE_ADDR pc)
1231 {
1232 struct svr4_info *info = get_svr4_info ();
1233
1234 return ((pc >= info->interp_text_sect_low
1235 && pc < info->interp_text_sect_high)
1236 || (pc >= info->interp_plt_sect_low
1237 && pc < info->interp_plt_sect_high)
1238 || in_plt_section (pc, NULL));
1239 }
1240
1241 /* Given an executable's ABFD and target, compute the entry-point
1242 address. */
1243
1244 static CORE_ADDR
1245 exec_entry_point (struct bfd *abfd, struct target_ops *targ)
1246 {
1247 /* KevinB wrote ... for most targets, the address returned by
1248 bfd_get_start_address() is the entry point for the start
1249 function. But, for some targets, bfd_get_start_address() returns
1250 the address of a function descriptor from which the entry point
1251 address may be extracted. This address is extracted by
1252 gdbarch_convert_from_func_ptr_addr(). The method
1253 gdbarch_convert_from_func_ptr_addr() is the merely the identify
1254 function for targets which don't use function descriptors. */
1255 return gdbarch_convert_from_func_ptr_addr (target_gdbarch,
1256 bfd_get_start_address (abfd),
1257 targ);
1258 }
1259
1260 /*
1261
1262 LOCAL FUNCTION
1263
1264 enable_break -- arrange for dynamic linker to hit breakpoint
1265
1266 SYNOPSIS
1267
1268 int enable_break (void)
1269
1270 DESCRIPTION
1271
1272 Both the SunOS and the SVR4 dynamic linkers have, as part of their
1273 debugger interface, support for arranging for the inferior to hit
1274 a breakpoint after mapping in the shared libraries. This function
1275 enables that breakpoint.
1276
1277 For SunOS, there is a special flag location (in_debugger) which we
1278 set to 1. When the dynamic linker sees this flag set, it will set
1279 a breakpoint at a location known only to itself, after saving the
1280 original contents of that place and the breakpoint address itself,
1281 in it's own internal structures. When we resume the inferior, it
1282 will eventually take a SIGTRAP when it runs into the breakpoint.
1283 We handle this (in a different place) by restoring the contents of
1284 the breakpointed location (which is only known after it stops),
1285 chasing around to locate the shared libraries that have been
1286 loaded, then resuming.
1287
1288 For SVR4, the debugger interface structure contains a member (r_brk)
1289 which is statically initialized at the time the shared library is
1290 built, to the offset of a function (_r_debug_state) which is guaran-
1291 teed to be called once before mapping in a library, and again when
1292 the mapping is complete. At the time we are examining this member,
1293 it contains only the unrelocated offset of the function, so we have
1294 to do our own relocation. Later, when the dynamic linker actually
1295 runs, it relocates r_brk to be the actual address of _r_debug_state().
1296
1297 The debugger interface structure also contains an enumeration which
1298 is set to either RT_ADD or RT_DELETE prior to changing the mapping,
1299 depending upon whether or not the library is being mapped or unmapped,
1300 and then set to RT_CONSISTENT after the library is mapped/unmapped.
1301 */
1302
1303 static int
1304 enable_break (struct svr4_info *info, int from_tty)
1305 {
1306 struct minimal_symbol *msymbol;
1307 char **bkpt_namep;
1308 asection *interp_sect;
1309 gdb_byte *interp_name;
1310 CORE_ADDR sym_addr;
1311
1312 /* First, remove all the solib event breakpoints. Their addresses
1313 may have changed since the last time we ran the program. */
1314 remove_solib_event_breakpoints ();
1315
1316 info->interp_text_sect_low = info->interp_text_sect_high = 0;
1317 info->interp_plt_sect_low = info->interp_plt_sect_high = 0;
1318
1319 /* If we already have a shared library list in the target, and
1320 r_debug contains r_brk, set the breakpoint there - this should
1321 mean r_brk has already been relocated. Assume the dynamic linker
1322 is the object containing r_brk. */
1323
1324 solib_add (NULL, from_tty, &current_target, auto_solib_add);
1325 sym_addr = 0;
1326 if (info->debug_base && solib_svr4_r_map (info) != 0)
1327 sym_addr = solib_svr4_r_brk (info);
1328
1329 if (sym_addr != 0)
1330 {
1331 struct obj_section *os;
1332
1333 sym_addr = gdbarch_addr_bits_remove
1334 (target_gdbarch, gdbarch_convert_from_func_ptr_addr (target_gdbarch,
1335 sym_addr,
1336 &current_target));
1337
1338 /* On at least some versions of Solaris there's a dynamic relocation
1339 on _r_debug.r_brk and SYM_ADDR may not be relocated yet, e.g., if
1340 we get control before the dynamic linker has self-relocated.
1341 Check if SYM_ADDR is in a known section, if it is assume we can
1342 trust its value. This is just a heuristic though, it could go away
1343 or be replaced if it's getting in the way.
1344
1345 On ARM we need to know whether the ISA of rtld_db_dlactivity (or
1346 however it's spelled in your particular system) is ARM or Thumb.
1347 That knowledge is encoded in the address, if it's Thumb the low bit
1348 is 1. However, we've stripped that info above and it's not clear
1349 what all the consequences are of passing a non-addr_bits_remove'd
1350 address to create_solib_event_breakpoint. The call to
1351 find_pc_section verifies we know about the address and have some
1352 hope of computing the right kind of breakpoint to use (via
1353 symbol info). It does mean that GDB needs to be pointed at a
1354 non-stripped version of the dynamic linker in order to obtain
1355 information it already knows about. Sigh. */
1356
1357 os = find_pc_section (sym_addr);
1358 if (os != NULL)
1359 {
1360 /* Record the relocated start and end address of the dynamic linker
1361 text and plt section for svr4_in_dynsym_resolve_code. */
1362 bfd *tmp_bfd;
1363 CORE_ADDR load_addr;
1364
1365 tmp_bfd = os->objfile->obfd;
1366 load_addr = ANOFFSET (os->objfile->section_offsets,
1367 os->objfile->sect_index_text);
1368
1369 interp_sect = bfd_get_section_by_name (tmp_bfd, ".text");
1370 if (interp_sect)
1371 {
1372 info->interp_text_sect_low =
1373 bfd_section_vma (tmp_bfd, interp_sect) + load_addr;
1374 info->interp_text_sect_high =
1375 info->interp_text_sect_low
1376 + bfd_section_size (tmp_bfd, interp_sect);
1377 }
1378 interp_sect = bfd_get_section_by_name (tmp_bfd, ".plt");
1379 if (interp_sect)
1380 {
1381 info->interp_plt_sect_low =
1382 bfd_section_vma (tmp_bfd, interp_sect) + load_addr;
1383 info->interp_plt_sect_high =
1384 info->interp_plt_sect_low
1385 + bfd_section_size (tmp_bfd, interp_sect);
1386 }
1387
1388 create_solib_event_breakpoint (target_gdbarch, sym_addr);
1389 return 1;
1390 }
1391 }
1392
1393 /* Find the program interpreter; if not found, warn the user and drop
1394 into the old breakpoint at symbol code. */
1395 interp_name = find_program_interpreter ();
1396 if (interp_name)
1397 {
1398 CORE_ADDR load_addr = 0;
1399 int load_addr_found = 0;
1400 int loader_found_in_list = 0;
1401 struct so_list *so;
1402 bfd *tmp_bfd = NULL;
1403 struct target_ops *tmp_bfd_target;
1404 volatile struct gdb_exception ex;
1405
1406 sym_addr = 0;
1407
1408 /* Now we need to figure out where the dynamic linker was
1409 loaded so that we can load its symbols and place a breakpoint
1410 in the dynamic linker itself.
1411
1412 This address is stored on the stack. However, I've been unable
1413 to find any magic formula to find it for Solaris (appears to
1414 be trivial on GNU/Linux). Therefore, we have to try an alternate
1415 mechanism to find the dynamic linker's base address. */
1416
1417 TRY_CATCH (ex, RETURN_MASK_ALL)
1418 {
1419 tmp_bfd = solib_bfd_open (interp_name);
1420 }
1421 if (tmp_bfd == NULL)
1422 goto bkpt_at_symbol;
1423
1424 /* Now convert the TMP_BFD into a target. That way target, as
1425 well as BFD operations can be used. Note that closing the
1426 target will also close the underlying bfd. */
1427 tmp_bfd_target = target_bfd_reopen (tmp_bfd);
1428
1429 /* On a running target, we can get the dynamic linker's base
1430 address from the shared library table. */
1431 so = master_so_list ();
1432 while (so)
1433 {
1434 if (svr4_same_1 (interp_name, so->so_original_name))
1435 {
1436 load_addr_found = 1;
1437 loader_found_in_list = 1;
1438 load_addr = LM_ADDR_CHECK (so, tmp_bfd);
1439 break;
1440 }
1441 so = so->next;
1442 }
1443
1444 /* If we were not able to find the base address of the loader
1445 from our so_list, then try using the AT_BASE auxilliary entry. */
1446 if (!load_addr_found)
1447 if (target_auxv_search (&current_target, AT_BASE, &load_addr) > 0)
1448 load_addr_found = 1;
1449
1450 /* Otherwise we find the dynamic linker's base address by examining
1451 the current pc (which should point at the entry point for the
1452 dynamic linker) and subtracting the offset of the entry point.
1453
1454 This is more fragile than the previous approaches, but is a good
1455 fallback method because it has actually been working well in
1456 most cases. */
1457 if (!load_addr_found)
1458 {
1459 struct regcache *regcache
1460 = get_thread_arch_regcache (inferior_ptid, target_gdbarch);
1461 load_addr = (regcache_read_pc (regcache)
1462 - exec_entry_point (tmp_bfd, tmp_bfd_target));
1463 }
1464
1465 if (!loader_found_in_list)
1466 {
1467 info->debug_loader_name = xstrdup (interp_name);
1468 info->debug_loader_offset_p = 1;
1469 info->debug_loader_offset = load_addr;
1470 solib_add (NULL, from_tty, &current_target, auto_solib_add);
1471 }
1472
1473 /* Record the relocated start and end address of the dynamic linker
1474 text and plt section for svr4_in_dynsym_resolve_code. */
1475 interp_sect = bfd_get_section_by_name (tmp_bfd, ".text");
1476 if (interp_sect)
1477 {
1478 info->interp_text_sect_low =
1479 bfd_section_vma (tmp_bfd, interp_sect) + load_addr;
1480 info->interp_text_sect_high =
1481 info->interp_text_sect_low
1482 + bfd_section_size (tmp_bfd, interp_sect);
1483 }
1484 interp_sect = bfd_get_section_by_name (tmp_bfd, ".plt");
1485 if (interp_sect)
1486 {
1487 info->interp_plt_sect_low =
1488 bfd_section_vma (tmp_bfd, interp_sect) + load_addr;
1489 info->interp_plt_sect_high =
1490 info->interp_plt_sect_low
1491 + bfd_section_size (tmp_bfd, interp_sect);
1492 }
1493
1494 /* Now try to set a breakpoint in the dynamic linker. */
1495 for (bkpt_namep = solib_break_names; *bkpt_namep != NULL; bkpt_namep++)
1496 {
1497 sym_addr = bfd_lookup_symbol (tmp_bfd, *bkpt_namep);
1498 if (sym_addr != 0)
1499 break;
1500 }
1501
1502 if (sym_addr != 0)
1503 /* Convert 'sym_addr' from a function pointer to an address.
1504 Because we pass tmp_bfd_target instead of the current
1505 target, this will always produce an unrelocated value. */
1506 sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch,
1507 sym_addr,
1508 tmp_bfd_target);
1509
1510 /* We're done with both the temporary bfd and target. Remember,
1511 closing the target closes the underlying bfd. */
1512 target_close (tmp_bfd_target, 0);
1513
1514 if (sym_addr != 0)
1515 {
1516 create_solib_event_breakpoint (target_gdbarch, load_addr + sym_addr);
1517 xfree (interp_name);
1518 return 1;
1519 }
1520
1521 /* For whatever reason we couldn't set a breakpoint in the dynamic
1522 linker. Warn and drop into the old code. */
1523 bkpt_at_symbol:
1524 xfree (interp_name);
1525 warning (_("Unable to find dynamic linker breakpoint function.\n"
1526 "GDB will be unable to debug shared library initializers\n"
1527 "and track explicitly loaded dynamic code."));
1528 }
1529
1530 /* Scan through the lists of symbols, trying to look up the symbol and
1531 set a breakpoint there. Terminate loop when we/if we succeed. */
1532
1533 for (bkpt_namep = solib_break_names; *bkpt_namep != NULL; bkpt_namep++)
1534 {
1535 msymbol = lookup_minimal_symbol (*bkpt_namep, NULL, symfile_objfile);
1536 if ((msymbol != NULL) && (SYMBOL_VALUE_ADDRESS (msymbol) != 0))
1537 {
1538 sym_addr = SYMBOL_VALUE_ADDRESS (msymbol);
1539 sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch,
1540 sym_addr,
1541 &current_target);
1542 create_solib_event_breakpoint (target_gdbarch, sym_addr);
1543 return 1;
1544 }
1545 }
1546
1547 for (bkpt_namep = bkpt_names; *bkpt_namep != NULL; bkpt_namep++)
1548 {
1549 msymbol = lookup_minimal_symbol (*bkpt_namep, NULL, symfile_objfile);
1550 if ((msymbol != NULL) && (SYMBOL_VALUE_ADDRESS (msymbol) != 0))
1551 {
1552 sym_addr = SYMBOL_VALUE_ADDRESS (msymbol);
1553 sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch,
1554 sym_addr,
1555 &current_target);
1556 create_solib_event_breakpoint (target_gdbarch, sym_addr);
1557 return 1;
1558 }
1559 }
1560 return 0;
1561 }
1562
1563 /*
1564
1565 LOCAL FUNCTION
1566
1567 special_symbol_handling -- additional shared library symbol handling
1568
1569 SYNOPSIS
1570
1571 void special_symbol_handling ()
1572
1573 DESCRIPTION
1574
1575 Once the symbols from a shared object have been loaded in the usual
1576 way, we are called to do any system specific symbol handling that
1577 is needed.
1578
1579 For SunOS4, this consisted of grunging around in the dynamic
1580 linkers structures to find symbol definitions for "common" symbols
1581 and adding them to the minimal symbol table for the runtime common
1582 objfile.
1583
1584 However, for SVR4, there's nothing to do.
1585
1586 */
1587
1588 static void
1589 svr4_special_symbol_handling (void)
1590 {
1591 svr4_relocate_main_executable ();
1592 }
1593
1594 /* Decide if the objfile needs to be relocated. As indicated above,
1595 we will only be here when execution is stopped at the beginning
1596 of the program. Relocation is necessary if the address at which
1597 we are presently stopped differs from the start address stored in
1598 the executable AND there's no interpreter section. The condition
1599 regarding the interpreter section is very important because if
1600 there *is* an interpreter section, execution will begin there
1601 instead. When there is an interpreter section, the start address
1602 is (presumably) used by the interpreter at some point to start
1603 execution of the program.
1604
1605 If there is an interpreter, it is normal for it to be set to an
1606 arbitrary address at the outset. The job of finding it is
1607 handled in enable_break().
1608
1609 So, to summarize, relocations are necessary when there is no
1610 interpreter section and the start address obtained from the
1611 executable is different from the address at which GDB is
1612 currently stopped.
1613
1614 [ The astute reader will note that we also test to make sure that
1615 the executable in question has the DYNAMIC flag set. It is my
1616 opinion that this test is unnecessary (undesirable even). It
1617 was added to avoid inadvertent relocation of an executable
1618 whose e_type member in the ELF header is not ET_DYN. There may
1619 be a time in the future when it is desirable to do relocations
1620 on other types of files as well in which case this condition
1621 should either be removed or modified to accomodate the new file
1622 type. (E.g, an ET_EXEC executable which has been built to be
1623 position-independent could safely be relocated by the OS if
1624 desired. It is true that this violates the ABI, but the ABI
1625 has been known to be bent from time to time.) - Kevin, Nov 2000. ]
1626 */
1627
1628 static CORE_ADDR
1629 svr4_static_exec_displacement (void)
1630 {
1631 asection *interp_sect;
1632 struct regcache *regcache
1633 = get_thread_arch_regcache (inferior_ptid, target_gdbarch);
1634 CORE_ADDR pc = regcache_read_pc (regcache);
1635
1636 interp_sect = bfd_get_section_by_name (exec_bfd, ".interp");
1637 if (interp_sect == NULL
1638 && (bfd_get_file_flags (exec_bfd) & DYNAMIC) != 0
1639 && (exec_entry_point (exec_bfd, &exec_ops) != pc))
1640 return pc - exec_entry_point (exec_bfd, &exec_ops);
1641
1642 return 0;
1643 }
1644
1645 /* We relocate all of the sections by the same amount. This
1646 behavior is mandated by recent editions of the System V ABI.
1647 According to the System V Application Binary Interface,
1648 Edition 4.1, page 5-5:
1649
1650 ... Though the system chooses virtual addresses for
1651 individual processes, it maintains the segments' relative
1652 positions. Because position-independent code uses relative
1653 addressesing between segments, the difference between
1654 virtual addresses in memory must match the difference
1655 between virtual addresses in the file. The difference
1656 between the virtual address of any segment in memory and
1657 the corresponding virtual address in the file is thus a
1658 single constant value for any one executable or shared
1659 object in a given process. This difference is the base
1660 address. One use of the base address is to relocate the
1661 memory image of the program during dynamic linking.
1662
1663 The same language also appears in Edition 4.0 of the System V
1664 ABI and is left unspecified in some of the earlier editions. */
1665
1666 static CORE_ADDR
1667 svr4_exec_displacement (void)
1668 {
1669 int found;
1670 /* ENTRY_POINT is a possible function descriptor - before
1671 a call to gdbarch_convert_from_func_ptr_addr. */
1672 CORE_ADDR entry_point;
1673
1674 if (exec_bfd == NULL)
1675 return 0;
1676
1677 if (target_auxv_search (&current_target, AT_ENTRY, &entry_point) == 1)
1678 return entry_point - bfd_get_start_address (exec_bfd);
1679
1680 return svr4_static_exec_displacement ();
1681 }
1682
1683 /* Relocate the main executable. This function should be called upon
1684 stopping the inferior process at the entry point to the program.
1685 The entry point from BFD is compared to the AT_ENTRY of AUXV and if they are
1686 different, the main executable is relocated by the proper amount. */
1687
1688 static void
1689 svr4_relocate_main_executable (void)
1690 {
1691 CORE_ADDR displacement = svr4_exec_displacement ();
1692
1693 /* Even if DISPLACEMENT is 0 still try to relocate it as this is a new
1694 difference of in-memory vs. in-file addresses and we could already
1695 relocate the executable at this function to improper address before. */
1696
1697 if (symfile_objfile)
1698 {
1699 struct section_offsets *new_offsets;
1700 int i;
1701
1702 new_offsets = alloca (symfile_objfile->num_sections
1703 * sizeof (*new_offsets));
1704
1705 for (i = 0; i < symfile_objfile->num_sections; i++)
1706 new_offsets->offsets[i] = displacement;
1707
1708 objfile_relocate (symfile_objfile, new_offsets);
1709 }
1710 else if (exec_bfd)
1711 {
1712 asection *asect;
1713
1714 for (asect = exec_bfd->sections; asect != NULL; asect = asect->next)
1715 exec_set_section_address (bfd_get_filename (exec_bfd), asect->index,
1716 (bfd_section_vma (exec_bfd, asect)
1717 + displacement));
1718 }
1719 }
1720
1721 /*
1722
1723 GLOBAL FUNCTION
1724
1725 svr4_solib_create_inferior_hook -- shared library startup support
1726
1727 SYNOPSIS
1728
1729 void svr4_solib_create_inferior_hook (int from_tty)
1730
1731 DESCRIPTION
1732
1733 When gdb starts up the inferior, it nurses it along (through the
1734 shell) until it is ready to execute it's first instruction. At this
1735 point, this function gets called via expansion of the macro
1736 SOLIB_CREATE_INFERIOR_HOOK.
1737
1738 For SunOS executables, this first instruction is typically the
1739 one at "_start", or a similar text label, regardless of whether
1740 the executable is statically or dynamically linked. The runtime
1741 startup code takes care of dynamically linking in any shared
1742 libraries, once gdb allows the inferior to continue.
1743
1744 For SVR4 executables, this first instruction is either the first
1745 instruction in the dynamic linker (for dynamically linked
1746 executables) or the instruction at "start" for statically linked
1747 executables. For dynamically linked executables, the system
1748 first exec's /lib/libc.so.N, which contains the dynamic linker,
1749 and starts it running. The dynamic linker maps in any needed
1750 shared libraries, maps in the actual user executable, and then
1751 jumps to "start" in the user executable.
1752
1753 For both SunOS shared libraries, and SVR4 shared libraries, we
1754 can arrange to cooperate with the dynamic linker to discover the
1755 names of shared libraries that are dynamically linked, and the
1756 base addresses to which they are linked.
1757
1758 This function is responsible for discovering those names and
1759 addresses, and saving sufficient information about them to allow
1760 their symbols to be read at a later time.
1761
1762 FIXME
1763
1764 Between enable_break() and disable_break(), this code does not
1765 properly handle hitting breakpoints which the user might have
1766 set in the startup code or in the dynamic linker itself. Proper
1767 handling will probably have to wait until the implementation is
1768 changed to use the "breakpoint handler function" method.
1769
1770 Also, what if child has exit()ed? Must exit loop somehow.
1771 */
1772
1773 static void
1774 svr4_solib_create_inferior_hook (int from_tty)
1775 {
1776 struct inferior *inf;
1777 struct thread_info *tp;
1778 struct svr4_info *info;
1779
1780 info = get_svr4_info ();
1781
1782 /* Relocate the main executable if necessary. */
1783 if (current_inferior ()->attach_flag == 0)
1784 svr4_relocate_main_executable ();
1785
1786 if (!svr4_have_link_map_offsets ())
1787 return;
1788
1789 if (!enable_break (info, from_tty))
1790 return;
1791
1792 #if defined(_SCO_DS)
1793 /* SCO needs the loop below, other systems should be using the
1794 special shared library breakpoints and the shared library breakpoint
1795 service routine.
1796
1797 Now run the target. It will eventually hit the breakpoint, at
1798 which point all of the libraries will have been mapped in and we
1799 can go groveling around in the dynamic linker structures to find
1800 out what we need to know about them. */
1801
1802 inf = current_inferior ();
1803 tp = inferior_thread ();
1804
1805 clear_proceed_status ();
1806 inf->stop_soon = STOP_QUIETLY;
1807 tp->stop_signal = TARGET_SIGNAL_0;
1808 do
1809 {
1810 target_resume (pid_to_ptid (-1), 0, tp->stop_signal);
1811 wait_for_inferior (0);
1812 }
1813 while (tp->stop_signal != TARGET_SIGNAL_TRAP);
1814 inf->stop_soon = NO_STOP_QUIETLY;
1815 #endif /* defined(_SCO_DS) */
1816 }
1817
1818 static void
1819 svr4_clear_solib (void)
1820 {
1821 struct svr4_info *info;
1822
1823 info = get_svr4_info ();
1824 info->debug_base = 0;
1825 info->debug_loader_offset_p = 0;
1826 info->debug_loader_offset = 0;
1827 xfree (info->debug_loader_name);
1828 info->debug_loader_name = NULL;
1829 }
1830
1831 static void
1832 svr4_free_so (struct so_list *so)
1833 {
1834 xfree (so->lm_info->lm);
1835 xfree (so->lm_info);
1836 }
1837
1838
1839 /* Clear any bits of ADDR that wouldn't fit in a target-format
1840 data pointer. "Data pointer" here refers to whatever sort of
1841 address the dynamic linker uses to manage its sections. At the
1842 moment, we don't support shared libraries on any processors where
1843 code and data pointers are different sizes.
1844
1845 This isn't really the right solution. What we really need here is
1846 a way to do arithmetic on CORE_ADDR values that respects the
1847 natural pointer/address correspondence. (For example, on the MIPS,
1848 converting a 32-bit pointer to a 64-bit CORE_ADDR requires you to
1849 sign-extend the value. There, simply truncating the bits above
1850 gdbarch_ptr_bit, as we do below, is no good.) This should probably
1851 be a new gdbarch method or something. */
1852 static CORE_ADDR
1853 svr4_truncate_ptr (CORE_ADDR addr)
1854 {
1855 if (gdbarch_ptr_bit (target_gdbarch) == sizeof (CORE_ADDR) * 8)
1856 /* We don't need to truncate anything, and the bit twiddling below
1857 will fail due to overflow problems. */
1858 return addr;
1859 else
1860 return addr & (((CORE_ADDR) 1 << gdbarch_ptr_bit (target_gdbarch)) - 1);
1861 }
1862
1863
1864 static void
1865 svr4_relocate_section_addresses (struct so_list *so,
1866 struct target_section *sec)
1867 {
1868 sec->addr = svr4_truncate_ptr (sec->addr + LM_ADDR_CHECK (so,
1869 sec->bfd));
1870 sec->endaddr = svr4_truncate_ptr (sec->endaddr + LM_ADDR_CHECK (so,
1871 sec->bfd));
1872 }
1873 \f
1874
1875 /* Architecture-specific operations. */
1876
1877 /* Per-architecture data key. */
1878 static struct gdbarch_data *solib_svr4_data;
1879
1880 struct solib_svr4_ops
1881 {
1882 /* Return a description of the layout of `struct link_map'. */
1883 struct link_map_offsets *(*fetch_link_map_offsets)(void);
1884 };
1885
1886 /* Return a default for the architecture-specific operations. */
1887
1888 static void *
1889 solib_svr4_init (struct obstack *obstack)
1890 {
1891 struct solib_svr4_ops *ops;
1892
1893 ops = OBSTACK_ZALLOC (obstack, struct solib_svr4_ops);
1894 ops->fetch_link_map_offsets = NULL;
1895 return ops;
1896 }
1897
1898 /* Set the architecture-specific `struct link_map_offsets' fetcher for
1899 GDBARCH to FLMO. Also, install SVR4 solib_ops into GDBARCH. */
1900
1901 void
1902 set_solib_svr4_fetch_link_map_offsets (struct gdbarch *gdbarch,
1903 struct link_map_offsets *(*flmo) (void))
1904 {
1905 struct solib_svr4_ops *ops = gdbarch_data (gdbarch, solib_svr4_data);
1906
1907 ops->fetch_link_map_offsets = flmo;
1908
1909 set_solib_ops (gdbarch, &svr4_so_ops);
1910 }
1911
1912 /* Fetch a link_map_offsets structure using the architecture-specific
1913 `struct link_map_offsets' fetcher. */
1914
1915 static struct link_map_offsets *
1916 svr4_fetch_link_map_offsets (void)
1917 {
1918 struct solib_svr4_ops *ops = gdbarch_data (target_gdbarch, solib_svr4_data);
1919
1920 gdb_assert (ops->fetch_link_map_offsets);
1921 return ops->fetch_link_map_offsets ();
1922 }
1923
1924 /* Return 1 if a link map offset fetcher has been defined, 0 otherwise. */
1925
1926 static int
1927 svr4_have_link_map_offsets (void)
1928 {
1929 struct solib_svr4_ops *ops = gdbarch_data (target_gdbarch, solib_svr4_data);
1930 return (ops->fetch_link_map_offsets != NULL);
1931 }
1932 \f
1933
1934 /* Most OS'es that have SVR4-style ELF dynamic libraries define a
1935 `struct r_debug' and a `struct link_map' that are binary compatible
1936 with the origional SVR4 implementation. */
1937
1938 /* Fetch (and possibly build) an appropriate `struct link_map_offsets'
1939 for an ILP32 SVR4 system. */
1940
1941 struct link_map_offsets *
1942 svr4_ilp32_fetch_link_map_offsets (void)
1943 {
1944 static struct link_map_offsets lmo;
1945 static struct link_map_offsets *lmp = NULL;
1946
1947 if (lmp == NULL)
1948 {
1949 lmp = &lmo;
1950
1951 lmo.r_version_offset = 0;
1952 lmo.r_version_size = 4;
1953 lmo.r_map_offset = 4;
1954 lmo.r_brk_offset = 8;
1955 lmo.r_ldsomap_offset = 20;
1956
1957 /* Everything we need is in the first 20 bytes. */
1958 lmo.link_map_size = 20;
1959 lmo.l_addr_offset = 0;
1960 lmo.l_name_offset = 4;
1961 lmo.l_ld_offset = 8;
1962 lmo.l_next_offset = 12;
1963 lmo.l_prev_offset = 16;
1964 }
1965
1966 return lmp;
1967 }
1968
1969 /* Fetch (and possibly build) an appropriate `struct link_map_offsets'
1970 for an LP64 SVR4 system. */
1971
1972 struct link_map_offsets *
1973 svr4_lp64_fetch_link_map_offsets (void)
1974 {
1975 static struct link_map_offsets lmo;
1976 static struct link_map_offsets *lmp = NULL;
1977
1978 if (lmp == NULL)
1979 {
1980 lmp = &lmo;
1981
1982 lmo.r_version_offset = 0;
1983 lmo.r_version_size = 4;
1984 lmo.r_map_offset = 8;
1985 lmo.r_brk_offset = 16;
1986 lmo.r_ldsomap_offset = 40;
1987
1988 /* Everything we need is in the first 40 bytes. */
1989 lmo.link_map_size = 40;
1990 lmo.l_addr_offset = 0;
1991 lmo.l_name_offset = 8;
1992 lmo.l_ld_offset = 16;
1993 lmo.l_next_offset = 24;
1994 lmo.l_prev_offset = 32;
1995 }
1996
1997 return lmp;
1998 }
1999 \f
2000
2001 struct target_so_ops svr4_so_ops;
2002
2003 /* Lookup global symbol for ELF DSOs linked with -Bsymbolic. Those DSOs have a
2004 different rule for symbol lookup. The lookup begins here in the DSO, not in
2005 the main executable. */
2006
2007 static struct symbol *
2008 elf_lookup_lib_symbol (const struct objfile *objfile,
2009 const char *name,
2010 const char *linkage_name,
2011 const domain_enum domain)
2012 {
2013 bfd *abfd;
2014
2015 if (objfile == symfile_objfile)
2016 abfd = exec_bfd;
2017 else
2018 {
2019 /* OBJFILE should have been passed as the non-debug one. */
2020 gdb_assert (objfile->separate_debug_objfile_backlink == NULL);
2021
2022 abfd = objfile->obfd;
2023 }
2024
2025 if (abfd == NULL || scan_dyntag (DT_SYMBOLIC, abfd, NULL) != 1)
2026 return NULL;
2027
2028 return lookup_global_symbol_from_objfile
2029 (objfile, name, linkage_name, domain);
2030 }
2031
2032 extern initialize_file_ftype _initialize_svr4_solib; /* -Wmissing-prototypes */
2033
2034 void
2035 _initialize_svr4_solib (void)
2036 {
2037 solib_svr4_data = gdbarch_data_register_pre_init (solib_svr4_init);
2038 solib_svr4_pspace_data
2039 = register_program_space_data_with_cleanup (svr4_pspace_data_cleanup);
2040
2041 svr4_so_ops.relocate_section_addresses = svr4_relocate_section_addresses;
2042 svr4_so_ops.free_so = svr4_free_so;
2043 svr4_so_ops.clear_solib = svr4_clear_solib;
2044 svr4_so_ops.solib_create_inferior_hook = svr4_solib_create_inferior_hook;
2045 svr4_so_ops.special_symbol_handling = svr4_special_symbol_handling;
2046 svr4_so_ops.current_sos = svr4_current_sos;
2047 svr4_so_ops.open_symbol_file_object = open_symbol_file_object;
2048 svr4_so_ops.in_dynsym_resolve_code = svr4_in_dynsym_resolve_code;
2049 svr4_so_ops.bfd_open = solib_bfd_open;
2050 svr4_so_ops.lookup_lib_global_symbol = elf_lookup_lib_symbol;
2051 svr4_so_ops.same = svr4_same;
2052 svr4_so_ops.keep_data_in_core = svr4_keep_data_in_core;
2053 }
This page took 0.078283 seconds and 4 git commands to generate.