Eric Pouech : winedump: Add support for long section names ( at least used by MinGW).

Alexandre Julliard julliard at winehq.org
Thu Dec 24 10:27:18 CST 2009


Module: wine
Branch: master
Commit: 1c238c77f7679fc2122c07f2e1a05ab0a40f8e6c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=1c238c77f7679fc2122c07f2e1a05ab0a40f8e6c

Author: Eric Pouech <eric.pouech at orange.fr>
Date:   Wed Dec 23 22:05:44 2009 +0100

winedump: Add support for long section names (at least used by MinGW).

---

 tools/winedump/lib.c      |    2 +-
 tools/winedump/pe.c       |   22 ++++++++++++++++++----
 tools/winedump/winedump.h |    2 +-
 3 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/tools/winedump/lib.c b/tools/winedump/lib.c
index 85f305d..de5184a 100644
--- a/tools/winedump/lib.c
+++ b/tools/winedump/lib.c
@@ -88,7 +88,7 @@ static void dump_long_import(const void *base, const IMAGE_SECTION_HEADER *ish,
     for (i = 0; i < num_sect; i++)
     {
         if (globals.do_dumpheader)
-            dump_section(&ish[i]);
+            dump_section(&ish[i], NULL);
 
         if (globals.do_dump_rawdata)
         {
diff --git a/tools/winedump/pe.c b/tools/winedump/pe.c
index a79593c..1f9c5a7 100644
--- a/tools/winedump/pe.c
+++ b/tools/winedump/pe.c
@@ -371,10 +371,14 @@ static	void	dump_pe_header(void)
     dump_optional_header((const IMAGE_OPTIONAL_HEADER32*)&PE_nt_headers->OptionalHeader, PE_nt_headers->FileHeader.SizeOfOptionalHeader);
 }
 
-void dump_section(const IMAGE_SECTION_HEADER *sectHead)
+void dump_section(const IMAGE_SECTION_HEADER *sectHead, const char* strtable)
 {
-	printf("  %-8.8s   VirtSize: 0x%08x  VirtAddr:  0x%08x\n",
-               sectHead->Name, sectHead->Misc.VirtualSize, sectHead->VirtualAddress);
+        if (strtable && sectHead->Name[0] == '/') /* long section name */
+            printf("  %.8s (%s)", sectHead->Name, strtable + atoi((const char*)sectHead->Name + 1));
+        else
+	    printf("  %-8.8s", sectHead->Name);
+	printf("   VirtSize: 0x%08x  VirtAddr:  0x%08x\n",
+               sectHead->Misc.VirtualSize, sectHead->VirtualAddress);
 	printf("    raw data offs:   0x%08x  raw data size: 0x%08x\n",
 	       sectHead->PointerToRawData, sectHead->SizeOfRawData);
 	printf("    relocation offs: 0x%08x  relocations:   0x%08x\n",
@@ -448,11 +452,21 @@ static void dump_sections(const void *base, const void* addr, unsigned num_sect)
 {
     const IMAGE_SECTION_HEADER*	sectHead = addr;
     unsigned			i;
+    const char*                 strtable;
+
+    if (PE_nt_headers->FileHeader.PointerToSymbolTable && PE_nt_headers->FileHeader.NumberOfSymbols)
+    {
+        /* FIXME: no way to get strtable size */
+        strtable = (const char*)base +
+            PE_nt_headers->FileHeader.PointerToSymbolTable +
+            PE_nt_headers->FileHeader.NumberOfSymbols * sizeof(IMAGE_SYMBOL);
+    }
+    else strtable = NULL;
 
     printf("Section Table\n");
     for (i = 0; i < num_sect; i++, sectHead++)
     {
-        dump_section(sectHead);
+        dump_section(sectHead, strtable);
 
         if (globals.do_dump_rawdata)
         {
diff --git a/tools/winedump/winedump.h b/tools/winedump/winedump.h
index 9ad20a5..1f49369 100644
--- a/tools/winedump/winedump.h
+++ b/tools/winedump/winedump.h
@@ -234,7 +234,7 @@ const char*     get_guid_str(const GUID* guid);
 const char*     get_symbol_str(const char* symname);
 void            dump_file_header(const IMAGE_FILE_HEADER *);
 void            dump_optional_header(const IMAGE_OPTIONAL_HEADER32 *, UINT);
-void            dump_section(const IMAGE_SECTION_HEADER *);
+void            dump_section(const IMAGE_SECTION_HEADER *, const char* strtable);
 
 enum FileSig    get_kind_exec(void);
 void            dos_dump( void );




More information about the wine-cvs mailing list