|
From: <sv...@va...> - 2009-07-01 12:00:28
|
Author: tom
Date: 2009-07-01 12:59:20 +0100 (Wed, 01 Jul 2009)
New Revision: 10394
Log:
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.
Modified:
trunk/coregrind/m_debuginfo/readpdb.c
Modified: trunk/coregrind/m_debuginfo/readpdb.c
===================================================================
--- trunk/coregrind/m_debuginfo/readpdb.c 2009-07-01 08:12:22 UTC (rev 10393)
+++ trunk/coregrind/m_debuginfo/readpdb.c 2009-07-01 11:59:20 UTC (rev 10394)
@@ -2117,19 +2117,26 @@
" ::: 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;
+ /* 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;
}
- 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;
}
else if (pe_sechdr_avma->Characteristics
& IMAGE_SCN_CNT_INITIALIZED_DATA) {
|