summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2004-04-29 16:40:20 +0000
committerNick Clifton <nickc@redhat.com>2004-04-29 16:40:20 +0000
commitafb831ec020046fb435b5ae0bff638dd5a97e40e (patch)
treeb904d4db6f62813343d6e55f2a09735e268c5434
parent00ef249e28db4e60f6a6272c18d79bf53de0a18e (diff)
downloadgdb-afb831ec020046fb435b5ae0bff638dd5a97e40e.tar.gz
Add support for generating DWARF2 debug sections in the x86 PE port
-rw-r--r--bfd/ChangeLog14
-rw-r--r--bfd/bfd.c8
-rw-r--r--bfd/coffcode.h22
-rw-r--r--bfd/pe-i386.c17
-rw-r--r--bfd/pei-i386.c17
5 files changed, 56 insertions, 22 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 7f26f184ba3..4c3f11b5e90 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,17 @@
+2004-04-29 Brian Ford <ford@vss.fsi.com>
+
+ * bfd.c (bfd_get_sign_extend_vma): Add pe[i]-i386 case to DJGPP hack.
+ * coffcode.h (DOT_DEBUG, GNU_LINKONCE_WI): Define.
+ [!COFF_WITH_PE] (sec_to_styp_flags, styp_to_sec_flags): Use them.
+ (coff_compute_section_file_positions) [RS6000COFF_C]: Likewise.
+ [COFF_WITH_PE] (sec_to_styp_flags): Handle DWARF 2/3 .debug* and
+ .gnu.linkonce.wi. sections.
+ * pe-i386.c (COFF_SUPPORT_GNU_LINKONCE): Define.
+ (COFF_SECTION_ALIGNMENT_ENTRIES): Add entries for .debug and
+ .gnu.linkonce.wi..
+ * pei-i386.c (COFF_SUPPORT_GNU_LINKONCE): Likewise.
+ (COFF_SECTION_ALIGNMENT_ENTRIES): Likewise.
+
2004-04-28 Chris Demetriou <cgd@broadcom.com>
* reloc.c: Remove BFD_RELOC_PCREL_HI16_S and BFD_RELOC_PCREL_LO16.
diff --git a/bfd/bfd.c b/bfd/bfd.c
index c8a60f20d01..199ed1af7aa 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -1,6 +1,6 @@
/* Generic BFD library interface and support routines.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- 2000, 2001, 2002, 2003
+ 2000, 2001, 2002, 2003, 2004
Free Software Foundation, Inc.
Written by Cygnus Support.
@@ -765,12 +765,14 @@ bfd_get_sign_extend_vma (bfd *abfd)
name = bfd_get_target (abfd);
- /* Return a proper value for DJGPP COFF (an x86 COFF variant).
+ /* Return a proper value for DJGPP & PE COFF (x86 COFF variants).
This function is required for DWARF2 support, but there is
no place to store this information in the COFF back end.
Should enough other COFF targets add support for DWARF2,
a place will have to be found. Until then, this hack will do. */
- if (strncmp (name, "coff-go32", sizeof ("coff-go32") - 1) == 0)
+ if (strncmp (name, "coff-go32", sizeof ("coff-go32") - 1) == 0
+ || strcmp (name, "pe-i386") == 0
+ || strcmp (name, "pei-i386") == 0)
return 1;
bfd_set_error (bfd_error_wrong_format);
diff --git a/bfd/coffcode.h b/bfd/coffcode.h
index 15d97093f67..80b5526a4fd 100644
--- a/bfd/coffcode.h
+++ b/bfd/coffcode.h
@@ -1,6 +1,6 @@
/* Support for the generic parts of most COFF variants, for BFD.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- 2000, 2001, 2002, 2003
+ 2000, 2001, 2002, 2003, 2004
Free Software Foundation, Inc.
Written by Cygnus Support.
@@ -309,6 +309,9 @@ CODE_FRAGMENT
#define STRING_SIZE_SIZE (4)
+#define DOT_DEBUG ".debug"
+#define GNU_LINKONCE_WI ".gnu.linkonce.wi."
+
static long sec_to_styp_flags
PARAMS ((const char *, flagword));
static bfd_boolean styp_to_sec_flags
@@ -428,7 +431,7 @@ sec_to_styp_flags (sec_name, sec_flags)
styp_flags = STYP_LIT;
#endif /* _LIT */
}
- else if (!strncmp (sec_name, ".debug", 6))
+ else if (!strncmp (sec_name, DOT_DEBUG, sizeof (DOT_DEBUG) - 1))
{
/* Handle the XCOFF debug section and DWARF2 debug sections. */
if (!sec_name[6])
@@ -441,7 +444,7 @@ sec_to_styp_flags (sec_name, sec_flags)
styp_flags = STYP_DEBUG_INFO;
}
#ifdef COFF_LONG_SECTION_NAMES
- else if (!strncmp (sec_name, ".gnu.linkonce.wi.", 17))
+ else if (!strncmp (sec_name, GNU_LINKONCE_WI, sizeof (GNU_LINKONCE_WI) - 1))
{
styp_flags = STYP_DEBUG_INFO;
}
@@ -518,7 +521,7 @@ sec_to_styp_flags (sec_name, sec_flags)
static long
sec_to_styp_flags (sec_name, sec_flags)
- const char *sec_name ATTRIBUTE_UNUSED;
+ const char *sec_name;
flagword sec_flags;
{
long styp_flags = 0;
@@ -531,6 +534,11 @@ sec_to_styp_flags (sec_name, sec_flags)
PE files. The STYP_* flags and the IMAGE_SCN_* flags overlap,
but there are more IMAGE_SCN_* flags. */
+ /* FIXME: There is no gas syntax to specify the debug section flag. */
+ if (strncmp (sec_name, DOT_DEBUG, sizeof (DOT_DEBUG) - 1) == 0
+ || strncmp (sec_name, GNU_LINKONCE_WI, sizeof (GNU_LINKONCE_WI) - 1) == 0)
+ sec_flags = SEC_READONLY | SEC_DEBUGGING;
+
/* skip LOAD */
/* READONLY later */
/* skip RELOC */
@@ -675,12 +683,12 @@ styp_to_sec_flags (abfd, hdr, name, section, flags_ptr)
#endif
sec_flags |= SEC_ALLOC;
}
- else if (strncmp (name, ".debug", 6) == 0
+ else if (strncmp (name, DOT_DEBUG, sizeof (DOT_DEBUG) - 1) == 0
#ifdef _COMMENT
|| strcmp (name, _COMMENT) == 0
#endif
#ifdef COFF_LONG_SECTION_NAMES
- || strncmp (name, ".gnu.linkonce.wi.", 17) == 0
+ || strncmp (name, GNU_LINKONCE_WI, sizeof (GNU_LINKONCE_WI) - 1) == 0
#endif
|| strncmp (name, ".stab", 5) == 0)
{
@@ -3004,7 +3012,7 @@ coff_compute_section_file_positions (abfd)
{
asection *dsec;
- dsec = bfd_make_section_old_way (abfd, ".debug");
+ dsec = bfd_make_section_old_way (abfd, DOT_DEBUG);
if (dsec == NULL)
abort ();
dsec->_raw_size = sz;
diff --git a/bfd/pe-i386.c b/bfd/pe-i386.c
index a912cffd998..be691fd7eeb 100644
--- a/bfd/pe-i386.c
+++ b/bfd/pe-i386.c
@@ -1,5 +1,5 @@
/* BFD back-end for Intel 386 PECOFF files.
- Copyright 1995, 1996, 1999, 2001, 2002 Free Software Foundation, Inc.
+ Copyright 1995, 1996, 1999, 2001, 2002, 2004 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
@@ -20,12 +20,13 @@
#include "bfd.h"
#include "sysdep.h"
-#define TARGET_SYM i386pe_vec
-#define TARGET_NAME "pe-i386"
+#define TARGET_SYM i386pe_vec
+#define TARGET_NAME "pe-i386"
#define COFF_WITH_PE
-#define PCRELOFFSET TRUE
-#define TARGET_UNDERSCORE '_'
+#define PCRELOFFSET TRUE
+#define TARGET_UNDERSCORE '_'
#define COFF_LONG_SECTION_NAMES
+#define COFF_SUPPORT_GNU_LINKONCE
#define COFF_LONG_FILENAMES
#define COFF_SECTION_ALIGNMENT_ENTRIES \
@@ -38,6 +39,10 @@
{ COFF_SECTION_NAME_PARTIAL_MATCH (".idata"), \
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
{ COFF_SECTION_NAME_EXACT_MATCH (".pdata"), \
- COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
+{ COFF_SECTION_NAME_PARTIAL_MATCH (".debug"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \
+{ COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
#include "coff-i386.c"
diff --git a/bfd/pei-i386.c b/bfd/pei-i386.c
index 63a63a84839..4a59f143ad0 100644
--- a/bfd/pei-i386.c
+++ b/bfd/pei-i386.c
@@ -1,5 +1,5 @@
/* BFD back-end for Intel 386 PE IMAGE COFF files.
- Copyright 1995, 1996, 1999, 2002 Free Software Foundation, Inc.
+ Copyright 1995, 1996, 1999, 2002, 2004 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
@@ -20,13 +20,14 @@
#include "bfd.h"
#include "sysdep.h"
-#define TARGET_SYM i386pei_vec
-#define TARGET_NAME "pei-i386"
+#define TARGET_SYM i386pei_vec
+#define TARGET_NAME "pei-i386"
#define COFF_IMAGE_WITH_PE
#define COFF_WITH_PE
-#define PCRELOFFSET TRUE
-#define TARGET_UNDERSCORE '_'
+#define PCRELOFFSET TRUE
+#define TARGET_UNDERSCORE '_'
#define COFF_LONG_SECTION_NAMES
+#define COFF_SUPPORT_GNU_LINKONCE
#define COFF_LONG_FILENAMES
#define COFF_SECTION_ALIGNMENT_ENTRIES \
@@ -39,6 +40,10 @@
{ COFF_SECTION_NAME_PARTIAL_MATCH (".idata"), \
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
{ COFF_SECTION_NAME_EXACT_MATCH (".pdata"), \
- COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
+{ COFF_SECTION_NAME_PARTIAL_MATCH (".debug"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \
+{ COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
#include "coff-i386.c"