From: Tom Hughes Date: Wed, 1 Jul 2009 11:59:20 +0000 (+0000) Subject: When looking for the text section in a PE executable ignore any X-Git-Tag: svn/VALGRIND_3_5_0~452 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=839cf6c974412f30726cb3f55f613d8222178d3b;p=thirdparty%2Fvalgrind.git When looking for the text section in a PE executable ignore any 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 --- diff --git a/coregrind/m_debuginfo/readpdb.c b/coregrind/m_debuginfo/readpdb.c index b0682c034e..88fb7f6731 100644 --- a/coregrind/m_debuginfo/readpdb.c +++ b/coregrind/m_debuginfo/readpdb.c @@ -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) {