]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
When looking for the text section in a PE executable ignore any
authorTom Hughes <tom@compton.nu>
Wed, 1 Jul 2009 11:59:20 +0000 (11:59 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 1 Jul 2009 11:59:20 +0000 (11:59 +0000)
code section which is marked as uninitialised.

This can happen if you have incremental linking enabled in Visual
Studio, which causes a .textbss section to be added before the real
text section. We were picking up that .textbss section and using it to
compute the avma and bias for the code which was giving completely the
wrong results.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10394

coregrind/m_debuginfo/readpdb.c

index b0682c034e6c1edb53a642946225632a1efd6d5c..88fb7f6731bd65e1d6033be8e250025f218b7e80 100644 (file)
@@ -2117,19 +2117,26 @@ Bool ML_(read_pdb_debug_info)(
              "   ::: mapped_avma is %#lx", mapped_avma);
 
       if (pe_sechdr_avma->Characteristics & IMAGE_SCN_CNT_CODE) {
-         di->have_rx_map = True;
-         if (di->rx_map_avma == 0) {
-            di->rx_map_avma = mapped_avma;
-         }
-         if (di->rx_map_size==0) {
-            di->rx_map_foff = pe_sechdr_avma->PointerToRawData;
-         }
-         di->text_present = True;
-         if (di->text_avma==0) {
-            di->text_avma = mapped_avma;
+         /* Ignore uninitialised code sections - if you have
+            incremental linking enabled in Visual Studio then you will
+            get a uninitialised code section called .textbss before
+            the real text section and valgrind will compute the wrong
+            avma value and hence the wrong bias. */
+         if (!(pe_sechdr_avma->Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA)) {
+            di->have_rx_map = True;
+            if (di->rx_map_avma == 0) {
+               di->rx_map_avma = mapped_avma;
+            }
+            if (di->rx_map_size==0) {
+               di->rx_map_foff = pe_sechdr_avma->PointerToRawData;
+            }
+            di->text_present = True;
+            if (di->text_avma==0) {
+               di->text_avma = mapped_avma;
+            }
+            di->text_size   += pe_sechdr_avma->Misc.VirtualSize;
+            di->rx_map_size += pe_sechdr_avma->Misc.VirtualSize;
          }
-         di->text_size   += pe_sechdr_avma->Misc.VirtualSize;
-         di->rx_map_size += pe_sechdr_avma->Misc.VirtualSize;
       }
       else if (pe_sechdr_avma->Characteristics 
                & IMAGE_SCN_CNT_INITIALIZED_DATA) {