diff options
author | Kai Tietz <kai.tietz@onevision.com> | 2010-09-22 14:19:35 +0000 |
---|---|---|
committer | Kai Tietz <kai.tietz@onevision.com> | 2010-09-22 14:19:35 +0000 |
commit | 72e4db75e816964c7533b8522a59ec05b7439691 (patch) | |
tree | 2386bc56c508112d6c5cf9140744c3ad7d120f02 | |
parent | fccd1d1e5f52fe58263f77522339067e2a6064c8 (diff) | |
download | gdb-72e4db75e816964c7533b8522a59ec05b7439691.zip gdb-72e4db75e816964c7533b8522a59ec05b7439691.tar.gz gdb-72e4db75e816964c7533b8522a59ec05b7439691.tar.bz2 |
2010-09-22 Kai Tietz <kai.tietz@onevision.com>
* coffcode.h (sec_to_styp_flags): Adjust debug
sections to be conform to pe-coff specification
and avoid marking them as excluded.
(styp_to_sec_flags): Doing reverse mapping.
-rw-r--r-- | bfd/ChangeLog | 5 | ||||
-rw-r--r-- | bfd/coffcode.h | 45 |
2 files changed, 36 insertions, 14 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index c2cd439..56e2f12 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,10 @@ 2010-09-22 Kai Tietz <kai.tietz@onevision.com> + * coffcode.h (sec_to_styp_flags): Adjust debug + sections to be conform to pe-coff specification + and avoid marking them as excluded. + (styp_to_sec_flags): Doing reverse mapping. + * peXXigen.c (_bfd_XXi_final_link_postscript): Add handling for setting IAT directory entry. diff --git a/bfd/coffcode.h b/bfd/coffcode.h index 790908a..ff69704 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -636,6 +636,14 @@ static long sec_to_styp_flags (const char *sec_name, flagword sec_flags) { long styp_flags = 0; + bfd_boolean is_dbg = FALSE; + + if (CONST_STRNEQ (sec_name, DOT_DEBUG) +#ifdef COFF_LONG_SECTION_NAMES + || CONST_STRNEQ (sec_name, GNU_LINKONCE_WI) +#endif + || CONST_STRNEQ (sec_name, ".stab")) + is_dbg = TRUE; /* caution: there are at least three groups of symbols that have very similar bits and meanings: IMAGE_SCN*, SEC_*, and STYP_*. @@ -646,16 +654,15 @@ sec_to_styp_flags (const char *sec_name, flagword sec_flags) but there are more IMAGE_SCN_* flags. */ /* FIXME: There is no gas syntax to specify the debug section flag. */ - if (CONST_STRNEQ (sec_name, DOT_DEBUG) - || CONST_STRNEQ (sec_name, GNU_LINKONCE_WI)) - sec_flags = SEC_DEBUGGING | SEC_READONLY; + if (is_dbg) + sec_flags = SEC_DEBUGGING | SEC_READONLY; /* skip LOAD */ /* READONLY later */ /* skip RELOC */ if ((sec_flags & SEC_CODE) != 0) styp_flags |= IMAGE_SCN_CNT_CODE; - if ((sec_flags & SEC_DATA) != 0) + if ((sec_flags & (SEC_DATA | SEC_DEBUGGING)) != 0) styp_flags |= IMAGE_SCN_CNT_INITIALIZED_DATA; if ((sec_flags & SEC_ALLOC) != 0 && (sec_flags & SEC_LOAD) == 0) styp_flags |= IMAGE_SCN_CNT_UNINITIALIZED_DATA; /* ==STYP_BSS */ @@ -666,9 +673,9 @@ sec_to_styp_flags (const char *sec_name, flagword sec_flags) styp_flags |= IMAGE_SCN_LNK_COMDAT; if ((sec_flags & SEC_DEBUGGING) != 0) styp_flags |= IMAGE_SCN_MEM_DISCARDABLE; - if ((sec_flags & SEC_EXCLUDE) != 0) + if ((sec_flags & SEC_EXCLUDE) != 0 && !is_dbg) styp_flags |= IMAGE_SCN_LNK_REMOVE; - if ((sec_flags & SEC_NEVER_LOAD) != 0) + if ((sec_flags & SEC_NEVER_LOAD) != 0 && !is_dbg) styp_flags |= IMAGE_SCN_LNK_REMOVE; /* skip IN_MEMORY */ /* skip SORT */ @@ -1120,7 +1127,14 @@ styp_to_sec_flags (bfd *abfd, long styp_flags = internal_s->s_flags; flagword sec_flags; bfd_boolean result = TRUE; + bfd_boolean is_dbg = FALSE; + if (CONST_STRNEQ (name, DOT_DEBUG) +#ifdef COFF_LONG_SECTION_NAMES + || CONST_STRNEQ (name, GNU_LINKONCE_WI) +#endif + || CONST_STRNEQ (name, ".stab")) + is_dbg = TRUE; /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ sec_flags = SEC_READONLY; @@ -1190,27 +1204,30 @@ styp_to_sec_flags (bfd *abfd, mean that a given section contains debug information. Thus we only set the SEC_DEBUGGING flag on sections that we recognise as containing debug information. */ - if (CONST_STRNEQ (name, DOT_DEBUG) + if (is_dbg #ifdef _COMMENT || strcmp (name, _COMMENT) == 0 #endif -#ifdef COFF_LONG_SECTION_NAMES - || CONST_STRNEQ (name, GNU_LINKONCE_WI) -#endif - || CONST_STRNEQ (name, ".stab")) - sec_flags |= SEC_DEBUGGING; + ) + { + sec_flags |= SEC_DEBUGGING | SEC_READONLY; + } break; case IMAGE_SCN_MEM_SHARED: sec_flags |= SEC_COFF_SHARED; break; case IMAGE_SCN_LNK_REMOVE: - sec_flags |= SEC_EXCLUDE; + if (!is_dbg) + sec_flags |= SEC_EXCLUDE; break; case IMAGE_SCN_CNT_CODE: sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; break; case IMAGE_SCN_CNT_INITIALIZED_DATA: - sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; + if (is_dbg) + sec_flags |= SEC_DEBUGGING; + else + sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; break; case IMAGE_SCN_CNT_UNINITIALIZED_DATA: sec_flags |= SEC_ALLOC; |