aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Smith <dannysmith@users.sourceforge.net>2004-01-20 21:04:19 +0000
committerDanny Smith <dannysmith@users.sourceforge.net>2004-01-20 21:04:19 +0000
commit66bed356fcb5fcae7a2af096b919b99218c28543 (patch)
tree901264c05e107edee810d521099835a559798237
parentd99e9f4d31bc087b7092dfd4b28b2cea8f555903 (diff)
downloadgdb-66bed356fcb5fcae7a2af096b919b99218c28543.zip
gdb-66bed356fcb5fcae7a2af096b919b99218c28543.tar.gz
gdb-66bed356fcb5fcae7a2af096b919b99218c28543.tar.bz2
* peXXigen.c (_bfd_XXi_swap_scnhdr_out): Don't remove
IMAGE_SCN_MEM_WRITE flag from .text section if WP_TEXT flag has been cleared.
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/peXXigen.c18
2 files changed, 19 insertions, 5 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 2330758..6818677 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2004-01-20 Danny Smith <dannysmith@users.sourceforge.net>
+
+ * peXXigen.c (_bfd_XXi_swap_scnhdr_out): Don't remove
+ IMAGE_SCN_MEM_WRITE flag from .text section if WP_TEXT
+ flag has been cleared.
+
2004-01-19 Kazu Hirata <kazu@cs.umass.edu>
* coff-h8300.c: Add and adjust comments about relaxation.
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
index 2fe294f..559f2a2 100644
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -1,5 +1,5 @@
/* Support for the generic parts of PE/PEI; the common executable parts.
- Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+ Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
Free Software Foundation, Inc.
Written by Cygnus Solutions.
@@ -985,13 +985,21 @@ _bfd_XXi_swap_scnhdr_out (abfd, in, out)
pe_required_section_flags * p;
int flags = scnhdr_int->s_flags;
+ /* We have defaulted to adding the IMAGE_SCN_MEM_WRITE flag, but now
+ we know exactly what this specific section wants so we remove it
+ and then allow the must_have field to add it back in if necessary.
+ However, we don't remove IMAGE_SCN_MEM_WRITE flag from .text if the
+ default WP_TEXT file flag has been cleared. WP_TEXT may be cleared
+ by ld --enable-auto-import (if auto-import is actually needed),
+ by ld --omagic, or by obcopy --writable-text. */
+
+ if (strcmp (scnhdr_int->s_name, ".text")
+ || (bfd_get_file_flags (abfd) & WP_TEXT))
+ flags &= ~IMAGE_SCN_MEM_WRITE;
+
for (p = known_sections; p->section_name; p++)
if (strcmp (scnhdr_int->s_name, p->section_name) == 0)
{
- /* We have defaulted to adding the IMAGE_SCN_MEM_WRITE flag, but now
- we know exactly what this specific section wants so we remove it
- and then allow the must_have field to add it back in if necessary. */
- flags &= ~IMAGE_SCN_MEM_WRITE;
flags |= p->must_have;
break;
}