From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14037 invoked by alias); 16 Jan 2003 16:43:15 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 14010 invoked from network); 16 Jan 2003 16:43:02 -0000 Received: from unknown (HELO esds.vss.fsi.com) (66.136.174.212) by sources.redhat.com with SMTP; 16 Jan 2003 16:43:02 -0000 Received: from eos.vss.fsi.com (eos [198.51.27.61]) by esds.vss.fsi.com (8.9.1a/8.9.1) with ESMTP id KAA10659; Thu, 16 Jan 2003 10:43:00 -0600 (CST) Received: from localhost (ford@localhost) by eos.vss.fsi.com (8.11.6+Sun/8.11.6) with ESMTP id h0GGgxR16920; Thu, 16 Jan 2003 10:42:59 -0600 (CST) X-Authentication-Warning: eos.vss.fsi.com: ford owned process doing -bs Date: Thu, 16 Jan 2003 17:51:00 -0000 From: Brian Ford X-X-Sender: ford@eos To: Nick Clifton cc: cygwin@cygwin.com, , , , Subject: Re: Support for DDWARF-2 debug info? (on Cygwin) In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2003-01/txt/msg00761.txt.bz2 On 16 Jan 2003, Nick Clifton wrote: > Hi Brian, > > > My current problem is that all previous DWARF2 implementations > > assign a VMA of zero to the .debug_* sections in the link script. > > This violates the PE format and makes the executable unusable. > > I saw your post about this to the binutils list. > > Does the PE format require that the debugging sections be loaded into > memory when the executable is invoked ? The reason that the ELF > format allows the .debug sections to have a VMA of zero is that they > also do not have the ALLOC flag, so they are not loaded into memory. > (A debugger wanting to access the sections for a running process must > locate the executable on disk an load them/mmap them from there). > No, they do not need to be loaded into memory, and they do not have the ALLOC flag set. But, the PE format requires all sections to be adjacent and in ascending order of VMA. It also specifies debug sections should be last. I think it just tries to load everything up to the fist non-ALLOC section, or so it seams. > > I am still consulting the DWARF2 spec to see if gcc and gas are > > correct in generating VMA addresses. If so, I guess I have to fix > > the dwarf parsing code in bfd and gdb to subtract the section base > > VMA. > > I do not believe that the DWARF2 spec mandates the VMA addresses of > the .debug sections. It does say that their contents must be > contiguous, and it does specify the meaning of their contents, but it > does not specify the meaning of partially-complete .debug sections. > (ie ones attached to relocations that have not yet been resolved). > No, it does not, but I did find out it mandates section relative offsets. So, the dwarf parsing code is correct. It is gcc that has taken a short cut. BTW, these problems are with fully linked executables. >From gcc/dwarf2asm.c:122 /* Output a section-relative reference to a label. In general this can only be done for debugging symbols. E.g. on most targets with the GNU linker, this is accomplished with a direct reference and the knowledge that the debugging section will be placed at VMA 0. Some targets have special relocations for this that we must use. */ void dw2_asm_output_offset VPARAMS ((int size, const char *label, const char *comment, ...)) { VA_OPEN (ap, comment); VA_FIXEDARG (ap, int, size); VA_FIXEDARG (ap, const char *, label); VA_FIXEDARG (ap, const char *, comment); #ifdef ASM_OUTPUT_DWARF_OFFSET ASM_OUTPUT_DWARF_OFFSET (asm_out_file, size, label); #else dw2_assemble_integer (size, gen_rtx_SYMBOL_REF (Pmode, label)); #endif [snip] So, all I need to do is define ASM_OUTPUT_DWARF_OFFSET correctly in gcc/config/i386/cygwin.h. Does anyone have I good way to define a section relative offset in assembly for Cygwin, or do I need to define labels for the sections in the link script as use them? That seems messy. > So, I think it is the case that BFD and GDB are both assuming that the > VMA of the sections will be zero, but that this is not required. > Actually, as stated above, bfd and gdb are correct. The VMA should not be relevant as section relative offsets are specified. -- Brian Ford Senior Realtime Software Engineer VITAL - Visual Simulation Systems FlightSafety International Phone: 314-551-8460 Fax: 314-551-8444