+/* Data used to display dynamic fixups. */
+
+struct ia64_vms_dynfixup
+{
+ bfd_vma needed_ident; /* Library ident number. */
+ bfd_vma needed; /* Index in the dstrtab of the library name. */
+ bfd_vma fixup_needed; /* Index of the library. */
+ bfd_vma fixup_rela_cnt; /* Number of fixups. */
+ bfd_vma fixup_rela_off; /* Fixups offset in the dynamic segment. */
+};
+
+/* Data used to display dynamic relocations. */
+
+struct ia64_vms_dynimgrela
+{
+ bfd_vma img_rela_cnt; /* Number of relocations. */
+ bfd_vma img_rela_off; /* Reloc offset in the dynamic segment. */
+};
+
+/* Display IA-64 OpenVMS dynamic fixups (used to dynamically link a shared
+ library). */
+
+static void
+dump_ia64_vms_dynamic_fixups (FILE *file, struct ia64_vms_dynfixup *fixup,
+ const char *strtab, unsigned int strtab_sz)
+{
+ Elf64_External_VMS_IMAGE_FIXUP *imfs;
+ long i;
+ const char *lib_name;
+
+ imfs = get_data (NULL, file, dynamic_addr + fixup->fixup_rela_off,
+ 1, fixup->fixup_rela_cnt * sizeof (*imfs),
+ _("dynamic section image fixups"));
+ if (!imfs)
+ return;
+
+ if (fixup->needed < strtab_sz)
+ lib_name = strtab + fixup->needed;
+ else
+ {
+ warn ("corrupt library name index of 0x%lx found in dynamic entry",
+ (unsigned long) fixup->needed);
+ lib_name = "???";
+ }
+ printf (_("\nImage fixups for needed library #%d: %s - ident: %lx\n"),
+ (int) fixup->fixup_needed, lib_name, (long) fixup->needed_ident);
+ printf
+ (_("Seg Offset Type SymVec DataType\n"));
+
+ for (i = 0; i < (long) fixup->fixup_rela_cnt; i++)
+ {
+ unsigned int type;
+ const char *rtype;
+
+ printf ("%3u ", (unsigned) BYTE_GET (imfs [i].fixup_seg));
+ printf_vma ((bfd_vma) BYTE_GET (imfs [i].fixup_offset));
+ type = BYTE_GET (imfs [i].type);
+ rtype = elf_ia64_reloc_type (type);
+ if (rtype == NULL)
+ printf (" 0x%08x ", type);
+ else
+ printf (" %-32s ", rtype);
+ printf ("%6u ", (unsigned) BYTE_GET (imfs [i].symvec_index));
+ printf ("0x%08x\n", (unsigned) BYTE_GET (imfs [i].data_type));
+ }
+
+ free (imfs);
+}
+
+/* Display IA-64 OpenVMS dynamic relocations (used to relocate an image). */
+
+static void
+dump_ia64_vms_dynamic_relocs (FILE *file, struct ia64_vms_dynimgrela *imgrela)
+{
+ Elf64_External_VMS_IMAGE_RELA *imrs;
+ long i;
+
+ imrs = get_data (NULL, file, dynamic_addr + imgrela->img_rela_off,
+ 1, imgrela->img_rela_cnt * sizeof (*imrs),
+ _("dynamic section image relas"));
+ if (!imrs)
+ return;
+
+ printf (_("\nImage relocs\n"));
+ printf
+ (_("Seg Offset Type Addend Seg Sym Off\n"));
+
+ for (i = 0; i < (long) imgrela->img_rela_cnt; i++)
+ {
+ unsigned int type;
+ const char *rtype;
+
+ printf ("%3u ", (unsigned) BYTE_GET (imrs [i].rela_seg));
+ printf ("%08" BFD_VMA_FMT "x ",
+ (bfd_vma) BYTE_GET (imrs [i].rela_offset));
+ type = BYTE_GET (imrs [i].type);
+ rtype = elf_ia64_reloc_type (type);
+ if (rtype == NULL)
+ printf ("0x%08x ", type);
+ else
+ printf ("%-31s ", rtype);
+ print_vma (BYTE_GET (imrs [i].addend), FULL_HEX);
+ printf ("%3u ", (unsigned) BYTE_GET (imrs [i].sym_seg));
+ printf ("%08" BFD_VMA_FMT "x\n",
+ (bfd_vma) BYTE_GET (imrs [i].sym_offset));
+ }
+
+ free (imrs);
+}
+
+/* Display IA-64 OpenVMS dynamic relocations and fixups. */
+
+static int
+process_ia64_vms_dynamic_relocs (FILE *file)
+{
+ struct ia64_vms_dynfixup fixup;
+ struct ia64_vms_dynimgrela imgrela;
+ Elf_Internal_Dyn *entry;
+ int res = 0;
+ bfd_vma strtab_off = 0;
+ bfd_vma strtab_sz = 0;
+ char *strtab = NULL;
+
+ memset (&fixup, 0, sizeof (fixup));
+ memset (&imgrela, 0, sizeof (imgrela));
+
+ /* Note: the order of the entries is specified by the OpenVMS specs. */
+ for (entry = dynamic_section;
+ entry < dynamic_section + dynamic_nent;
+ entry++)
+ {
+ switch (entry->d_tag)
+ {
+ case DT_IA_64_VMS_STRTAB_OFFSET:
+ strtab_off = entry->d_un.d_val;
+ break;
+ case DT_STRSZ:
+ strtab_sz = entry->d_un.d_val;
+ if (strtab == NULL)
+ strtab = get_data (NULL, file, dynamic_addr + strtab_off,
+ 1, strtab_sz, _("dynamic string section"));
+ break;
+
+ case DT_IA_64_VMS_NEEDED_IDENT:
+ fixup.needed_ident = entry->d_un.d_val;
+ break;
+ case DT_NEEDED:
+ fixup.needed = entry->d_un.d_val;
+ break;
+ case DT_IA_64_VMS_FIXUP_NEEDED:
+ fixup.fixup_needed = entry->d_un.d_val;
+ break;
+ case DT_IA_64_VMS_FIXUP_RELA_CNT:
+ fixup.fixup_rela_cnt = entry->d_un.d_val;
+ break;
+ case DT_IA_64_VMS_FIXUP_RELA_OFF:
+ fixup.fixup_rela_off = entry->d_un.d_val;
+ res++;
+ dump_ia64_vms_dynamic_fixups (file, &fixup, strtab, strtab_sz);
+ break;
+
+ case DT_IA_64_VMS_IMG_RELA_CNT:
+ imgrela.img_rela_cnt = entry->d_un.d_val;
+ break;
+ case DT_IA_64_VMS_IMG_RELA_OFF:
+ imgrela.img_rela_off = entry->d_un.d_val;
+ res++;
+ dump_ia64_vms_dynamic_relocs (file, &imgrela);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if (strtab != NULL)
+ free (strtab);
+
+ return res;
+}
+