mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-29 08:24:05 +08:00
bfd: prune COFF/PE section flags setting
It is my understanding that IMAGE_SCN_LNK_* are supposed to communicate information to the (static) linker, and become at best meaningless in PE images. I wouldn't call loaders wrong which would refuse to process sections with any of these bits set. While there's no replacement for IMAGE_SCN_LNK_COMDAT, use IMAGE_SCN_MEM_DISCARDABLE in place of IMAGE_SCN_LNK_REMOVE in this case.
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
2021-03-04 Jan Beulich <jbeulich@suse.com>
|
||||||
|
|
||||||
|
* coffcode.h (sec_to_styp_flags): Don't set IMAGE_SCN_LNK_* in
|
||||||
|
final PE images.
|
||||||
|
|
||||||
2021-03-04 Alan Modra <amodra@gmail.com>
|
2021-03-04 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
* rs6000-core.c (rs6000coff_core_p): Correct prototype.
|
* rs6000-core.c (rs6000coff_core_p): Correct prototype.
|
||||||
|
@ -672,22 +672,31 @@ sec_to_styp_flags (const char *sec_name, flagword sec_flags)
|
|||||||
/* skip ROM */
|
/* skip ROM */
|
||||||
/* skip constRUCTOR */
|
/* skip constRUCTOR */
|
||||||
/* skip CONTENTS */
|
/* skip CONTENTS */
|
||||||
|
#ifndef COFF_IMAGE_WITH_PE
|
||||||
|
/* I don't think any of the IMAGE_SCN_LNK_* flags set below should be set
|
||||||
|
when the output is PE. Only object files should have them, for the linker
|
||||||
|
to consume. */
|
||||||
if ((sec_flags & SEC_IS_COMMON) != 0)
|
if ((sec_flags & SEC_IS_COMMON) != 0)
|
||||||
styp_flags |= IMAGE_SCN_LNK_COMDAT;
|
styp_flags |= IMAGE_SCN_LNK_COMDAT;
|
||||||
|
#endif
|
||||||
if ((sec_flags & SEC_DEBUGGING) != 0)
|
if ((sec_flags & SEC_DEBUGGING) != 0)
|
||||||
styp_flags |= IMAGE_SCN_MEM_DISCARDABLE;
|
styp_flags |= IMAGE_SCN_MEM_DISCARDABLE;
|
||||||
if ((sec_flags & SEC_EXCLUDE) != 0 && !is_dbg)
|
if ((sec_flags & (SEC_EXCLUDE | SEC_NEVER_LOAD)) != 0 && !is_dbg)
|
||||||
styp_flags |= IMAGE_SCN_LNK_REMOVE;
|
#ifdef COFF_IMAGE_WITH_PE
|
||||||
if ((sec_flags & SEC_NEVER_LOAD) != 0 && !is_dbg)
|
styp_flags |= IMAGE_SCN_MEM_DISCARDABLE;
|
||||||
|
#else
|
||||||
styp_flags |= IMAGE_SCN_LNK_REMOVE;
|
styp_flags |= IMAGE_SCN_LNK_REMOVE;
|
||||||
|
#endif
|
||||||
/* skip IN_MEMORY */
|
/* skip IN_MEMORY */
|
||||||
/* skip SORT */
|
/* skip SORT */
|
||||||
|
#ifndef COFF_IMAGE_WITH_PE
|
||||||
if (sec_flags & SEC_LINK_ONCE)
|
if (sec_flags & SEC_LINK_ONCE)
|
||||||
styp_flags |= IMAGE_SCN_LNK_COMDAT;
|
styp_flags |= IMAGE_SCN_LNK_COMDAT;
|
||||||
if ((sec_flags
|
if ((sec_flags
|
||||||
& (SEC_LINK_DUPLICATES_DISCARD | SEC_LINK_DUPLICATES_SAME_CONTENTS
|
& (SEC_LINK_DUPLICATES_DISCARD | SEC_LINK_DUPLICATES_SAME_CONTENTS
|
||||||
| SEC_LINK_DUPLICATES_SAME_SIZE)) != 0)
|
| SEC_LINK_DUPLICATES_SAME_SIZE)) != 0)
|
||||||
styp_flags |= IMAGE_SCN_LNK_COMDAT;
|
styp_flags |= IMAGE_SCN_LNK_COMDAT;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* skip LINKER_CREATED */
|
/* skip LINKER_CREATED */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user