This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Should the section address be ignored when processing DWARF information ?


Hi Eric, Hi Corinna,

  Does Mach-O need to have the section address added in to the offset
  calculation when processing DWARF information ?

Right now dwarf information is only used in object files which are a single "section", that then the actual sections are offsets within that so unfortunately, yes, it needs the section address added into the offset calculation when processing dwarf in object files.

Darn.


Out of curiosity what is the section offset in the coff/pe files? I would think it would be something similar...

Corinna can probably answer this better than I, but I believe that the dwarf sections in PE files are given addresses after the end of all the other data. (See ld/scripttempl/pe.sc). They do not have the Mach-O problem however, because the offsets are all section relative to the start of the real debug sections, not Mach-O's mega-section.



So - Eric, Corinna - please could you try out the attached, alternative patch ? It changes the value computed for the "address" field of the dwarf_section structure to be 0 for all targets, except the Mach-O. (Well at least that is its intention...) So that in theory the current code in dwarf.c will continue to add in the section address for Mach-O, but no longer use it for Cygwin.


Cheers
  Nick


Index: binutils/objdump.c
===================================================================
RCS file: /cvs/src/src/binutils/objdump.c,v
retrieving revision 1.124
diff -c -3 -p -r1.124 objdump.c
*** binutils/objdump.c	19 Apr 2007 10:43:47 -0000	1.124
--- binutils/objdump.c	20 Apr 2007 12:41:53 -0000
*************** load_debug_section (enum dwarf_section_d
*** 1973,1979 ****
    if (sec == NULL)
      return 0;
  
!   section->address = bfd_get_section_vma (abfd, sec);
    section->size = bfd_get_section_size (sec);
    section->start = xmalloc (section->size);
  
--- 1973,1991 ----
    if (sec == NULL)
      return 0;
  
!   /* Compute a bias to be added to offsets found within the DWARF debug
!      information.  These offsets are meant to be relative to the start of
!      the dwarf section, and hence the bias should be 0.  For MACH-O however
!      a dwarf section is really just a region of a much larger section and so
!      the bias is the address of the start of that area within the larger
!      section.  This test is important for PE and COFF based targets which
!      use DWARF debug information, since unlike ELF, they do not allow the
!      dwarf sections to be placed at address 0.  */
!   if (bfd_get_flavour (abfd) == bfd_target_mach_o_flavour)
!     section->address = bfd_get_section_vma (abfd, sec);
!   else
!     section->address = 0;
!     
    section->size = bfd_get_section_size (sec);
    section->start = xmalloc (section->size);
  

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]