+static void
+dynamic_section_parisc_val (Elf_Internal_Dyn * entry)
+{
+ switch (entry->d_tag)
+ {
+ case DT_HP_DLD_FLAGS:
+ {
+ static struct
+ {
+ long int bit;
+ const char * str;
+ }
+ flags[] =
+ {
+ { DT_HP_DEBUG_PRIVATE, "HP_DEBUG_PRIVATE" },
+ { DT_HP_DEBUG_CALLBACK, "HP_DEBUG_CALLBACK" },
+ { DT_HP_DEBUG_CALLBACK_BOR, "HP_DEBUG_CALLBACK_BOR" },
+ { DT_HP_NO_ENVVAR, "HP_NO_ENVVAR" },
+ { DT_HP_BIND_NOW, "HP_BIND_NOW" },
+ { DT_HP_BIND_NONFATAL, "HP_BIND_NONFATAL" },
+ { DT_HP_BIND_VERBOSE, "HP_BIND_VERBOSE" },
+ { DT_HP_BIND_RESTRICTED, "HP_BIND_RESTRICTED" },
+ { DT_HP_BIND_SYMBOLIC, "HP_BIND_SYMBOLIC" },
+ { DT_HP_RPATH_FIRST, "HP_RPATH_FIRST" },
+ { DT_HP_BIND_DEPTH_FIRST, "HP_BIND_DEPTH_FIRST" },
+ { DT_HP_GST, "HP_GST" },
+ { DT_HP_SHLIB_FIXED, "HP_SHLIB_FIXED" },
+ { DT_HP_MERGE_SHLIB_SEG, "HP_MERGE_SHLIB_SEG" },
+ { DT_HP_NODELETE, "HP_NODELETE" },
+ { DT_HP_GROUP, "HP_GROUP" },
+ { DT_HP_PROTECT_LINKAGE_TABLE, "HP_PROTECT_LINKAGE_TABLE" }
+ };
+ int first = 1;
+ size_t cnt;
+ bfd_vma val = entry->d_un.d_val;
+
+ for (cnt = 0; cnt < ARRAY_SIZE (flags); ++cnt)
+ if (val & flags[cnt].bit)
+ {
+ if (! first)
+ putchar (' ');
+ fputs (flags[cnt].str, stdout);
+ first = 0;
+ val ^= flags[cnt].bit;
+ }
+
+ if (val != 0 || first)
+ {
+ if (! first)
+ putchar (' ');
+ print_vma (val, HEX);
+ }
+ }
+ break;
+
+ default:
+ print_vma (entry->d_un.d_ptr, PREFIX_HEX);
+ break;
+ }
+ putchar ('\n');
+}
+
+#ifdef BFD64
+
+/* VMS vs Unix time offset and factor. */
+
+#define VMS_EPOCH_OFFSET 35067168000000000LL
+#define VMS_GRANULARITY_FACTOR 10000000
+
+/* Display a VMS time in a human readable format. */
+
+static void
+print_vms_time (bfd_int64_t vmstime)
+{
+ struct tm *tm;
+ time_t unxtime;
+
+ unxtime = (vmstime - VMS_EPOCH_OFFSET) / VMS_GRANULARITY_FACTOR;
+ tm = gmtime (&unxtime);
+ printf ("%04u-%02u-%02uT%02u:%02u:%02u",
+ tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
+ tm->tm_hour, tm->tm_min, tm->tm_sec);
+}
+#endif /* BFD64 */
+
+static void
+dynamic_section_ia64_val (Elf_Internal_Dyn * entry)
+{
+ switch (entry->d_tag)
+ {
+ case DT_IA_64_PLT_RESERVE:
+ /* First 3 slots reserved. */
+ print_vma (entry->d_un.d_ptr, PREFIX_HEX);
+ printf (" -- ");
+ print_vma (entry->d_un.d_ptr + (3 * 8), PREFIX_HEX);
+ break;
+
+ case DT_IA_64_VMS_LINKTIME:
+#ifdef BFD64
+ print_vms_time (entry->d_un.d_val);
+#endif
+ break;
+
+ case DT_IA_64_VMS_LNKFLAGS:
+ print_vma (entry->d_un.d_ptr, PREFIX_HEX);
+ if (entry->d_un.d_val & VMS_LF_CALL_DEBUG)
+ printf (" CALL_DEBUG");
+ if (entry->d_un.d_val & VMS_LF_NOP0BUFS)
+ printf (" NOP0BUFS");
+ if (entry->d_un.d_val & VMS_LF_P0IMAGE)
+ printf (" P0IMAGE");
+ if (entry->d_un.d_val & VMS_LF_MKTHREADS)
+ printf (" MKTHREADS");
+ if (entry->d_un.d_val & VMS_LF_UPCALLS)
+ printf (" UPCALLS");
+ if (entry->d_un.d_val & VMS_LF_IMGSTA)
+ printf (" IMGSTA");
+ if (entry->d_un.d_val & VMS_LF_INITIALIZE)
+ printf (" INITIALIZE");
+ if (entry->d_un.d_val & VMS_LF_MAIN)
+ printf (" MAIN");
+ if (entry->d_un.d_val & VMS_LF_EXE_INIT)
+ printf (" EXE_INIT");
+ if (entry->d_un.d_val & VMS_LF_TBK_IN_IMG)
+ printf (" TBK_IN_IMG");
+ if (entry->d_un.d_val & VMS_LF_DBG_IN_IMG)
+ printf (" DBG_IN_IMG");
+ if (entry->d_un.d_val & VMS_LF_TBK_IN_DSF)
+ printf (" TBK_IN_DSF");
+ if (entry->d_un.d_val & VMS_LF_DBG_IN_DSF)
+ printf (" DBG_IN_DSF");
+ if (entry->d_un.d_val & VMS_LF_SIGNATURES)
+ printf (" SIGNATURES");
+ if (entry->d_un.d_val & VMS_LF_REL_SEG_OFF)
+ printf (" REL_SEG_OFF");
+ break;
+
+ default:
+ print_vma (entry->d_un.d_ptr, PREFIX_HEX);
+ break;
+ }
+ putchar ('\n');
+}
+
+static int
+get_32bit_dynamic_section (FILE * file)
+{
+ Elf32_External_Dyn * edyn;
+ Elf32_External_Dyn * ext;
+ Elf_Internal_Dyn * entry;
+
+ edyn = (Elf32_External_Dyn *) get_data (NULL, file, dynamic_addr, 1,
+ dynamic_size, _("dynamic section"));
+ if (!edyn)
+ return 0;
+
+/* SGI's ELF has more than one section in the DYNAMIC segment, and we
+ might not have the luxury of section headers. Look for the DT_NULL
+ terminator to determine the number of entries. */
+ for (ext = edyn, dynamic_nent = 0;
+ (char *) ext < (char *) edyn + dynamic_size;
+ ext++)
+ {
+ dynamic_nent++;
+ if (BYTE_GET (ext->d_tag) == DT_NULL)
+ break;
+ }
+
+ dynamic_section = (Elf_Internal_Dyn *) cmalloc (dynamic_nent,
+ sizeof (* entry));
+ if (dynamic_section == NULL)
+ {
+ error (_("Out of memory\n"));
+ free (edyn);
+ return 0;
+ }
+
+ for (ext = edyn, entry = dynamic_section;
+ entry < dynamic_section + dynamic_nent;
+ ext++, entry++)
+ {
+ entry->d_tag = BYTE_GET (ext->d_tag);
+ entry->d_un.d_val = BYTE_GET (ext->d_un.d_val);
+ }
+
+ free (edyn);
+
+ return 1;
+}
+
+static int
+get_64bit_dynamic_section (FILE * file)
+{
+ Elf64_External_Dyn * edyn;
+ Elf64_External_Dyn * ext;
+ Elf_Internal_Dyn * entry;
+
+ edyn = (Elf64_External_Dyn *) get_data (NULL, file, dynamic_addr, 1,
+ dynamic_size, _("dynamic section"));
+ if (!edyn)
+ return 0;
+
+/* SGI's ELF has more than one section in the DYNAMIC segment, and we
+ might not have the luxury of section headers. Look for the DT_NULL
+ terminator to determine the number of entries. */
+ for (ext = edyn, dynamic_nent = 0;
+ (char *) ext < (char *) edyn + dynamic_size;
+ ext++)
+ {
+ dynamic_nent++;
+ if (BYTE_GET (ext->d_tag) == DT_NULL)
+ break;
+ }
+
+ dynamic_section = (Elf_Internal_Dyn *) cmalloc (dynamic_nent,
+ sizeof (* entry));
+ if (dynamic_section == NULL)
+ {
+ error (_("Out of memory\n"));
+ free (edyn);
+ return 0;
+ }
+
+ for (ext = edyn, entry = dynamic_section;
+ entry < dynamic_section + dynamic_nent;
+ ext++, entry++)
+ {
+ entry->d_tag = BYTE_GET (ext->d_tag);
+ entry->d_un.d_val = BYTE_GET (ext->d_un.d_val);
+ }
+
+ free (edyn);
+
+ return 1;
+}
+
+static void
+print_dynamic_flags (bfd_vma flags)
+{
+ int first = 1;
+
+ while (flags)
+ {
+ bfd_vma flag;
+
+ flag = flags & - flags;
+ flags &= ~ flag;
+
+ if (first)
+ first = 0;
+ else
+ putc (' ', stdout);
+
+ switch (flag)
+ {
+ case DF_ORIGIN: fputs ("ORIGIN", stdout); break;
+ case DF_SYMBOLIC: fputs ("SYMBOLIC", stdout); break;
+ case DF_TEXTREL: fputs ("TEXTREL", stdout); break;
+ case DF_BIND_NOW: fputs ("BIND_NOW", stdout); break;
+ case DF_STATIC_TLS: fputs ("STATIC_TLS", stdout); break;
+ default: fputs (_("unknown"), stdout); break;
+ }
+ }
+ puts ("");
+}
+
+/* Parse and display the contents of the dynamic section. */
+
+static int
+process_dynamic_section (FILE * file)
+{
+ Elf_Internal_Dyn * entry;
+
+ if (dynamic_size == 0)
+ {
+ if (do_dynamic)
+ printf (_("\nThere is no dynamic section in this file.\n"));
+
+ return 1;
+ }
+
+ if (is_32bit_elf)
+ {
+ if (! get_32bit_dynamic_section (file))
+ return 0;
+ }
+ else if (! get_64bit_dynamic_section (file))
+ return 0;
+
+ /* Find the appropriate symbol table. */
+ if (dynamic_symbols == NULL)
+ {
+ for (entry = dynamic_section;
+ entry < dynamic_section + dynamic_nent;
+ ++entry)
+ {
+ Elf_Internal_Shdr section;
+
+ if (entry->d_tag != DT_SYMTAB)
+ continue;
+
+ dynamic_info[DT_SYMTAB] = entry->d_un.d_val;
+
+ /* Since we do not know how big the symbol table is,
+ we default to reading in the entire file (!) and
+ processing that. This is overkill, I know, but it
+ should work. */
+ section.sh_offset = offset_from_vma (file, entry->d_un.d_val, 0);
+
+ if (archive_file_offset != 0)
+ section.sh_size = archive_file_size - section.sh_offset;
+ else
+ {
+ if (fseek (file, 0, SEEK_END))
+ error (_("Unable to seek to end of file!\n"));
+
+ section.sh_size = ftell (file) - section.sh_offset;
+ }
+
+ if (is_32bit_elf)
+ section.sh_entsize = sizeof (Elf32_External_Sym);
+ else
+ section.sh_entsize = sizeof (Elf64_External_Sym);
+
+ num_dynamic_syms = section.sh_size / section.sh_entsize;
+ if (num_dynamic_syms < 1)
+ {
+ error (_("Unable to determine the number of symbols to load\n"));
+ continue;
+ }
+
+ dynamic_symbols = GET_ELF_SYMBOLS (file, §ion);
+ }
+ }
+
+ /* Similarly find a string table. */
+ if (dynamic_strings == NULL)
+ {
+ for (entry = dynamic_section;
+ entry < dynamic_section + dynamic_nent;
+ ++entry)
+ {
+ unsigned long offset;
+ long str_tab_len;
+
+ if (entry->d_tag != DT_STRTAB)
+ continue;
+
+ dynamic_info[DT_STRTAB] = entry->d_un.d_val;
+
+ /* Since we do not know how big the string table is,
+ we default to reading in the entire file (!) and
+ processing that. This is overkill, I know, but it
+ should work. */
+
+ offset = offset_from_vma (file, entry->d_un.d_val, 0);
+
+ if (archive_file_offset != 0)
+ str_tab_len = archive_file_size - offset;
+ else
+ {
+ if (fseek (file, 0, SEEK_END))
+ error (_("Unable to seek to end of file\n"));
+ str_tab_len = ftell (file) - offset;
+ }
+
+ if (str_tab_len < 1)
+ {
+ error
+ (_("Unable to determine the length of the dynamic string table\n"));
+ continue;
+ }
+
+ dynamic_strings = (char *) get_data (NULL, file, offset, 1,
+ str_tab_len,
+ _("dynamic string table"));
+ dynamic_strings_length = str_tab_len;
+ break;
+ }
+ }
+
+ /* And find the syminfo section if available. */
+ if (dynamic_syminfo == NULL)
+ {
+ unsigned long syminsz = 0;
+
+ for (entry = dynamic_section;
+ entry < dynamic_section + dynamic_nent;
+ ++entry)
+ {
+ if (entry->d_tag == DT_SYMINENT)
+ {
+ /* Note: these braces are necessary to avoid a syntax
+ error from the SunOS4 C compiler. */
+ assert (sizeof (Elf_External_Syminfo) == entry->d_un.d_val);
+ }
+ else if (entry->d_tag == DT_SYMINSZ)
+ syminsz = entry->d_un.d_val;
+ else if (entry->d_tag == DT_SYMINFO)
+ dynamic_syminfo_offset = offset_from_vma (file, entry->d_un.d_val,
+ syminsz);
+ }
+
+ if (dynamic_syminfo_offset != 0 && syminsz != 0)
+ {
+ Elf_External_Syminfo * extsyminfo;
+ Elf_External_Syminfo * extsym;
+ Elf_Internal_Syminfo * syminfo;
+
+ /* There is a syminfo section. Read the data. */
+ extsyminfo = (Elf_External_Syminfo *)
+ get_data (NULL, file, dynamic_syminfo_offset, 1, syminsz,
+ _("symbol information"));
+ if (!extsyminfo)
+ return 0;
+
+ dynamic_syminfo = (Elf_Internal_Syminfo *) malloc (syminsz);
+ if (dynamic_syminfo == NULL)
+ {
+ error (_("Out of memory\n"));
+ return 0;
+ }
+
+ dynamic_syminfo_nent = syminsz / sizeof (Elf_External_Syminfo);
+ for (syminfo = dynamic_syminfo, extsym = extsyminfo;
+ syminfo < dynamic_syminfo + dynamic_syminfo_nent;
+ ++syminfo, ++extsym)
+ {
+ syminfo->si_boundto = BYTE_GET (extsym->si_boundto);
+ syminfo->si_flags = BYTE_GET (extsym->si_flags);
+ }
+
+ free (extsyminfo);
+ }
+ }
+
+ if (do_dynamic && dynamic_addr)
+ printf (_("\nDynamic section at offset 0x%lx contains %u entries:\n"),
+ dynamic_addr, dynamic_nent);
+ if (do_dynamic)
+ printf (_(" Tag Type Name/Value\n"));
+
+ for (entry = dynamic_section;
+ entry < dynamic_section + dynamic_nent;
+ entry++)
+ {
+ if (do_dynamic)
+ {
+ const char * dtype;
+
+ putchar (' ');
+ print_vma (entry->d_tag, FULL_HEX);
+ dtype = get_dynamic_type (entry->d_tag);
+ printf (" (%s)%*s", dtype,
+ ((is_32bit_elf ? 27 : 19)
+ - (int) strlen (dtype)),
+ " ");
+ }
+
+ switch (entry->d_tag)
+ {
+ case DT_FLAGS:
+ if (do_dynamic)
+ print_dynamic_flags (entry->d_un.d_val);
+ break;
+
+ case DT_AUXILIARY:
+ case DT_FILTER:
+ case DT_CONFIG:
+ case DT_DEPAUDIT:
+ case DT_AUDIT:
+ if (do_dynamic)
+ {
+ switch (entry->d_tag)
+ {
+ case DT_AUXILIARY:
+ printf (_("Auxiliary library"));
+ break;
+
+ case DT_FILTER:
+ printf (_("Filter library"));
+ break;
+
+ case DT_CONFIG:
+ printf (_("Configuration file"));
+ break;
+
+ case DT_DEPAUDIT:
+ printf (_("Dependency audit library"));
+ break;
+
+ case DT_AUDIT:
+ printf (_("Audit library"));
+ break;
+ }
+
+ if (VALID_DYNAMIC_NAME (entry->d_un.d_val))
+ printf (": [%s]\n", GET_DYNAMIC_NAME (entry->d_un.d_val));
+ else
+ {
+ printf (": ");
+ print_vma (entry->d_un.d_val, PREFIX_HEX);
+ putchar ('\n');
+ }
+ }
+ break;
+
+ case DT_FEATURE:
+ if (do_dynamic)
+ {