public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Binutils <binutils@sourceware.org>
Cc: Dave Korn <dave.korn.cygwin@gmail.com>
Subject: [PATCH 4/5] COFF/PE: keep linker version during objcopy / strip
Date: Fri, 6 May 2022 08:55:19 +0200	[thread overview]
Message-ID: <be4dba87-1671-507a-c396-280d8de6b952@suse.com> (raw)
In-Reply-To: <4242b48a-f2c3-4af2-db1e-35dbbbdc1b2e@suse.com>

Neither of the tools is really a linker, so whatever was originally
recorded should be retained rather than being overwritten by these
tools' versions.

--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -736,13 +736,23 @@ _bfd_XXi_swap_aouthdr_out (bfd * abfd, v
 
   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);


  parent reply	other threads:[~2022-05-06  6:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-06  6:53 [PATCH 0/5] PE/COFF: assorted adjustments Jan Beulich
2022-05-06  6:54 ` [PATCH 1/5] don't over-align file positions of PE executable sections Jan Beulich
2022-05-06  6:54 ` [PATCH 2/5] COFF: make objcopy / strip honor --keep-file-symbols Jan Beulich
2022-05-06  6:54 ` [PATCH 3/5] COFF/PE: don't leave zero timestamp after objcopy / strip Jan Beulich
2022-05-06  6:55 ` Jan Beulich [this message]
2022-05-06  6:55 ` [PATCH 5/5] COFF: use hash for string table also when copying / stripping Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=be4dba87-1671-507a-c396-280d8de6b952@suse.com \
    --to=jbeulich@suse.com \
    --cc=binutils@sourceware.org \
    --cc=dave.korn.cygwin@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).