BFD patch for linker version stamp This patch enables real version stamp into produced PE binaries. The PE version of the linker have injected the linker version "2.56" into all produced binaries since beginning of time. This makes it impossible to judge status of the tools that produced an unknown binary. A correct linker version stamp could help debugging tools, security and binary information tools. Index: bfd/peXXigen.c =================================================================== RCS file: /cvs/src/src/bfd/peXXigen.c,v retrieving revision 1.46 diff -w -b -B -u -p -r1.46 peXXigen.c --- bfd/peXXigen.c 30 Jul 2008 04:34:56 -0000 1.46 +++ bfd/peXXigen.c 27 Feb 2009 23:15:53 -0000 @@ -664,15 +669,21 @@ _bfd_XXi_swap_aouthdr_out (bfd * abfd, v extra->SizeOfHeaders = hsize; extra->SizeOfImage = isize; } H_PUT_16 (abfd, aouthdr_in->magic, aouthdr_out->standard.magic); +#ifdef BFD_VERSION_MAJOR +/* Version assignment in configure like Python or Gnome, gets defined in config.h + MajorLinkerVersion.MinorLinkerVersion e.g. 2.19 */ + bfd_h_put_8 (abfd, BFD_VERSION_MAJOR, aouthdr_out->standard.vstamp[0]); + bfd_h_put_8 (abfd, BFD_VERSION_MINOR, aouthdr_out->standard.vstamp[1]); +#else #define LINKER_VERSION 256 /* That is, 2.56 */ - - /* This piece of magic sets the "linker version" field to - LINKER_VERSION. */ +/* 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); +#endif PUT_AOUTHDR_TSIZE (abfd, aouthdr_in->tsize, aouthdr_out->standard.tsize); PUT_AOUTHDR_DSIZE (abfd, aouthdr_in->dsize, aouthdr_out->standard.dsize); Index: bfd/configure.in =================================================================== RCS file: /cvs/src/src/bfd/configure.in,v retrieving revision 1.254 diff -w -b -B -u -p -r1.254 configure.in --- bfd/configure.in 3 Feb 2009 15:53:58 -0000 1.254 +++ bfd/configure.in 28 Feb 2009 00:25:24 -0000 @@ -1,6 +1,14 @@ dnl Process this file with autoconf to produce a configure script. dnl +m4_define([bfd_version_major], [2]) +m4_define([bfd_version_minor], [19]) +m4_define([bfd_version_release], [0]) +m4_define([bfd_version_build], [51]) # Intermediate version number e.g. repro no +m4_define([bfd_version_beta], [1]) # True(1) if beta +m4_define([bfd_full_version], [bfd_version_major.bfd_version_minor.bfd_version_build]) +m4_define([bfd_version_comment], ["development source from cvs"]) + AC_PREREQ(2.59) AC_INIT AC_CONFIG_SRCDIR([libbfd.c]) @@ -8,13 +16,29 @@ AC_CONFIG_SRCDIR([libbfd.c]) AC_CANONICAL_TARGET AC_ISC_POSIX -AM_INIT_AUTOMAKE(bfd, 2.19.51) +AM_INIT_AUTOMAKE(bfd, [bfd_full_version]) dnl These must be called before LT_INIT, because it may want dnl to call AC_CHECK_PROG. AC_CHECK_TOOL(AR, ar) AC_CHECK_TOOL(RANLIB, ranlib, :) +dnl version macros +AC_DEFINE([BFD_VERSION_MAJOR], [bfd_version_major], + [The major version number of this release]) +AC_DEFINE([BFD_VERSION_MINOR], [bfd_version_minor], + [The minor version number of this release]) +AC_DEFINE([BFD_VERSION_RELEASE], [bfd_version_release], + [The release version number of this release]) +AC_DEFINE([BFD_VERSION_BUILD], [bfd_version_build], + [The build version number of this release - official release = 0, otherwise repro no]) +AC_DEFINE([BFD_VERSION_BETA], [bfd_version_beta], + [Whether this is a beta release - TRUE(1) or FALSE(0)]) +AC_DEFINE([BFD_VERSION_BUILD_COMMENT], [bfd_version_comment], + [Maintainer's or builder's comment to describe features of this particular build]) +dnl Note the build host in config.h +AC_DEFINE_UNQUOTED(BFD_BUILD_HOST,"$host",[Build host information.]) + dnl Default to a non shared library. This may be overridden by the dnl configure option --enable-shared. AC_DISABLE_SHARED