aboutsummaryrefslogtreecommitdiff
path: root/bfd/peXXigen.c
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2022-05-19 12:44:56 +0200
committerJan Beulich <jbeulich@suse.com>2022-05-19 12:44:56 +0200
commitf0a53c9c89316a0e362fd671f566f453e451b21c (patch)
tree1438abcf5f234c7a8f1ec19a3b4d3476f7c1b1c8 /bfd/peXXigen.c
parent6db1e45d7b85634679bc6dedf4e4a2c78fed74d4 (diff)
downloadgdb-f0a53c9c89316a0e362fd671f566f453e451b21c.zip
gdb-f0a53c9c89316a0e362fd671f566f453e451b21c.tar.gz
gdb-f0a53c9c89316a0e362fd671f566f453e451b21c.tar.bz2
COFF/PE: keep linker version during objcopy / strip
Neither of the tools is really a linker, so whatever was originally recorded should be retained rather than being overwritten by these tools' versions.
Diffstat (limited to 'bfd/peXXigen.c')
-rw-r--r--bfd/peXXigen.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
index 50e4fac..5ab0938 100644
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -736,13 +736,23 @@ _bfd_XXi_swap_aouthdr_out (bfd * abfd, void * in, void * out)
H_PUT_16 (abfd, aouthdr_in->magic, aouthdr_out->standard.magic);
+ if (extra->MajorLinkerVersion || extra->MinorLinkerVersion)
+ {
+ H_PUT_8 (abfd, extra->MajorLinkerVersion,
+ aouthdr_out->standard.vstamp);
+ H_PUT_8 (abfd, extra->MinorLinkerVersion,
+ aouthdr_out->standard.vstamp + 1);
+ }
+ else
+ {
/* e.g. 219510000 is linker version 2.19 */
#define LINKER_VERSION ((short) (BFD_VERSION / 1000000))
- /* This piece of magic sets the "linker version" field to
- LINKER_VERSION. */
- H_PUT_16 (abfd, (LINKER_VERSION / 100 + (LINKER_VERSION % 100) * 256),
- aouthdr_out->standard.vstamp);
+ /* This piece of magic sets the "linker version" field to
+ LINKER_VERSION. */
+ H_PUT_16 (abfd, (LINKER_VERSION / 100 + (LINKER_VERSION % 100) * 256),
+ aouthdr_out->standard.vstamp);
+ }
PUT_AOUTHDR_TSIZE (abfd, aouthdr_in->tsize, aouthdr_out->standard.tsize);
PUT_AOUTHDR_DSIZE (abfd, aouthdr_in->dsize, aouthdr_out->standard.dsize);