Index: src/bfd/bfd-in2.h =================================================================== --- src.orig/bfd/bfd-in2.h 2009-03-11 11:15:39.000000000 +0100 +++ src/bfd/bfd-in2.h 2009-03-13 10:47:19.447863400 +0100 @@ -1304,6 +1304,10 @@ TMS320C54X only. */ #define SEC_TIC54X_CLINK 0x20000000 + /* Indicate that section has the no read flag set. This happens + when memory read flag isn't set. */ +#define SEC_COFF_NOREAD 0x40000000 + /* End of section flags. */ /* Some internal packed boolean fields. */ Index: src/bfd/coffcode.h =================================================================== --- src.orig/bfd/coffcode.h 2009-03-11 11:15:46.000000000 +0100 +++ src/bfd/coffcode.h 2009-03-13 11:00:12.682238400 +0100 @@ -637,7 +637,7 @@ /* 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_flags = SEC_DEBUGGING | SEC_READONLY; /* skip LOAD */ /* READONLY later */ @@ -666,19 +666,14 @@ /* skip LINK_DUPLICATES */ /* skip LINKER_CREATED */ - if (sec_flags & (SEC_ALLOC | SEC_LOAD)) - { - /* For now, the read/write bits are mapped onto SEC_READONLY, even - though the semantics don't quite match. The bits from the input - are retained in pei_section_data(abfd, section)->pe_flags. */ - styp_flags |= IMAGE_SCN_MEM_READ; /* Always readable. */ - if ((sec_flags & SEC_READONLY) == 0) - styp_flags |= IMAGE_SCN_MEM_WRITE; /* Invert READONLY for write. */ - if (sec_flags & SEC_CODE) - styp_flags |= IMAGE_SCN_MEM_EXECUTE; /* CODE->EXECUTE. */ - if (sec_flags & SEC_COFF_SHARED) - styp_flags |= IMAGE_SCN_MEM_SHARED; /* Shared remains meaningful. */ - } + if ((sec_flags & SEC_COFF_NOREAD) == 0) + styp_flags |= IMAGE_SCN_MEM_READ; /* Invert NOREAD for read. */ + if ((sec_flags & SEC_READONLY) == 0) + styp_flags |= IMAGE_SCN_MEM_WRITE; /* Invert READONLY for write. */ + if (sec_flags & SEC_CODE) + styp_flags |= IMAGE_SCN_MEM_EXECUTE; /* CODE->EXECUTE. */ + if (sec_flags & SEC_COFF_SHARED) + styp_flags |= IMAGE_SCN_MEM_SHARED; /* Shared remains meaningful. */ return styp_flags; } @@ -1117,6 +1112,10 @@ /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ sec_flags = SEC_READONLY; + /* If section disallows read, then set the NOREAD flag. */ + if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) + sec_flags |= SEC_COFF_NOREAD; + /* Process each flag bit in styp_flags in turn. */ while (styp_flags) { @@ -1149,7 +1148,7 @@ break; #endif case IMAGE_SCN_MEM_READ: - /* Ignored, assume it always to be true. */ + sec_flags |= SEC_COFF_NOREAD; break; case IMAGE_SCN_TYPE_NO_PAD: /* Skip. */ @@ -1245,6 +1244,8 @@ sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; #endif + section->flags = sec_flags; + if (flags_ptr) * flags_ptr = sec_flags; Index: src/bfd/section.c =================================================================== --- src.orig/bfd/section.c 2009-03-11 11:14:47.000000000 +0100 +++ src/bfd/section.c 2009-03-13 10:47:37.791613400 +0100 @@ -343,6 +343,10 @@ . TMS320C54X only. *} .#define SEC_TIC54X_CLINK 0x20000000 . +. {* Indicate that section has the no read flag set. This happens +. when memory read flag isn't set. *} +.#define SEC_COFF_NOREAD 0x40000000 +. . {* End of section flags. *} . . {* Some internal packed boolean fields. *}