diff options
| author | Jan Beulich <jbeulich@suse.com> | 2025-10-10 15:58:30 +0200 |
|---|---|---|
| committer | Jan Beulich <jbeulich@suse.com> | 2025-10-10 15:58:30 +0200 |
| commit | ef3816215dfa95a298d26bad0be8ccf7cb74153f (patch) | |
| tree | 5a51659c1fd447bed1b35af912717740bd9cc80c | |
| parent | 6e870bea5f3d79a63604e1b5141385e011061df7 (diff) | |
| download | binutils-ef3816215dfa95a298d26bad0be8ccf7cb74153f.zip binutils-ef3816215dfa95a298d26bad0be8ccf7cb74153f.tar.gz binutils-ef3816215dfa95a298d26bad0be8ccf7cb74153f.tar.bz2 | |
bfd / PE/COFF: avoid setting SEC_ALLOC when finding IMAGE_SCN_MEM_DISCARDABLE
Before teaching _bfd_XXi_swap_scnhdr_out() to respect SEC_ALLOC when
considering whether to force IMAGE_SCN_MEM_DISCARDABLE for a section,
make sure we won't "invert" present wrong behavior when transforming an
incoming object's section attributes to an outgoing one's (objcopy or
"ld -r"): Right now, IMAGE_SCN_MEM_DISCARDABLE would appear out of the
blue for certain sections. We don't want the opposite, though, i.e. we
want avoid silently dropping IMAGE_SCN_MEM_DISCARDABLE when it's present
for an incoming object's section.
| -rw-r--r-- | bfd/coffcode.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/bfd/coffcode.h b/bfd/coffcode.h index 4a1f4be..a466af1 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -1347,6 +1347,11 @@ styp_to_sec_flags (bfd *abfd, || startswith (name, ".sdata"))) sec_flags |= SEC_SMALL_DATA; + /* As there is no internal representation of the "discardable" flag, + reflect it by keeping SEC_ALLOC clear. */ + if (internal_s->s_flags & IMAGE_SCN_MEM_DISCARDABLE) + sec_flags &= ~SEC_ALLOC; + #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) /* As a GNU extension, if the name begins with .gnu.linkonce, we only link a single copy of the section. This is used to support |
