• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/cxxfilt-11/cxxfilt/binutils/

Lines Matching +defs:temp +defs:file +defs:name

1 /* readelf.c -- display contents of an ELF format file
8 This file is part of GNU Binutils.
29 so why does the binutils project have two file dumpers ?
31 The reason is that objdump sees an ELF file through a BFD filter of the
36 the file actually says.
42 ELF file than is provided by objdump. In particular it can display DWARF
103 /* The following headers use the elf/reloc-macros.h file to
224 by name. */
227 char *name;
240 some kind has been requested. It is reset on a per-object file
270 : string_table == NULL ? "<no-name>" \
296 #define GET_ELF_SYMBOLS(file, section) \
297 (is_32bit_elf ? get_32bit_elf_symbols (file, section) \
298 : get_64bit_elf_symbols (file, section))
312 get_data (void *var, FILE *file, long offset, size_t size, size_t nmemb,
320 if (fseek (file, archive_file_offset + offset, SEEK_SET))
345 if (fread (mvar, size, nmemb, file) != nmemb)
581 find_section (const char *name)
586 if (streq (SECTION_NAME (section_headers + i), name))
692 slurp_rela_relocs (FILE *file,
706 erelas = get_data (NULL, file, rel_offset, 1, rel_size, _("relocs"));
734 erelas = get_data (NULL, file, rel_offset, 1, rel_size, _("relocs"));
764 slurp_rel_relocs (FILE *file,
778 erels = get_data (NULL, file, rel_offset, 1, rel_size, _("relocs"));
806 erels = get_data (NULL, file, rel_offset, 1, rel_size, _("relocs"));
839 dump_relocations (FILE *file,
857 if (!slurp_rela_relocs (file, rel_offset, rel_size, &rels, &rel_size))
862 if (!slurp_rel_relocs (file, rel_offset, rel_size, &rels, &rel_size))
1667 case ET_REL: return _("REL (Relocatable file)");
1668 case ET_EXEC: return _("EXEC (Executable file)");
1669 case ET_DYN: return _("DYN (Shared object file)");
1670 case ET_CORE: return _("CORE (Core file)");
2189 This means it is likely to be an o32 file, but not for
2728 {"file-header", no_argument, 0, 'h'},
2737 {"full-section-name",no_argument, 0, 'N'},
2762 fprintf (stdout, _("Usage: readelf <option(s)> elf-file(s)\n"));
2766 -h --file-header Display the ELF file header\n\
2795 @<file> Read options from <file>\n\
2837 /* Request a dump by section name. */
2848 new_request->name = strdup (section);
2849 if (!new_request->name)
3178 (_("Not an ELF file - it has the wrong magic bytes at the start\n"));
3217 printf (_(" (bytes into file)\n Start of section headers: "));
3219 printf (_(" (bytes into file)\n"));
3269 get_32bit_program_headers (FILE *file, Elf_Internal_Phdr *program_headers)
3276 phdrs = get_data (NULL, file, elf_header.e_phoff,
3302 get_64bit_program_headers (FILE *file, Elf_Internal_Phdr *program_headers)
3309 phdrs = get_data (NULL, file, elf_header.e_phoff,
3337 get_program_headers (FILE *file)
3354 ? get_32bit_program_headers (file, phdrs)
3355 : get_64bit_program_headers (file, phdrs))
3368 process_program_headers (FILE *file)
3376 printf (_("\nThere are no program headers in this file.\n"));
3382 printf (_("\nElf file type is %s\n"), get_file_type (elf_header.e_type));
3391 if (! get_program_headers (file))
3539 if (fseek (file, archive_file_offset + (long) segment->p_offset,
3541 error (_("Unable to find program interpreter name\n"));
3551 if (fscanf (file, fmt, program_interpreter) <= 0)
3552 error (_("Unable to read program interpreter name\n"));
3594 /* Find the file offset corresponding to VMA by using the program headers. */
3597 offset_from_vma (FILE *file, bfd_vma vma, bfd_size_type size)
3601 if (! get_program_headers (file))
3626 get_32bit_section_headers (FILE *file, unsigned int num)
3632 shdrs = get_data (NULL, file, elf_header.e_shoff,
3667 get_64bit_section_headers (FILE *file, unsigned int num)
3673 shdrs = get_data (NULL, file, elf_header.e_shoff,
3708 get_32bit_elf_symbols (FILE *file, Elf_Internal_Shdr *section)
3717 esyms = get_data (NULL, file, section->sh_offset, 1, section->sh_size,
3727 shndx = get_data (NULL, file, symtab_shndx_hdr->sh_offset,
3771 get_64bit_elf_symbols (FILE *file, Elf_Internal_Shdr *section)
3780 esyms = get_data (NULL, file, section->sh_offset, 1, section->sh_size,
3790 shndx = get_data (NULL, file, symtab_shndx_hdr->sh_offset,
4008 process_section_headers (FILE *file)
4018 printf (_("\nThere are no sections in this file.\n"));
4029 if (! get_32bit_section_headers (file, elf_header.e_shnum))
4032 else if (! get_64bit_section_headers (file, elf_header.e_shnum))
4043 string_table = get_data (NULL, file, section->sh_offset,
4114 char *name = SECTION_NAME (section);
4126 dynamic_symbols = GET_ELF_SYMBOLS (file, section);
4129 && streq (name, ".dynstr"))
4137 dynamic_strings = get_data (NULL, file, section->sh_offset,
4162 && const_strneq (name, ".debug_"))
4164 name += 7;
4167 || (do_debug_info && streq (name, "info"))
4168 || (do_debug_abbrevs && streq (name, "abbrev"))
4169 || (do_debug_lines && streq (name, "line"))
4170 || (do_debug_pubnames && streq (name, "pubnames"))
4171 || (do_debug_aranges && streq (name, "aranges"))
4172 || (do_debug_ranges && streq (name, "ranges"))
4173 || (do_debug_frames && streq (name, "frame"))
4174 || (do_debug_macinfo && streq (name, "macinfo"))
4175 || (do_debug_str && streq (name, "str"))
4176 || (do_debug_loc && streq (name, "loc"))
4182 && const_strneq (name, ".gnu.linkonce.wi."))
4184 else if (do_debug_frames && streq (name, ".eh_frame"))
4394 process_section_groups (FILE *file)
4411 printf (_("\nThere are no sections in this file.\n"));
4442 printf (_("\nThere are no section groups in this file.\n"));
4466 char *name = SECTION_NAME (section);
4478 error (_("Bad sh_link in group section `%s'\n"), name);
4487 symtab = GET_ELF_SYMBOLS (file, symtab_sec);
4497 error (_("Bad sh_info in group section `%s'\n"), name);
4526 strtab = get_data (NULL, file, strtab_sec->sh_offset,
4535 start = get_data (NULL, file, section->sh_offset,
4546 get_group_flags (entry), i, name, group_name, size);
4629 const char *name;
4643 process_relocs (FILE *file)
4655 const char *name;
4664 name = dynamic_relocations [i].name;
4688 name, rel_offset, rel_size);
4690 dump_relocations (file,
4691 offset_from_vma (file, rel_offset, rel_size),
4699 printf (_("\nThere are no dynamic relocations in this file.\n"));
4751 symtab = GET_ELF_SYMBOLS (file, symsec);
4761 strtab = get_data (NULL, file, strsec->sh_offset,
4767 dump_relocations (file, rel_offset, rel_size,
4774 dump_relocations (file, rel_offset, rel_size,
4782 printf (_("\nThere are no relocations in this file.\n"));
4922 slurp_ia64_unwind_table (FILE *file,
4940 if (! get_program_headers (file))
4961 table = get_data (NULL, file, sec->sh_offset, 1, size, _("unwind table"));
5001 if (!slurp_rela_relocs (file, relsec->sh_offset, relsec->sh_size,
5053 ia64_process_unwind (FILE *file)
5067 aux.symtab = GET_ELF_SYMBOLS (file, sec);
5070 aux.strtab = get_data (NULL, file, strsec->sh_offset,
5079 printf (_("\nThere are no unwind sections in this file.\n"));
5153 aux.info = get_data (NULL, file, sec->sh_offset, 1, aux.info_size,
5167 (void) slurp_ia64_unwind_table (file, & aux, unwsec);
5303 slurp_hppa_unwind_table (FILE *file,
5321 if (! get_program_headers (file))
5343 table = get_data (NULL, file, sec->sh_offset, 1, size, _("unwind table"));
5413 if (!slurp_rela_relocs (file, relsec->sh_offset, relsec->sh_size,
5463 hppa_process_unwind (FILE *file)
5482 aux.symtab = GET_ELF_SYMBOLS (file, sec);
5485 aux.strtab = get_data (NULL, file, strsec->sh_offset,
5494 printf (_("\nThere are no unwind sections in this file.\n"));
5507 slurp_hppa_unwind_table (file, &aux, sec);
5526 process_unwind (FILE *file)
5530 int (*handler)(FILE *file);
5543 return handlers[i].handler (file);
5545 printf (_("\nThere are no unwind sections in this file.\n"));
5704 get_32bit_dynamic_section (FILE *file)
5709 edyn = get_data (NULL, file, dynamic_addr, 1, dynamic_size,
5748 get_64bit_dynamic_section (FILE *file)
5753 edyn = get_data (NULL, file, dynamic_addr, 1, dynamic_size,
5824 process_dynamic_section (FILE *file)
5831 printf (_("\nThere is no dynamic section in this file.\n"));
5838 if (! get_32bit_dynamic_section (file))
5841 else if (! get_64bit_dynamic_section (file))
5859 we default to reading in the entire file (!) and
5862 section.sh_offset = offset_from_vma (file, entry->d_un.d_val, 0);
5868 if (fseek (file, 0, SEEK_END))
5869 error (_("Unable to seek to end of file!"));
5871 section.sh_size = ftell (file) - section.sh_offset;
5886 dynamic_symbols = GET_ELF_SYMBOLS (file, &section);
5906 we default to reading in the entire file (!) and
5910 offset = offset_from_vma (file, entry->d_un.d_val, 0);
5916 if (fseek (file, 0, SEEK_END))
5917 error (_("Unable to seek to end of file\n"));
5918 str_tab_len = ftell (file) - offset;
5928 dynamic_strings = get_data (NULL, file, offset, 1, str_tab_len,
5953 dynamic_syminfo_offset = offset_from_vma (file, entry->d_un.d_val,
5963 extsyminfo = get_data (NULL, file, dynamic_syminfo_offset, 1,
6036 printf (_("Configuration file"));
6229 char *name;
6232 name = GET_DYNAMIC_NAME (entry->d_un.d_val);
6234 name = NULL;
6236 if (name)
6241 printf (_("Shared library: [%s]"), name);
6243 if (streq (name, program_interpreter))
6248 printf (_("Library soname: [%s]"), name);
6252 printf (_("Library rpath: [%s]"), name);
6256 printf (_("Library runpath: [%s]"), name);
6315 char *name = GET_DYNAMIC_NAME (entry->d_un.d_val);
6317 if (*name)
6319 printf (_("Not needed object: [%s]\n"), name);
6418 process_version_sections (FILE *file)
6454 edefs = get_data (NULL, file, section->sh_offset, 1,
6516 printf (_(" %#06x: Parent %d, name index: %ld\n"),
6547 eneed = get_data (NULL, file, section->sh_offset, 1,
6640 symbols = GET_ELF_SYMBOLS (file, link_section);
6644 strtab = get_data (NULL, file, string_sec->sh_offset, 1,
6658 off = offset_from_vma (file,
6661 edata = get_data (NULL, file, off, total, sizeof (short),
6681 char *name;
6720 (file, version_info[DT_VERSIONTAGIDX (DT_VERNEED)],
6730 get_data (&evn, file, offset, sizeof (evn), 1,
6740 get_data (&evna, file, a_off, sizeof (evna),
6755 name = strtab + ivna.vna_name;
6757 name,
6758 12 - (int) strlen (name),
6777 (file, version_info[DT_VERSIONTAGIDX (DT_VERDEF)],
6782 get_data (&evd, file, offset, sizeof (evd), 1,
6800 get_data (&evda, file,
6807 name = strtab + ivda.vda_name;
6809 name,
6810 12 - (int) strlen (name),
6834 printf (_("\nNo version information found in this file.\n"));
6996 get_dynamic_data (FILE *file, unsigned int number, unsigned int ent_size)
7009 if (fread (e_data, ent_size, number, file) != number)
7034 process_symbol_table (FILE *file)
7061 if (fseek (file,
7063 + offset_from_vma (file, dynamic_info[DT_HASH],
7071 if (fread (nb, hash_ent_size, 1, file) != 1)
7077 if (fread (nc, hash_ent_size, 1, file) != 1)
7086 buckets = get_dynamic_data (file, nbuckets, hash_ent_size);
7087 chains = get_dynamic_data (file, nchains, hash_ent_size);
7169 symtab = GET_ELF_SYMBOLS (file, section);
7184 strtab = get_data (NULL, file, string_sec->sh_offset,
7219 (file, version_info[DT_VERSIONTAGIDX (DT_VERSYM)],
7222 get_data (&data, file, offset + si * sizeof (vers_data),
7245 (file, version_info[DT_VERSIONTAGIDX (DT_VERNEED)],
7252 get_data (&evn, file, offset, sizeof (evn), 1,
7264 get_data (&evna, file, vna_off,
7309 (file,
7317 get_data (&evd, file, offset, sizeof (evd),
7332 get_data (&evda, file, offset, sizeof (evda),
7435 if (fseek (file,
7437 + offset_from_vma (file, dynamic_info_DT_GNU_HASH,
7445 if (fread (nb, 16, 1, file) != 1)
7460 if (fseek (file,
7462 + offset_from_vma (file, buckets_vma, 4)),
7469 gnubuckets = get_dynamic_data (file, ngnubuckets, 4);
7489 if (fseek (file,
7491 + offset_from_vma (file, buckets_vma
7501 if (fread (nb, 4, 1, file) != 1)
7514 if (fseek (file,
7516 + offset_from_vma (file, buckets_vma + 4 * ngnubuckets, 4)),
7523 gnuchains = get_dynamic_data (file, maxchain, 4);
7587 process_syminfo (FILE *file ATTRIBUTE_UNUSED)
7654 disassemble_section (Elf_Internal_Shdr *section, FILE *file)
7666 dump_section (Elf_Internal_Shdr *section, FILE *file)
7687 start = get_data (NULL, file, section->sh_offset, 1, bytes,
7797 debug_apply_rela_addends (void *file,
7824 if (!slurp_rela_relocs (file, relsec->sh_offset, relsec->sh_size,
7829 symtab = GET_ELF_SYMBOLS (file, symsec);
7914 load_debug_section (enum dwarf_section_display_enum debug, void *file)
7925 sec = find_section (section->name);
7929 snprintf (buf, sizeof (buf), _("%s section data"), section->name);
7932 section->start = get_data (NULL, file, sec->sh_offset, 1,
7936 debug_apply_rela_addends (file, sec, section->start);
7956 display_debug_section (Elf_Internal_Shdr *section, FILE *file)
7958 char *name = SECTION_NAME (section);
7966 printf (_("\nSection '%s' has no debugging data.\n"), name);
7970 if (const_strneq (name, ".gnu.linkonce.wi."))
7971 name = ".debug_info";
7975 if (streq (debug_displays[i].section.name, name))
7979 if (load_debug_section (i, file))
7981 result &= debug_displays[i].display (sec, file);
7992 printf (_("Unrecognized debug section: %s\n"), name);
8000 based on section name. */
8013 if (streq (SECTION_NAME (section_headers + i), cur->name))
8021 cur->name);
8026 process_section_contents (FILE *file)
8042 disassemble_section (section, file);
8045 dump_section (section, file);
8048 display_debug_section (section, file);
8083 const char *name;
8136 #define LOOKUP(id, name) \
8137 {id, #name, 0x80 | ARRAY_SIZE(arm_attr_tag_##name), arm_attr_tag_##name}
8222 printf (" Tag_%s: ", attr->name);
8295 process_arm_specific (FILE *file)
8313 contents = get_data (NULL, file, sect->sh_offset, 1, sect->sh_size,
8412 process_mips_specific (FILE *file)
8431 = offset_from_vma (file, entry->d_un.d_val,
8438 options_offset = offset_from_vma (file, entry->d_un.d_val, 0);
8442 = offset_from_vma (file, entry->d_un.d_val,
8457 elib = get_data (NULL, file, liblist_offset,
8500 const char *name;
8520 fputs (l_flags_vals[fcnt].name, stdout);
8547 eopt = get_data (NULL, file, options_offset, 1, sect->sh_size,
8754 econf32 = get_data (NULL, file, conflicts_offset,
8768 econf64 = get_data (NULL, file, conflicts_offset,
8804 process_gnu_liblist (FILE *file)
8826 elib = get_data (NULL, file, section->sh_offset, 1, section->sh_size,
8833 strtab = get_data (NULL, file, string_sec->sh_offset, 1,
9000 /* Note that by the ELF standard, the name field is already null byte
9002 I.E. the value of namesz for the name "FSF" is 4.
9004 If the value of namesz is zero, there is no name present. */
9011 /* If there is no note name, then use the default set of
9016 /* NetBSD-specific core file notes. */
9020 /* Don't recognize this note name; just use the default set of
9032 process_corefile_note_segment (FILE *file, bfd_vma offset, bfd_vma length)
9041 pnotes = get_data (NULL, file, offset, 1, length, _("notes"));
9055 char *temp = NULL;
9059 inote.namedata = external->name;
9077 /* Verify that name is null terminated. It appears that at least
9083 temp = malloc (inote.namesz + 1);
9085 if (temp == NULL)
9092 strncpy (temp, inote.namedata, inote.namesz);
9093 temp[inote.namesz] = 0;
9095 /* warn (_("'%s' NOTE name not properly null terminated\n"), temp); */
9096 inote.namedata = temp;
9101 if (temp != NULL)
9103 free (temp);
9104 temp = NULL;
9114 process_corefile_note_segments (FILE *file)
9120 if (! get_program_headers (file))
9128 res &= process_corefile_note_segment (file,
9137 process_note_sections (FILE *file)
9147 res &= process_corefile_note_segment (file,
9155 process_notes (FILE *file)
9162 return process_note_sections (file);
9166 return process_corefile_note_segments (file);
9168 printf (_("No note segments present in the core file.\n"));
9173 process_arch_specific (FILE *file)
9181 return process_arm_specific (file);
9184 return process_mips_specific (file);
9193 get_file_header (FILE *file)
9196 if (fread (elf_header.e_ident, EI_NIDENT, 1, file) != 1)
9222 if (fread (ehdr32.e_type, sizeof (ehdr32) - EI_NIDENT, 1, file) != 1)
9254 if (fread (ehdr64.e_type, sizeof (ehdr64) - EI_NIDENT, 1, file) != 1)
9277 get_32bit_section_headers (file, 1);
9279 get_64bit_section_headers (file, 1);
9287 /* Process one ELF object file according to the command line options.
9288 This file may actually be stored in an archive. The file is
9292 process_object (char *file_name, FILE *file)
9296 if (! get_file_header (file))
9298 error (_("%s: Failed to read file header\n"), file_name);
9302 /* Initialise per file variables. */
9309 /* Process the file. */
9316 object file is processed. */
9333 if (! process_section_headers (file))
9343 if (! process_section_groups (file))
9349 if (process_program_headers (file))
9350 process_dynamic_section (file);
9352 process_relocs (file);
9354 process_unwind (file);
9356 process_symbol_table (file);
9358 process_syminfo (file);
9360 process_version_sections (file);
9362 process_section_contents (file);
9364 process_notes (file);
9366 process_gnu_liblist (file);
9368 process_arch_specific (file);
9437 /* Process an ELF archive. The file is positioned just after the
9441 process_archive (char *file_name, FILE *file)
9453 got = fread (&arhdr, 1, sizeof arhdr, file);
9468 if (fseek (file, size + (size & 1), SEEK_CUR) != 0)
9474 got = fread (&arhdr, 1, sizeof arhdr, file);
9499 if (fread (longnames, longnames_size, 1, file) != 1)
9507 getc (file);
9509 got = fread (&arhdr, 1, sizeof arhdr, file);
9527 char *name;
9543 name = longnames + off;
9544 nameend = memchr (name, '/', longnames_size - off);
9548 name = arhdr.ar_name;
9549 nameend = memchr (name, '/', 16);
9554 error (_("%s: bad archive file name\n"), file_name);
9559 namealc = malloc (file_name_size + (nameend - name) + 3);
9569 memcpy (namealc + file_name_size + 1, name, nameend - name);
9570 namealc[file_name_size + 1 + (nameend - name)] = ')';
9571 namealc[file_name_size + 2 + (nameend - name)] = '\0';
9573 archive_file_offset = ftell (file);
9576 ret |= process_object (namealc, file);
9580 if (fseek (file,
9591 got = fread (&arhdr, 1, sizeof arhdr, file);
9612 FILE *file;
9620 error (_("'%s': No such file\n"), file_name);
9629 error (_("'%s' is not an ordinary file\n"), file_name);
9633 file = fopen (file_name, "rb");
9634 if (file == NULL)
9636 error (_("Input file '%s' is not readable.\n"), file_name);
9640 if (fread (armag, SARMAG, 1, file) != 1)
9642 error (_("%s: Failed to read file header\n"), file_name);
9643 fclose (file);
9648 ret = process_archive (file_name, file);
9651 rewind (file);
9653 ret = process_object (file_name, file);
9656 fclose (file);