Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(371)

Side by Side Diff: gdb/elfread.c

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gdb/dwarf2read.c ('k') | gdb/eval.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
None
OLDNEW
1 /* Read ELF (Executable and Linking Format) object files for GDB. 1 /* Read ELF (Executable and Linking Format) object files for GDB.
2 2
3 Copyright (C) 1991-2012 Free Software Foundation, Inc. 3 Copyright (C) 1991-2012 Free Software Foundation, Inc.
4 4
5 Written by Fred Fish at Cygnus Support. 5 Written by Fred Fish at Cygnus Support.
6 6
7 This file is part of GDB. 7 This file is part of GDB.
8 8
9 This program is free software; you can redistribute it and/or modify 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 10 it under the terms of the GNU General Public License as published by
(...skipping 18 matching lines...) Expand all
29 #include "symtab.h" 29 #include "symtab.h"
30 #include "symfile.h" 30 #include "symfile.h"
31 #include "objfiles.h" 31 #include "objfiles.h"
32 #include "buildsym.h" 32 #include "buildsym.h"
33 #include "stabsread.h" 33 #include "stabsread.h"
34 #include "gdb-stabs.h" 34 #include "gdb-stabs.h"
35 #include "complaints.h" 35 #include "complaints.h"
36 #include "demangle.h" 36 #include "demangle.h"
37 #include "psympriv.h" 37 #include "psympriv.h"
38 #include "filenames.h" 38 #include "filenames.h"
39 #include "probe.h"
40 #include "arch-utils.h"
39 #include "gdbtypes.h" 41 #include "gdbtypes.h"
40 #include "value.h" 42 #include "value.h"
41 #include "infcall.h" 43 #include "infcall.h"
42 #include "gdbthread.h" 44 #include "gdbthread.h"
43 #include "regcache.h" 45 #include "regcache.h"
46 #include "bcache.h"
44 47
45 extern void _initialize_elfread (void); 48 extern void _initialize_elfread (void);
46 49
47 /* Forward declarations. */ 50 /* Forward declarations. */
48 static const struct sym_fns elf_sym_fns_gdb_index; 51 static const struct sym_fns elf_sym_fns_gdb_index;
49 static const struct sym_fns elf_sym_fns_lazy_psyms; 52 static const struct sym_fns elf_sym_fns_lazy_psyms;
50 53
51 /* The struct elfinfo is available only during ELF symbol table and 54 /* The struct elfinfo is available only during ELF symbol table and
52 psymtab reading. It is destroyed at the completion of psymtab-reading. 55 psymtab reading. It is destroyed at the completion of psymtab-reading.
53 It's local to elf_symfile_read. */ 56 It's local to elf_symfile_read. */
54 57
55 struct elfinfo 58 struct elfinfo
56 { 59 {
57 asection *stabsect; /* Section pointer for .stab section */ 60 asection *stabsect; /* Section pointer for .stab section */
58 asection *stabindexsect; /* Section pointer for .stab.index section */ 61 asection *stabindexsect; /* Section pointer for .stab.index section */
59 asection *mdebugsect; /* Section pointer for .mdebug section */ 62 asection *mdebugsect; /* Section pointer for .mdebug section */
60 }; 63 };
61 64
65 /* Per-objfile data for probe info. */
66
67 static const struct objfile_data *probe_key = NULL;
68
62 static void free_elfinfo (void *); 69 static void free_elfinfo (void *);
63 70
64 /* Minimal symbols located at the GOT entries for .plt - that is the real 71 /* Minimal symbols located at the GOT entries for .plt - that is the real
65 pointer where the given entry will jump to. It gets updated by the real 72 pointer where the given entry will jump to. It gets updated by the real
66 function address during lazy ld.so resolving in the inferior. These 73 function address during lazy ld.so resolving in the inferior. These
67 minimal symbols are indexed for <tab>-completion. */ 74 minimal symbols are indexed for <tab>-completion. */
68 75
69 #define SYMBOL_GOT_PLT_SUFFIX "@got.plt" 76 #define SYMBOL_GOT_PLT_SUFFIX "@got.plt"
70 77
71 /* Locate the segments in ABFD. */ 78 /* Locate the segments in ABFD. */
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 If we haven't, we will not relocate this section by any 141 If we haven't, we will not relocate this section by any
135 offsets we apply to the segments. As an exception, do not 142 offsets we apply to the segments. As an exception, do not
136 warn about SHT_NOBITS sections; in normal ELF execution 143 warn about SHT_NOBITS sections; in normal ELF execution
137 environments, SHT_NOBITS means zero-initialized and belongs 144 environments, SHT_NOBITS means zero-initialized and belongs
138 in a segment, but in no-OS environments some tools (e.g. ARM 145 in a segment, but in no-OS environments some tools (e.g. ARM
139 RealView) use SHT_NOBITS for uninitialized data. Since it is 146 RealView) use SHT_NOBITS for uninitialized data. Since it is
140 uninitialized, it doesn't need a program header. Such 147 uninitialized, it doesn't need a program header. Such
141 binaries are not relocatable. */ 148 binaries are not relocatable. */
142 if (bfd_get_section_size (sect) > 0 && j == num_segments 149 if (bfd_get_section_size (sect) > 0 && j == num_segments
143 && (bfd_get_section_flags (abfd, sect) & SEC_LOAD) != 0) 150 && (bfd_get_section_flags (abfd, sect) & SEC_LOAD) != 0)
144 » warning (_("Loadable segment \"%s\" outside of ELF segments"), 151 » warning (_("Loadable section \"%s\" outside of ELF segments"),
145 bfd_section_name (abfd, sect)); 152 bfd_section_name (abfd, sect));
146 } 153 }
147 154
148 return data; 155 return data;
149 } 156 }
150 157
151 /* We are called once per section from elf_symfile_read. We 158 /* We are called once per section from elf_symfile_read. We
152 need to examine each section we are passed, check to see 159 need to examine each section we are passed, check to see
153 if it is something we are interested in processing, and 160 if it is something we are interested in processing, and
154 if so, stash away some access information for the section. 161 if so, stash away some access information for the section.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 CORE_ADDR symaddr; 238 CORE_ADDR symaddr;
232 CORE_ADDR offset; 239 CORE_ADDR offset;
233 enum minimal_symbol_type ms_type; 240 enum minimal_symbol_type ms_type;
234 /* If sectinfo is nonNULL, it contains section info that should end up 241 /* If sectinfo is nonNULL, it contains section info that should end up
235 filed in the objfile. */ 242 filed in the objfile. */
236 struct stab_section_info *sectinfo = NULL; 243 struct stab_section_info *sectinfo = NULL;
237 /* If filesym is nonzero, it points to a file symbol, but we haven't 244 /* If filesym is nonzero, it points to a file symbol, but we haven't
238 seen any section info for it yet. */ 245 seen any section info for it yet. */
239 asymbol *filesym = 0; 246 asymbol *filesym = 0;
240 /* Name of filesym. This is either a constant string or is saved on 247 /* Name of filesym. This is either a constant string or is saved on
241 the objfile's obstack. */ 248 the objfile's filename cache. */
242 char *filesymname = ""; 249 const char *filesymname = "";
243 struct dbx_symfile_info *dbx = objfile->deprecated_sym_stab_info; 250 struct dbx_symfile_info *dbx = objfile->deprecated_sym_stab_info;
244 int stripped = (bfd_get_symcount (objfile->obfd) == 0); 251 int stripped = (bfd_get_symcount (objfile->obfd) == 0);
245 252
246 for (i = 0; i < number_of_symbols; i++) 253 for (i = 0; i < number_of_symbols; i++)
247 { 254 {
248 sym = symbol_table[i]; 255 sym = symbol_table[i];
249 if (sym->name == NULL || *sym->name == '\0') 256 if (sym->name == NULL || *sym->name == '\0')
250 { 257 {
251 /* Skip names that don't exist (shouldn't happen), or names 258 /* Skip names that don't exist (shouldn't happen), or names
252 that are null strings (may happen). */ 259 that are null strings (may happen). */
253 continue; 260 continue;
254 } 261 }
255 262
256 /* Skip "special" symbols, e.g. ARM mapping symbols. These are 263 /* Skip "special" symbols, e.g. ARM mapping symbols. These are
257 symbols which do not correspond to objects in the symbol table, 264 symbols which do not correspond to objects in the symbol table,
258 but have some other target-specific meaning. */ 265 but have some other target-specific meaning. */
259 if (bfd_is_target_special_symbol (objfile->obfd, sym)) 266 if (bfd_is_target_special_symbol (objfile->obfd, sym))
260 { 267 {
261 if (gdbarch_record_special_symbol_p (gdbarch)) 268 if (gdbarch_record_special_symbol_p (gdbarch))
262 gdbarch_record_special_symbol (gdbarch, objfile, sym); 269 gdbarch_record_special_symbol (gdbarch, objfile, sym);
263 continue; 270 continue;
264 } 271 }
265 272
266 offset = ANOFFSET (objfile->section_offsets, sym->section->index); 273 offset = ANOFFSET (objfile->section_offsets, sym->section->index);
267 if (type == ST_DYNAMIC 274 if (type == ST_DYNAMIC
268 » && sym->section == &bfd_und_section 275 » && sym->section == bfd_und_section_ptr
269 && (sym->flags & BSF_FUNCTION)) 276 && (sym->flags & BSF_FUNCTION))
270 { 277 {
271 struct minimal_symbol *msym; 278 struct minimal_symbol *msym;
272 bfd *abfd = objfile->obfd; 279 bfd *abfd = objfile->obfd;
273 asection *sect; 280 asection *sect;
274 281
275 /* Symbol is a reference to a function defined in 282 /* Symbol is a reference to a function defined in
276 a shared library. 283 a shared library.
277 If its value is non zero then it is usually the address 284 If its value is non zero then it is usually the address
278 of the corresponding entry in the procedure linkage table, 285 of the corresponding entry in the procedure linkage table,
(...skipping 15 matching lines...) Expand all
294 continue; 301 continue;
295 302
296 if (symaddr >= bfd_get_section_vma (abfd, sect) 303 if (symaddr >= bfd_get_section_vma (abfd, sect)
297 && symaddr < bfd_get_section_vma (abfd, sect) 304 && symaddr < bfd_get_section_vma (abfd, sect)
298 + bfd_get_section_size (sect)) 305 + bfd_get_section_size (sect))
299 break; 306 break;
300 } 307 }
301 if (!sect) 308 if (!sect)
302 continue; 309 continue;
303 310
311 /* On ia64-hpux, we have discovered that the system linker
312 adds undefined symbols with nonzero addresses that cannot
313 be right (their address points inside the code of another
314 function in the .text section). This creates problems
315 when trying to determine which symbol corresponds to
316 a given address.
317
318 We try to detect those buggy symbols by checking which
319 section we think they correspond to. Normally, PLT symbols
320 are stored inside their own section, and the typical name
321 for that section is ".plt". So, if there is a ".plt"
322 section, and yet the section name of our symbol does not
323 start with ".plt", we ignore that symbol. */
324 if (strncmp (sect->name, ".plt", 4) != 0
325 && bfd_get_section_by_name (abfd, ".plt") != NULL)
326 continue;
327
304 symaddr += ANOFFSET (objfile->section_offsets, sect->index); 328 symaddr += ANOFFSET (objfile->section_offsets, sect->index);
305 329
306 msym = record_minimal_symbol 330 msym = record_minimal_symbol
307 (sym->name, strlen (sym->name), copy_names, 331 (sym->name, strlen (sym->name), copy_names,
308 symaddr, mst_solib_trampoline, sect, objfile); 332 symaddr, mst_solib_trampoline, sect, objfile);
309 if (msym != NULL) 333 if (msym != NULL)
310 msym->filename = filesymname; 334 msym->filename = filesymname;
311 continue; 335 continue;
312 } 336 }
313 337
314 /* If it is a nonstripped executable, do not enter dynamic 338 /* If it is a nonstripped executable, do not enter dynamic
315 symbols, as the dynamic symbol table is usually a subset 339 symbols, as the dynamic symbol table is usually a subset
316 of the main symbol table. */ 340 of the main symbol table. */
317 if (type == ST_DYNAMIC && !stripped) 341 if (type == ST_DYNAMIC && !stripped)
318 continue; 342 continue;
319 if (sym->flags & BSF_FILE) 343 if (sym->flags & BSF_FILE)
320 { 344 {
321 /* STT_FILE debugging symbol that helps stabs-in-elf debugging. 345 /* STT_FILE debugging symbol that helps stabs-in-elf debugging.
322 Chain any old one onto the objfile; remember new sym. */ 346 Chain any old one onto the objfile; remember new sym. */
323 if (sectinfo != NULL) 347 if (sectinfo != NULL)
324 { 348 {
325 sectinfo->next = dbx->stab_section_info; 349 sectinfo->next = dbx->stab_section_info;
326 dbx->stab_section_info = sectinfo; 350 dbx->stab_section_info = sectinfo;
327 sectinfo = NULL; 351 sectinfo = NULL;
328 } 352 }
329 filesym = sym; 353 filesym = sym;
330 » filesymname = 354 » filesymname = bcache (filesym->name, strlen (filesym->name) + 1,
331 » obsavestring ((char *) filesym->name, strlen (filesym->name), 355 » » » » objfile->filename_cache);
332 » » » &objfile->objfile_obstack);
333 } 356 }
334 else if (sym->flags & BSF_SECTION_SYM) 357 else if (sym->flags & BSF_SECTION_SYM)
335 continue; 358 continue;
336 else if (sym->flags & (BSF_GLOBAL | BSF_LOCAL | BSF_WEAK)) 359 else if (sym->flags & (BSF_GLOBAL | BSF_LOCAL | BSF_WEAK))
337 { 360 {
338 struct minimal_symbol *msym; 361 struct minimal_symbol *msym;
339 362
340 /* Select global/local/weak symbols. Note that bfd puts abs 363 /* Select global/local/weak symbols. Note that bfd puts abs
341 symbols in their own section, so all symbols we are 364 symbols in their own section, so all symbols we are
342 interested in will have a section. */ 365 interested in will have a section. */
343 /* Bfd symbols are section relative. */ 366 /* Bfd symbols are section relative. */
344 symaddr = sym->value + sym->section->vma; 367 symaddr = sym->value + sym->section->vma;
345 /* Relocate all non-absolute and non-TLS symbols by the 368 /* Relocate all non-absolute and non-TLS symbols by the
346 section offset. */ 369 section offset. */
347 » if (sym->section != &bfd_abs_section 370 » if (sym->section != bfd_abs_section_ptr
348 && !(sym->section->flags & SEC_THREAD_LOCAL)) 371 && !(sym->section->flags & SEC_THREAD_LOCAL))
349 { 372 {
350 symaddr += offset; 373 symaddr += offset;
351 } 374 }
352 /* For non-absolute symbols, use the type of the section 375 /* For non-absolute symbols, use the type of the section
353 they are relative to, to intuit text/data. Bfd provides 376 they are relative to, to intuit text/data. Bfd provides
354 no way of figuring this out for absolute symbols. */ 377 no way of figuring this out for absolute symbols. */
355 » if (sym->section == &bfd_abs_section) 378 » if (sym->section == bfd_abs_section_ptr)
356 { 379 {
357 /* This is a hack to get the minimal symbol type 380 /* This is a hack to get the minimal symbol type
358 right for Irix 5, which has absolute addresses 381 right for Irix 5, which has absolute addresses
359 with special section indices for dynamic symbols. 382 with special section indices for dynamic symbols.
360 383
361 NOTE: uweigand-20071112: Synthetic symbols do not 384 NOTE: uweigand-20071112: Synthetic symbols do not
362 have an ELF-private part, so do not touch those. */ 385 have an ELF-private part, so do not touch those. */
363 unsigned int shndx = type == ST_SYNTHETIC ? 0 : 386 unsigned int shndx = type == ST_SYNTHETIC ? 0 :
364 ((elf_symbol_type *) sym)->internal_elf_sym.st_shndx; 387 ((elf_symbol_type *) sym)->internal_elf_sym.st_shndx;
365 388
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 } 510 }
488 if (sectinfo->sections[special_local_sect] != 0) 511 if (sectinfo->sections[special_local_sect] != 0)
489 complaint (&symfile_complaints, 512 complaint (&symfile_complaints,
490 _("duplicated elf/stab section " 513 _("duplicated elf/stab section "
491 "information for %s"), 514 "information for %s"),
492 sectinfo->filename); 515 sectinfo->filename);
493 /* BFD symbols are section relative. */ 516 /* BFD symbols are section relative. */
494 symaddr = sym->value + sym->section->vma; 517 symaddr = sym->value + sym->section->vma;
495 /* Relocate non-absolute symbols by the 518 /* Relocate non-absolute symbols by the
496 section offset. */ 519 section offset. */
497 » » if (sym->section != &bfd_abs_section) 520 » » if (sym->section != bfd_abs_section_ptr)
498 symaddr += offset; 521 symaddr += offset;
499 sectinfo->sections[special_local_sect] = symaddr; 522 sectinfo->sections[special_local_sect] = symaddr;
500 /* The special local symbols don't go in the 523 /* The special local symbols don't go in the
501 minimal symbol table, so ignore this one. */ 524 minimal symbol table, so ignore this one. */
502 continue; 525 continue;
503 } 526 }
504 /* Not a special stabs-in-elf symbol, do regular 527 /* Not a special stabs-in-elf symbol, do regular
505 symbol processing. */ 528 symbol processing. */
506 if (sym->section->flags & SEC_LOAD) 529 if (sym->section->flags & SEC_LOAD)
507 { 530 {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 { 587 {
565 struct minimal_symbol *mtramp; 588 struct minimal_symbol *mtramp;
566 589
567 mtramp = record_minimal_symbol (sym->name, len - 4, 1, 590 mtramp = record_minimal_symbol (sym->name, len - 4, 1,
568 symaddr, 591 symaddr,
569 mst_solib_trampoline, 592 mst_solib_trampoline,
570 sym->section, objfile); 593 sym->section, objfile);
571 if (mtramp) 594 if (mtramp)
572 { 595 {
573 MSYMBOL_SIZE (mtramp) = MSYMBOL_SIZE (msym); 596 MSYMBOL_SIZE (mtramp) = MSYMBOL_SIZE (msym);
597 mtramp->created_by_gdb = 1;
574 mtramp->filename = filesymname; 598 mtramp->filename = filesymname;
575 gdbarch_elf_make_msymbol_special (gdbarch, sym, mtramp); 599 gdbarch_elf_make_msymbol_special (gdbarch, sym, mtramp);
576 } 600 }
577 } 601 }
578 } 602 }
579 } 603 }
580 } 604 }
581 } 605 }
582 606
583 /* Build minimal symbols named `function@got.plt' (see SYMBOL_GOT_PLT_SUFFIX) 607 /* Build minimal symbols named `function@got.plt' (see SYMBOL_GOT_PLT_SUFFIX)
584 for later look ups of which function to call when user requests 608 for later look ups of which function to call when user requests
585 a STT_GNU_IFUNC function. As the STT_GNU_IFUNC type is found at the target 609 a STT_GNU_IFUNC function. As the STT_GNU_IFUNC type is found at the target
586 library defining `function' we cannot yet know while reading OBJFILE which 610 library defining `function' we cannot yet know while reading OBJFILE which
587 of the SYMBOL_GOT_PLT_SUFFIX entries will be needed and later 611 of the SYMBOL_GOT_PLT_SUFFIX entries will be needed and later
588 DYN_SYMBOL_TABLE is no longer easily available for OBJFILE. */ 612 DYN_SYMBOL_TABLE is no longer easily available for OBJFILE. */
589 613
590 static void 614 static void
591 elf_rel_plt_read (struct objfile *objfile, asymbol **dyn_symbol_table) 615 elf_rel_plt_read (struct objfile *objfile, asymbol **dyn_symbol_table)
592 { 616 {
593 bfd *obfd = objfile->obfd; 617 bfd *obfd = objfile->obfd;
594 const struct elf_backend_data *bed = get_elf_backend_data (obfd); 618 const struct elf_backend_data *bed = get_elf_backend_data (obfd);
595 asection *plt, *relplt, *got_plt; 619 asection *plt, *relplt, *got_plt;
596 unsigned u;
597 int plt_elf_idx; 620 int plt_elf_idx;
598 bfd_size_type reloc_count, reloc; 621 bfd_size_type reloc_count, reloc;
599 char *string_buffer = NULL; 622 char *string_buffer = NULL;
600 size_t string_buffer_size = 0; 623 size_t string_buffer_size = 0;
601 struct cleanup *back_to; 624 struct cleanup *back_to;
602 struct gdbarch *gdbarch = objfile->gdbarch; 625 struct gdbarch *gdbarch = objfile->gdbarch;
603 struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr; 626 struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
604 size_t ptr_size = TYPE_LENGTH (ptr_type); 627 size_t ptr_size = TYPE_LENGTH (ptr_type);
605 628
606 if (objfile->separate_debug_objfile_backlink) 629 if (objfile->separate_debug_objfile_backlink)
(...skipping 18 matching lines...) Expand all
625 return; 648 return;
626 649
627 if (! bed->s->slurp_reloc_table (obfd, relplt, dyn_symbol_table, TRUE)) 650 if (! bed->s->slurp_reloc_table (obfd, relplt, dyn_symbol_table, TRUE))
628 return; 651 return;
629 652
630 back_to = make_cleanup (free_current_contents, &string_buffer); 653 back_to = make_cleanup (free_current_contents, &string_buffer);
631 654
632 reloc_count = relplt->size / elf_section_data (relplt)->this_hdr.sh_entsize; 655 reloc_count = relplt->size / elf_section_data (relplt)->this_hdr.sh_entsize;
633 for (reloc = 0; reloc < reloc_count; reloc++) 656 for (reloc = 0; reloc < reloc_count; reloc++)
634 { 657 {
635 const char *name, *name_got_plt; 658 const char *name;
636 struct minimal_symbol *msym; 659 struct minimal_symbol *msym;
637 CORE_ADDR address; 660 CORE_ADDR address;
638 const size_t got_suffix_len = strlen (SYMBOL_GOT_PLT_SUFFIX); 661 const size_t got_suffix_len = strlen (SYMBOL_GOT_PLT_SUFFIX);
639 size_t name_len; 662 size_t name_len;
640 663
641 name = bfd_asymbol_name (*relplt->relocation[reloc].sym_ptr_ptr); 664 name = bfd_asymbol_name (*relplt->relocation[reloc].sym_ptr_ptr);
642 name_len = strlen (name); 665 name_len = strlen (name);
643 address = relplt->relocation[reloc].address; 666 address = relplt->relocation[reloc].address;
644 667
645 /* Does the pointer reside in the .got.plt section? */ 668 /* Does the pointer reside in the .got.plt section? */
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 } 919 }
897 920
898 /* Call STT_GNU_IFUNC - a function returning addresss of a real function to 921 /* Call STT_GNU_IFUNC - a function returning addresss of a real function to
899 call. PC is theSTT_GNU_IFUNC resolving function entry. The value returned 922 call. PC is theSTT_GNU_IFUNC resolving function entry. The value returned
900 is the entry point of the resolved STT_GNU_IFUNC target function to call. 923 is the entry point of the resolved STT_GNU_IFUNC target function to call.
901 */ 924 */
902 925
903 static CORE_ADDR 926 static CORE_ADDR
904 elf_gnu_ifunc_resolve_addr (struct gdbarch *gdbarch, CORE_ADDR pc) 927 elf_gnu_ifunc_resolve_addr (struct gdbarch *gdbarch, CORE_ADDR pc)
905 { 928 {
906 char *name_at_pc; 929 const char *name_at_pc;
907 CORE_ADDR start_at_pc, address; 930 CORE_ADDR start_at_pc, address;
908 struct type *func_func_type = builtin_type (gdbarch)->builtin_func_func; 931 struct type *func_func_type = builtin_type (gdbarch)->builtin_func_func;
909 struct value *function, *address_val; 932 struct value *function, *address_val;
910 933
911 /* Try first any non-intrusive methods without an inferior call. */ 934 /* Try first any non-intrusive methods without an inferior call. */
912 935
913 if (find_pc_partial_function (pc, &name_at_pc, &start_at_pc, NULL) 936 if (find_pc_partial_function (pc, &name_at_pc, &start_at_pc, NULL)
914 && start_at_pc == pc) 937 && start_at_pc == pc)
915 { 938 {
916 if (elf_gnu_ifunc_resolve_name (name_at_pc, &address)) 939 if (elf_gnu_ifunc_resolve_name (name_at_pc, &address))
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 994
972 init_sal (&sal); 995 init_sal (&sal);
973 sal.pspace = current_inferior ()->pspace; 996 sal.pspace = current_inferior ()->pspace;
974 sal.pc = prev_pc; 997 sal.pc = prev_pc;
975 sal.section = find_pc_overlay (sal.pc); 998 sal.section = find_pc_overlay (sal.pc);
976 sal.explicit_pc = 1; 999 sal.explicit_pc = 1;
977 b_return = set_momentary_breakpoint (get_frame_arch (prev_frame), sal, 1000 b_return = set_momentary_breakpoint (get_frame_arch (prev_frame), sal,
978 prev_frame_id, 1001 prev_frame_id,
979 bp_gnu_ifunc_resolver_return); 1002 bp_gnu_ifunc_resolver_return);
980 1003
1004 /* set_momentary_breakpoint invalidates PREV_FRAME. */
1005 prev_frame = NULL;
1006
981 /* Add new b_return to the ring list b->related_breakpoint. */ 1007 /* Add new b_return to the ring list b->related_breakpoint. */
982 gdb_assert (b_return->related_breakpoint == b_return); 1008 gdb_assert (b_return->related_breakpoint == b_return);
983 b_return->related_breakpoint = b->related_breakpoint; 1009 b_return->related_breakpoint = b->related_breakpoint;
984 b->related_breakpoint = b_return; 1010 b->related_breakpoint = b_return;
985 } 1011 }
986 } 1012 }
987 1013
988 /* Handle inferior hit of bp_gnu_ifunc_resolver_return, see its definition. */ 1014 /* Handle inferior hit of bp_gnu_ifunc_resolver_return, see its definition. */
989 1015
990 static void 1016 static void
991 elf_gnu_ifunc_resolver_return_stop (struct breakpoint *b) 1017 elf_gnu_ifunc_resolver_return_stop (struct breakpoint *b)
992 { 1018 {
993 struct gdbarch *gdbarch = get_frame_arch (get_current_frame ()); 1019 struct gdbarch *gdbarch = get_frame_arch (get_current_frame ());
994 struct type *func_func_type = builtin_type (gdbarch)->builtin_func_func; 1020 struct type *func_func_type = builtin_type (gdbarch)->builtin_func_func;
995 struct type *value_type = TYPE_TARGET_TYPE (func_func_type); 1021 struct type *value_type = TYPE_TARGET_TYPE (func_func_type);
996 struct regcache *regcache = get_thread_regcache (inferior_ptid); 1022 struct regcache *regcache = get_thread_regcache (inferior_ptid);
1023 struct value *func_func;
997 struct value *value; 1024 struct value *value;
998 CORE_ADDR resolved_address, resolved_pc; 1025 CORE_ADDR resolved_address, resolved_pc;
999 struct symtab_and_line sal; 1026 struct symtab_and_line sal;
1000 struct symtabs_and_lines sals, sals_end; 1027 struct symtabs_and_lines sals, sals_end;
1001 1028
1002 gdb_assert (b->type == bp_gnu_ifunc_resolver_return); 1029 gdb_assert (b->type == bp_gnu_ifunc_resolver_return);
1003 1030
1004 value = allocate_value (value_type);
1005 gdbarch_return_value (gdbarch, func_func_type, value_type, regcache,
1006 value_contents_raw (value), NULL);
1007 resolved_address = value_as_address (value);
1008 resolved_pc = gdbarch_convert_from_func_ptr_addr (gdbarch,
1009 resolved_address,
1010 &current_target);
1011
1012 while (b->related_breakpoint != b) 1031 while (b->related_breakpoint != b)
1013 { 1032 {
1014 struct breakpoint *b_next = b->related_breakpoint; 1033 struct breakpoint *b_next = b->related_breakpoint;
1015 1034
1016 switch (b->type) 1035 switch (b->type)
1017 { 1036 {
1018 case bp_gnu_ifunc_resolver: 1037 case bp_gnu_ifunc_resolver:
1019 break; 1038 break;
1020 case bp_gnu_ifunc_resolver_return: 1039 case bp_gnu_ifunc_resolver_return:
1021 delete_breakpoint (b); 1040 delete_breakpoint (b);
1022 break; 1041 break;
1023 default: 1042 default:
1024 internal_error (__FILE__, __LINE__, 1043 internal_error (__FILE__, __LINE__,
1025 _("handle_inferior_event: Invalid " 1044 _("handle_inferior_event: Invalid "
1026 "gnu-indirect-function breakpoint type %d"), 1045 "gnu-indirect-function breakpoint type %d"),
1027 (int) b->type); 1046 (int) b->type);
1028 } 1047 }
1029 b = b_next; 1048 b = b_next;
1030 } 1049 }
1031 gdb_assert (b->type == bp_gnu_ifunc_resolver); 1050 gdb_assert (b->type == bp_gnu_ifunc_resolver);
1051 gdb_assert (b->loc->next == NULL);
1052
1053 func_func = allocate_value (func_func_type);
1054 set_value_address (func_func, b->loc->related_address);
1055
1056 value = allocate_value (value_type);
1057 gdbarch_return_value (gdbarch, func_func, value_type, regcache,
1058 value_contents_raw (value), NULL);
1059 resolved_address = value_as_address (value);
1060 resolved_pc = gdbarch_convert_from_func_ptr_addr (gdbarch,
1061 resolved_address,
1062 &current_target);
1032 1063
1033 gdb_assert (current_program_space == b->pspace || b->pspace == NULL); 1064 gdb_assert (current_program_space == b->pspace || b->pspace == NULL);
1034 elf_gnu_ifunc_record_cache (b->addr_string, resolved_pc); 1065 elf_gnu_ifunc_record_cache (b->addr_string, resolved_pc);
1035 1066
1036 sal = find_pc_line (resolved_pc, 0); 1067 sal = find_pc_line (resolved_pc, 0);
1037 sals.nelts = 1; 1068 sals.nelts = 1;
1038 sals.sals = &sal; 1069 sals.sals = &sal;
1039 sals_end.nelts = 0; 1070 sals_end.nelts = 0;
1040 1071
1041 b->type = bp_breakpoint; 1072 b->type = bp_breakpoint;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 1127
1097 xfree (found); 1128 xfree (found);
1098 1129
1099 return retval; 1130 return retval;
1100 } 1131 }
1101 1132
1102 static char * 1133 static char *
1103 build_id_to_debug_filename (struct build_id *build_id) 1134 build_id_to_debug_filename (struct build_id *build_id)
1104 { 1135 {
1105 char *link, *debugdir, *retval = NULL; 1136 char *link, *debugdir, *retval = NULL;
1137 VEC (char_ptr) *debugdir_vec;
1138 struct cleanup *back_to;
1139 int ix;
1106 1140
1107 /* DEBUG_FILE_DIRECTORY/.build-id/ab/cdef */ 1141 /* DEBUG_FILE_DIRECTORY/.build-id/ab/cdef */
1108 link = alloca (strlen (debug_file_directory) + (sizeof "/.build-id/" - 1) + 1 1142 link = alloca (strlen (debug_file_directory) + (sizeof "/.build-id/" - 1) + 1
1109 + 2 * build_id->size + (sizeof ".debug" - 1) + 1); 1143 + 2 * build_id->size + (sizeof ".debug" - 1) + 1);
1110 1144
1111 /* Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will 1145 /* Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will
1112 cause "/.build-id/..." lookups. */ 1146 cause "/.build-id/..." lookups. */
1113 1147
1114 debugdir = debug_file_directory; 1148 debugdir_vec = dirnames_to_char_ptr_vec (debug_file_directory);
1115 do 1149 back_to = make_cleanup_free_char_ptr_vec (debugdir_vec);
1150
1151 for (ix = 0; VEC_iterate (char_ptr, debugdir_vec, ix, debugdir); ++ix)
1116 { 1152 {
1117 char *s, *debugdir_end; 1153 size_t debugdir_len = strlen (debugdir);
1118 gdb_byte *data = build_id->data; 1154 gdb_byte *data = build_id->data;
1119 size_t size = build_id->size; 1155 size_t size = build_id->size;
1156 char *s;
1120 1157
1121 while (*debugdir == DIRNAME_SEPARATOR) 1158 memcpy (link, debugdir, debugdir_len);
1122 » debugdir++; 1159 s = &link[debugdir_len];
1123
1124 debugdir_end = strchr (debugdir, DIRNAME_SEPARATOR);
1125 if (debugdir_end == NULL)
1126 » debugdir_end = &debugdir[strlen (debugdir)];
1127
1128 memcpy (link, debugdir, debugdir_end - debugdir);
1129 s = &link[debugdir_end - debugdir];
1130 s += sprintf (s, "/.build-id/"); 1160 s += sprintf (s, "/.build-id/");
1131 if (size > 0) 1161 if (size > 0)
1132 { 1162 {
1133 size--; 1163 size--;
1134 s += sprintf (s, "%02x", (unsigned) *data++); 1164 s += sprintf (s, "%02x", (unsigned) *data++);
1135 } 1165 }
1136 if (size > 0) 1166 if (size > 0)
1137 *s++ = '/'; 1167 *s++ = '/';
1138 while (size-- > 0) 1168 while (size-- > 0)
1139 s += sprintf (s, "%02x", (unsigned) *data++); 1169 s += sprintf (s, "%02x", (unsigned) *data++);
1140 strcpy (s, ".debug"); 1170 strcpy (s, ".debug");
1141 1171
1142 /* lrealpath() is expensive even for the usually non-existent files. */ 1172 /* lrealpath() is expensive even for the usually non-existent files. */
1143 if (access (link, F_OK) == 0) 1173 if (access (link, F_OK) == 0)
1144 retval = lrealpath (link); 1174 retval = lrealpath (link);
1145 1175
1146 if (retval != NULL && !build_id_verify (retval, build_id)) 1176 if (retval != NULL && !build_id_verify (retval, build_id))
1147 { 1177 {
1148 xfree (retval); 1178 xfree (retval);
1149 retval = NULL; 1179 retval = NULL;
1150 } 1180 }
1151 1181
1152 if (retval != NULL) 1182 if (retval != NULL)
1153 break; 1183 break;
1184 }
1154 1185
1155 debugdir = debugdir_end; 1186 do_cleanups (back_to);
1156 }
1157 while (*debugdir != 0);
1158
1159 return retval; 1187 return retval;
1160 } 1188 }
1161 1189
1162 static char * 1190 static char *
1163 find_separate_debug_file_by_buildid (struct objfile *objfile) 1191 find_separate_debug_file_by_buildid (struct objfile *objfile)
1164 { 1192 {
1165 struct build_id *build_id; 1193 struct build_id *build_id;
1166 1194
1167 build_id = build_id_bfd_get (objfile->obfd); 1195 build_id = build_id_bfd_get (objfile->obfd);
1168 if (build_id != NULL) 1196 if (build_id != NULL)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 static void 1244 static void
1217 elf_symfile_read (struct objfile *objfile, int symfile_flags) 1245 elf_symfile_read (struct objfile *objfile, int symfile_flags)
1218 { 1246 {
1219 bfd *synth_abfd, *abfd = objfile->obfd; 1247 bfd *synth_abfd, *abfd = objfile->obfd;
1220 struct elfinfo ei; 1248 struct elfinfo ei;
1221 struct cleanup *back_to; 1249 struct cleanup *back_to;
1222 long symcount = 0, dynsymcount = 0, synthcount, storage_needed; 1250 long symcount = 0, dynsymcount = 0, synthcount, storage_needed;
1223 asymbol **symbol_table = NULL, **dyn_symbol_table = NULL; 1251 asymbol **symbol_table = NULL, **dyn_symbol_table = NULL;
1224 asymbol *synthsyms; 1252 asymbol *synthsyms;
1225 1253
1254 if (symtab_create_debug)
1255 {
1256 fprintf_unfiltered (gdb_stdlog,
1257 "Reading minimal symbols of objfile %s ...\n",
1258 objfile->name);
1259 }
1260
1226 init_minimal_symbol_collection (); 1261 init_minimal_symbol_collection ();
1227 back_to = make_cleanup_discard_minimal_symbols (); 1262 back_to = make_cleanup_discard_minimal_symbols ();
1228 1263
1229 memset ((char *) &ei, 0, sizeof (ei)); 1264 memset ((char *) &ei, 0, sizeof (ei));
1230 1265
1231 /* Allocate struct to keep track of the symfile. */ 1266 /* Allocate struct to keep track of the symfile. */
1232 objfile->deprecated_sym_stab_info = (struct dbx_symfile_info *) 1267 objfile->deprecated_sym_stab_info = (struct dbx_symfile_info *)
1233 xmalloc (sizeof (struct dbx_symfile_info)); 1268 xmalloc (sizeof (struct dbx_symfile_info));
1234 memset ((char *) objfile->deprecated_sym_stab_info, 1269 memset ((char *) objfile->deprecated_sym_stab_info,
1235 0, sizeof (struct dbx_symfile_info)); 1270 0, sizeof (struct dbx_symfile_info));
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 debugfile = find_separate_debug_file_by_debuglink (objfile); 1443 debugfile = find_separate_debug_file_by_debuglink (objfile);
1409 1444
1410 if (debugfile) 1445 if (debugfile)
1411 { 1446 {
1412 bfd *abfd = symfile_bfd_open (debugfile); 1447 bfd *abfd = symfile_bfd_open (debugfile);
1413 1448
1414 symbol_file_add_separate (abfd, symfile_flags, objfile); 1449 symbol_file_add_separate (abfd, symfile_flags, objfile);
1415 xfree (debugfile); 1450 xfree (debugfile);
1416 } 1451 }
1417 } 1452 }
1453
1454 if (symtab_create_debug)
1455 fprintf_unfiltered (gdb_stdlog, "Done reading minimal symbols.\n");
1418 } 1456 }
1419 1457
1420 /* Callback to lazily read psymtabs. */ 1458 /* Callback to lazily read psymtabs. */
1421 1459
1422 static void 1460 static void
1423 read_psyms (struct objfile *objfile) 1461 read_psyms (struct objfile *objfile)
1424 { 1462 {
1425 if (dwarf2_has_info (objfile, NULL)) 1463 if (dwarf2_has_info (objfile, NULL))
1426 dwarf2_build_psymtabs (objfile); 1464 dwarf2_build_psymtabs (objfile);
1427 } 1465 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 pst->section_offsets = (struct section_offsets *) 1587 pst->section_offsets = (struct section_offsets *)
1550 obstack_alloc (&objfile->objfile_obstack, 1588 obstack_alloc (&objfile->objfile_obstack,
1551 SIZEOF_N_SECTION_OFFSETS (objfile->num_sections)); 1589 SIZEOF_N_SECTION_OFFSETS (objfile->num_sections));
1552 for (i = 0; i < maybe->num_sections; i++) 1590 for (i = 0; i < maybe->num_sections; i++)
1553 (pst->section_offsets)->offsets[i] = maybe->sections[i]; 1591 (pst->section_offsets)->offsets[i] = maybe->sections[i];
1554 return; 1592 return;
1555 } 1593 }
1556 1594
1557 /* We were unable to find any offsets for this file. Complain. */ 1595 /* We were unable to find any offsets for this file. Complain. */
1558 if (dbx->stab_section_info) /* If there *is* any info, */ 1596 if (dbx->stab_section_info) /* If there *is* any info, */

error: old chunk mismatch

OLDNEW
« no previous file with comments | « gdb/dwarf2read.c ('k') | gdb/eval.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698