]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Move print_version into printversion.{h|c}
authorUlf Hermann <ulf.hermann@qt.io>
Thu, 16 Feb 2017 11:32:02 +0000 (12:32 +0100)
committerMark Wielaard <mark@klomp.org>
Fri, 17 Feb 2017 09:55:28 +0000 (10:55 +0100)
Rename version.c so that the implementation is called after the header
and the header doesn't clash with the toplevel version.h. print_version
depends on argp and is only used in the tools.

Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
23 files changed:
lib/ChangeLog
lib/Makefile.am
lib/printversion.c [moved from lib/version.c with 96% similarity]
lib/printversion.h [new file with mode: 0644]
lib/system.h
po/ChangeLog
po/POTFILES.in
src/ChangeLog
src/addr2line.c
src/ar.c
src/elfcmp.c
src/elfcompress.c
src/elflint.c
src/findtextrel.c
src/nm.c
src/objdump.c
src/ranlib.c
src/readelf.c
src/size.c
src/stack.c
src/strings.c
src/strip.c
src/unstrip.c

index fd63e0390a7961edfe40c8fd07fd8f905c801bb8..84290f79dd22d59cfd8a3ed1f7d1bec9d6c79f88 100644 (file)
@@ -1,3 +1,16 @@
+2017-02-16  Ulf Hermann  <ulf.hermann@qt.io>
+
+       * Makefile.am (libeu_a_SOURCES): Remove version.c, add printversion.c
+       (noinst_HEADERS): Add printversion.h
+       * version.c: Moved to printversion.c.
+       * printversion.c: New file, moved from version.c,
+       remove stdio.h, argp.h, system.h includes,
+       add printversion.h include.
+       * printversion.h: New file.
+       * system.h: Remove argp.h include,
+       (ARGP_PROGRAM_VERSION_HOOK_DEF, ARGP_PROGRAM_BUG_ADDRESS_DEF): Remove.
+       (print_version): Remove.
+
 2017-02-15  Ulf Hermann  <ulf.hermann@qt.io>
 
        * system.h: Provide mempcpy if it doesn't exist.
index 3e0c601fe28eafcb23c3a95008f2bcbb4d43374c..7a65eb91fe97a266cf81ffc2277e523ef78e84dc 100644 (file)
@@ -35,10 +35,10 @@ noinst_LIBRARIES = libeu.a
 
 libeu_a_SOURCES = xstrdup.c xstrndup.c xmalloc.c next_prime.c \
                  crc32.c crc32_file.c md5.c sha1.c \
-                 color.c version.c
+                 color.c printversion.c
 
 noinst_HEADERS = fixedsizehash.h libeu.h system.h dynamicsizehash.h list.h \
-                md5.h sha1.h eu-config.h color.h
+                md5.h sha1.h eu-config.h color.h printversion.h
 EXTRA_DIST = dynamicsizehash.c
 
 if !GPROF
similarity index 96%
rename from lib/version.c
rename to lib/printversion.c
index b8d70cbf413a523d3e411d8c7aae2df1db696b55..4056b938cfcc5ca42a5ab1f4ac97ab4a483b7846 100644 (file)
 # include <config.h>
 #endif
 
-#include <argp.h>
 #include <libintl.h>
-#include <stdio.h>
-#include "system.h"
+#include "printversion.h"
 
 void
 print_version (FILE *stream, struct argp_state *state)
diff --git a/lib/printversion.h b/lib/printversion.h
new file mode 100644 (file)
index 0000000..a9e059f
--- /dev/null
@@ -0,0 +1,49 @@
+/* Common argp_print_version_hook for all tools.
+   Copyright (C) 2017 The Qt Company Ltd.
+   This file is part of elfutils.
+
+   This file is free software; you can redistribute it and/or modify
+   it under the terms of either
+
+     * the GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 3 of the License, or (at
+       your option) any later version
+
+   or
+
+     * the GNU General Public License as published by the Free
+       Software Foundation; either version 2 of the License, or (at
+       your option) any later version
+
+   or both in parallel, as here.
+
+   elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received copies of the GNU General Public License and
+   the GNU Lesser General Public License along with this program.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef PRINTVERSION_H
+#define PRINTVERSION_H 1
+
+#include <argp.h>
+#include <stdio.h>
+
+/* Defined in version.c.  Common ARGP_PROGRAM_VERSION_HOOK_DEF.  */
+void print_version (FILE *stream, struct argp_state *state);
+
+/* We need define two variables, argp_program_version_hook and
+   argp_program_bug_address, in all programs.  argp.h declares these
+   variables as non-const (which is correct in general).  But we can
+   do better, it is not going to change.  So we want to move them into
+   the .rodata section.  Define macros to do the trick.  */
+#define ARGP_PROGRAM_VERSION_HOOK_DEF \
+  void (*const apvh) (FILE *, struct argp_state *) \
+   __asm ("argp_program_version_hook")
+#define ARGP_PROGRAM_BUG_ADDRESS_DEF \
+  const char *const apba__ __asm ("argp_program_bug_address")
+
+#endif // PRINTVERSION_H
index 429b0c33267fbb27d3b68ed232c1a8c0ce4a6351..2d05702502e4767375974bdfa4bd8de63b1fef75 100644 (file)
@@ -33,7 +33,6 @@
 # include <config.h>
 #endif
 
-#include <argp.h>
 #include <errno.h>
 #include <stddef.h>
 #include <stdint.h>
@@ -145,21 +144,6 @@ pread_retry (int fd, void *buf, size_t len, off_t off)
   return recvd;
 }
 
-
-/* We need define two variables, argp_program_version_hook and
-   argp_program_bug_address, in all programs.  argp.h declares these
-   variables as non-const (which is correct in general).  But we can
-   do better, it is not going to change.  So we want to move them into
-   the .rodata section.  Define macros to do the trick.  */
-#define ARGP_PROGRAM_VERSION_HOOK_DEF \
-  void (*const apvh) (FILE *, struct argp_state *) \
-   __asm ("argp_program_version_hook")
-#define ARGP_PROGRAM_BUG_ADDRESS_DEF \
-  const char *const apba__ __asm ("argp_program_bug_address")
-
-/* Defined in version.c.  Common ARGP_PROGRAM_VERSION_HOOK_DEF.  */
-void print_version (FILE *stream, struct argp_state *state);
-
 /* The demangler from libstdc++.  */
 extern char *__cxa_demangle (const char *mangled_name, char *output_buffer,
                             size_t *length, int *status);
index 38cae02db3779c2d8d0d79b9a860d531784b5cfe..b679f7a0b3d666fcdb11d144b9d71185e9b82073 100644 (file)
@@ -1,3 +1,7 @@
+2017-02-16  Ulf Hermann  <ulf.hermann@qt.io>
+
+       * po/POTFILES.in: Removed lib/version.c, added lib/printversion.c.
+
 2016-12-27  Mark Wielaard  <mark@klomp.org>
 
        * *.po: Update for 0.168.
index dec61ef565d0205a73e87d90a30aae399a5ae8e3..4eac6d09ac613e6e299c7e93364f67bd741709bb 100644 (file)
@@ -3,7 +3,7 @@
 
 # Files from the compatibility library
 lib/color.c
-lib/version.c
+lib/printversion.c
 lib/xmalloc.c
 
 # Library sources
index 19c7dbb7ded2189842ec5ee7aec70be5244a40b6..0601198c57a7d94de306cad575cdccb727d403e5 100644 (file)
@@ -1,3 +1,21 @@
+2017-02-16  Ulf Hermann  <ulf.hermann@qt.io>
+
+       * addr2line.c: Include printversion.h
+       * ar.c: Likewise.
+       * elflint.c: Likewise.
+       * nm.c: Likewise.
+       * objdump.c: Likewise.
+       * ranlib.c: Likewise.
+       * readelf.c: Likewise.
+       * size.c: Likewise.
+       * stack.c: Likewise.
+       * strings.c: Likewise.
+       * strip.c: Likewise.
+       * elfcmp.c: Include printversion.h, remove system.h include.
+       * elfcompress.c: Likewise.
+       * findtextrel.c: Likewise.
+       * unstrip.c: Likewise.
+
 2017-02-14  Ulf Hermann  <ulf.hermann@qt.io>
 
        * nm.c: Include color.h.
index 02220885aeeb3c1d4d3f149dd43cd2af723468d1..ba414a74d424fdbd48095a31af1f73e2fdcadd9b 100644 (file)
@@ -38,6 +38,7 @@
 #include <unistd.h>
 
 #include <system.h>
+#include <printversion.h>
 
 
 /* Name and version of program.  */
index f2f322b70ccb4770ccffc066bbe6e15187898894..ec32cee59c2b7b93fcdbe4a363d23941d8fdf95a 100644 (file)
--- a/src/ar.c
+++ b/src/ar.c
@@ -41,6 +41,7 @@
 #include <sys/time.h>
 
 #include <system.h>
+#include <printversion.h>
 
 #include "arlib.h"
 
index 401ab3157fc600909c1354bd350ad482d5c79bfb..7673cf212c01788be03aed984e4e4eb577b61c4d 100644 (file)
@@ -33,7 +33,7 @@
 #include <string.h>
 #include <unistd.h>
 
-#include <system.h>
+#include <printversion.h>
 #include "../libelf/elf-knowledge.h"
 #include "../libebl/libeblP.h"
 
index 9f6db1cc5626d2617180674873f24ef333e091c3..8e0d5c559c5a9012c82e81adfe0659d8cc71fe70 100644 (file)
@@ -35,7 +35,7 @@
 #include ELFUTILS_HEADER(dwelf)
 #include <gelf.h>
 #include "libeu.h"
-#include "system.h"
+#include "printversion.h"
 
 /* Name and version of program.  */
 ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
index 7d3f2271477437071c3dc7baa0e4195802026669..66a13ca2284eb8991fee94af48c7fdd78c164858 100644 (file)
@@ -39,6 +39,7 @@
 #include <elf-knowledge.h>
 #include <libeu.h>
 #include <system.h>
+#include <printversion.h>
 #include "../libelf/libelfP.h"
 #include "../libelf/common.h"
 #include "../libebl/libeblP.h"
index dc41502bd0dda48c52762383274a4c8b6beb87d8..8f1e239a949eb7203e8ed15a872ad90c4b9da14c 100644 (file)
@@ -36,7 +36,7 @@
 #include <string.h>
 #include <unistd.h>
 
-#include <system.h>
+#include <printversion.h>
 
 
 struct segments
index 47a9e3b176303741eaba886bc41333f6ec9fefa6..969c6d355524601aaade24857f66129cbf1dea07 100644 (file)
--- a/src/nm.c
+++ b/src/nm.c
@@ -45,6 +45,7 @@
 #include <libeu.h>
 #include <system.h>
 #include <color.h>
+#include <printversion.h>
 #include "../libebl/libeblP.h"
 #include "../libdwfl/libdwflP.h"
 
index 030274bc19bf5f3f955d2b9c13bbe0d3a7bbc66e..860cfac6923d6f63b52d875b667e6e1689603e1f 100644 (file)
@@ -36,6 +36,7 @@
 #include <libeu.h>
 #include <system.h>
 #include <color.h>
+#include <printversion.h>
 #include "../libebl/libeblP.h"
 
 
index 41a3bcf25caf921c2533130ff3ef8249fed89a96..cc0ee233872eafba0b43d927c2955d747b7a739e 100644 (file)
@@ -38,6 +38,7 @@
 #include <sys/stat.h>
 
 #include <system.h>
+#include <printversion.h>
 
 #include "arlib.h"
 
index d3a900884b7e65bcc37082383e2ee970ba193a18..8d96ba3f086cf402bf8132eb4f910b41c7b38d38 100644 (file)
@@ -45,6 +45,7 @@
 
 #include <libeu.h>
 #include <system.h>
+#include <printversion.h>
 #include "../libelf/libelfP.h"
 #include "../libelf/common.h"
 #include "../libebl/libeblP.h"
index de0d791bbe50afa4f8fab0753c7ffb4dd2b410ab..ad8dbcbb8342ea93dded6689123950b78e74e5d8 100644 (file)
@@ -36,7 +36,7 @@
 #include <unistd.h>
 
 #include <system.h>
-
+#include <printversion.h>
 
 /* Name and version of program.  */
 ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
index a5a7bebc38bfd78434b5a0f984ee60422fa88871..6f2ff69f88f013416655fe477f91de6cbfa31166 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <dwarf.h>
 #include <system.h>
+#include <printversion.h>
 
 /* Name and version of program.  */
 ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
index 49aab8b0bd8bf430529247e9c88eb21083a65d55..d214356c39cdd4cd18c38fef35a340b74dda07c9 100644 (file)
@@ -42,6 +42,7 @@
 
 #include <libeu.h>
 #include <system.h>
+#include <printversion.h>
 
 #ifndef MAP_POPULATE
 # define MAP_POPULATE 0
index a791ca573dd6295c9b2e92771bf690b86708d5ba..f7474418a045ff6d292b6b1cf3e2fd2a2ed1c08e 100644 (file)
@@ -44,6 +44,7 @@
 #include "libdwelf.h"
 #include <libeu.h>
 #include <system.h>
+#include <printversion.h>
 
 typedef uint8_t GElf_Byte;
 
index d838ae9f895238cd1f50e02701c86d1de26c061b..6e57a6b5f24c0cc2e90538d704727a60da8531d0 100644 (file)
@@ -50,7 +50,7 @@
 #include <libdwfl.h>
 #include "libdwelf.h"
 #include "libeu.h"
-#include "system.h"
+#include "printversion.h"
 
 #ifndef _
 # define _(str) gettext (str)