]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
bfd/PE: respect SEC_ALLOC when deciding whether to force IMAGE_SCN_MEM_DISCARDABLE
authorJan Beulich <jbeulich@suse.com>
Fri, 10 Oct 2025 14:02:50 +0000 (16:02 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 10 Oct 2025 14:02:50 +0000 (16:02 +0200)
commit8c41c5e09dbfe74e71a19c57e14472ba17ccd7ef
tree698fa33c9879da38278db9eee30267580c2d394f
parent6b7bbb694201d7450258080d4fa9b759c27be50e
bfd/PE: respect SEC_ALLOC when deciding whether to force IMAGE_SCN_MEM_DISCARDABLE

While in the common case sections like .reloc don't need to be accessed
by a binary (that's the job of the loader), there are rare cases where
the situation is different. Unconditionally forcing the discardable flag
is therefore unhelpful. Avoid doing so when SEC_ALLOC is set, which
would in particular be the case when .reloc isn't (solely) linker-
generated.

While adjusting the comment, drop the wrong (stale?) following sentence:
.rsrc, as per its table entry, doesn't need to be writable. And
commenting on it wanting to be readable would then need to be repeated
for all other sections as well.
bfd/peXXigen.c
gas/testsuite/gas/pe/pe.exp
gas/testsuite/gas/pe/reloc.d [new file with mode: 0644]
gas/testsuite/gas/pe/reloc.s [new file with mode: 0644]
ld/testsuite/ld-pe/pe.exp
ld/testsuite/ld-pe/reloc2.s [new file with mode: 0644]
ld/testsuite/ld-pe/reloc2a.d [new file with mode: 0644]
ld/testsuite/ld-pe/reloc2b.d [new file with mode: 0644]
ld/testsuite/ld-pe/reloc2c.d [new file with mode: 0644]