This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[patch]: dump of PE+ x64 pdata section
- From: Kai Tietz <ktietz70 at googlemail dot com>
- To: Binutils <binutils at sourceware dot org>
- Date: Thu, 2 Apr 2009 17:35:37 +0200
- Subject: [patch]: dump of PE+ x64 pdata section
Hello,
this patch implements the dumping of .pdata for x64 pe+ target via
bfd_pe_print_pdata. Additional it corrects the display of its content
as the pecoff specification tells.
ChangeLog
2009-04-02 Kai Tietz <kai.tietz@onevision.com>
* coff-x86_64.c (bfd_pe_print_pdata): Define as
_bfd_pep_print_x64_pdata.
* libpei.h (_bfd_pep_print_x64_pdata): New.
* peXXigen.c (_bfd_pep_print_x64_pdata): New.
Tested on i686-pc-cygwin and x86_64-pc-mingw32 without seeing any regressions.
Is this patch ok for apply?
Cheers,
Kai
--
| (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination
Index: src/bfd/coff-x86_64.c
===================================================================
--- src.orig/bfd/coff-x86_64.c
+++ src/bfd/coff-x86_64.c
@@ -711,9 +711,8 @@ coff_amd64_is_local_label_name (bfd *abf
#endif /* TARGET_UNDERSCORE */
-#ifndef bfd_pe_print_pdata
-#define bfd_pe_print_pdata NULL
-#endif
+#undef bfd_pe_print_pdata
+#define bfd_pe_print_pdata _bfd_pep_print_x64_pdata
#include "coffcode.h"
Index: src/bfd/libpei.h
===================================================================
--- src.orig/bfd/libpei.h
+++ src/bfd/libpei.h
@@ -393,4 +393,5 @@ bfd_boolean _bfd_pe_print_ce_compressed_
bfd_boolean _bfd_pe64_print_ce_compressed_pdata (bfd *, void *);
bfd_boolean _bfd_pex64_print_ce_compressed_pdata (bfd *, void *);
bfd_boolean _bfd_pep_print_ce_compressed_pdata (bfd *, void *);
+bfd_boolean _bfd_pep_print_x64_pdata (bfd *, void *);
Index: src/bfd/peXXigen.c
===================================================================
--- src.orig/bfd/peXXigen.c
+++ src/bfd/peXXigen.c
@@ -1894,6 +1894,83 @@ _bfd_XX_print_ce_compressed_pdata (bfd *
return TRUE;
#undef PDATA_ROW_SIZE
}
+
+/* The PE+ x64 variant. */
+bfd_boolean
+_bfd_pep_print_x64_pdata (bfd * abfd, void * vfile)
+{
+# define PDATA_ROW_SIZE (3 * 4)
+ FILE *file = (FILE *) vfile;
+ bfd_byte *data = NULL;
+ asection *section = bfd_get_section_by_name (abfd, ".pdata");
+ bfd_size_type datasize = 0;
+ bfd_size_type i;
+ bfd_size_type start, stop;
+ int onaline = PDATA_ROW_SIZE;
+ struct sym_cache sym_cache = {0, 0} ;
+
+ if (section == NULL
+ || coff_section_data (abfd, section) == NULL
+ || pei_section_data (abfd, section) == NULL)
+ return TRUE;
+
+ stop = pei_section_data (abfd, section)->virt_size;
+ if ((stop % onaline) != 0)
+ fprintf (file,
+ _("Warning, .pdata section size (%ld) is not a multiple of %d\n"),
+ (long) stop, onaline);
+
+ fprintf (file,
+ _("\nThe Function Table (interpreted .pdata section contents)\n"));
+
+ fprintf (file, _("vma:\t\t\tBeginAddress\t EndAddress\t UnwindData\n"));
+
+ datasize = section->size;
+ if (datasize == 0)
+ return TRUE;
+
+ if (! bfd_malloc_and_get_section (abfd, section, &data))
+ {
+ if (data != NULL)
+ free (data);
+ return FALSE;
+ }
+
+ start = 0;
+
+ for (i = start; i < stop; i += onaline)
+ {
+ bfd_vma begin_addr;
+ bfd_vma end_addr;
+ bfd_vma unwind_data_addr;
+
+ if (i + PDATA_ROW_SIZE > stop)
+ break;
+
+ begin_addr = bfd_get_32 (abfd, data + i );
+ end_addr = bfd_get_32 (abfd, data + i + 4);
+ unwind_data_addr = bfd_get_32 (abfd, data + i + 8);
+
+ if (begin_addr == 0 && end_addr == 0 && unwind_data_addr == 0)
+ /* We are probably into the padding of the section now. */
+ break;
+
+ fputc (' ', file);
+ fprintf_vma (file, i + section->vma); fprintf (file, ":\t");
+ fprintf_vma (file, begin_addr); fputc (' ', file);
+ fprintf_vma (file, end_addr); fputc (' ', file);
+ fprintf_vma (file, unwind_data_addr);
+
+ fprintf (file, "\n");
+ }
+
+ free (data);
+
+ cleanup_syms (& sym_cache);
+
+ return TRUE;
+#undef PDATA_ROW_SIZE
+}
#define IMAGE_REL_BASED_HIGHADJ 4
static const char * const tbl[] =