This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
NOLOAD section attribute results in incorrect debug information
- From: "Ina Pandit" <Ina dot Pandit at kpitcummins dot com>
- To: <binutils at sourceware dot org>
- Date: Wed, 7 Nov 2007 14:52:09 +0530
- Subject: NOLOAD section attribute results in incorrect debug information
Hi,
We have built toolchains for H8/SH targets using
binutils-2.17.90 (20070806), gcc-4.2.1 and newlib-1.15.0 sources.
During our internal testing we found a problem in the GNU Linker.
When a user defined section with NOLOAD attribute is used in the
application, the debugging information generated is not correct.
The ".debug_info" section is incomplete and incorrect.
Hence it is not possible to debug the application properly.
The test case below, demonstrates the problem:
//////////// C Program - t.c ////////////
int j __attribute__((section ("dont_load")));
int main(void)
{
return 0;
}
////////////////////////////////////////////
////////////// Linker script ///////////////
SECTIONS
{
.text 0x00000800 :
{
*(.text)
*(.text.*)
}
.dont_load 0x00FFF000 (NOLOAD) :
{
*(dont_load)
}
}
////////////////////////////////////////////
Commands used:
sh-elf-gcc t.c -Tscript -g -g2 -nostartfiles
sh-elf-readelf -w a.out > dmp
The "dmp" file shows that ".debug_info" section is incomplete
and incorrect.
//////////// .debug_info section //////////
Compilation Unit @ offset 0x0:
Length: 168
Version: 2
Abbrev Offset: 0
Pointer Size: 4
<0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
< c> DW_AT_producer : GNU C 4.2-GNUSH_v0703
<22> DW_AT_language : 1 (ANSI C)
<23> DW_AT_name : t.c
<27> DW_AT_comp_dir : <- Missing
<28> DW_AT_low_pc : 0x72 <- Incorrect-should be 0x800
<2c> DW_AT_high_pc : 0x6f677261 <- Incorrect-should be 0x810
<30> DW_AT_stmt_list : 0x6d204669 <- Incorrect-should be 0
<1><34>: Abbrev Number: 108
////////////////////////////////////////////
The following debugging information entries are also missing:
1. DW_TAG_subprogram
2. DW_TAG_base_type
3. DW_TAG_variable
Please note that correct debug information is present in the
object file. After linking, the information generated
is incorrect.
Please note that this problem was not present in
binutils-2.17.50(20070417).
After investigating further, we found that reverting the
following patch from binutils, solves the problem.
http://sourceware.org/ml/binutils-cvs/2007-05/msg00158.html
However, to revert the above mentioned patch, we had to revert
the patches mentioned below as well,
1. http://sourceware.org/ml/binutils-cvs/2007-06/msg00115.html
2. http://sourceware.org/ml/binutils-cvs/2007-06/msg00114.html
The problem exists in binutils 2.18 as well.
Any help on this will be appreciated.
Regards,
Ina Pandit
KPIT Cummins InfoSystems Ltd.
Pune, India
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Free download of GNU based tool-chains for Renesas' SH, H8, R8C, M16C
and M32C Series. The following site also offers free technical support
to its users. Visit http://www.kpitgnutools.com for details.
Latest versions of KPIT GNU tools were released on October 1, 2007.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~