summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlrich Drepper <[email protected]>2009-01-17 11:47:10 -0800
committerUlrich Drepper <[email protected]>2009-01-17 11:47:10 -0800
commitfdc93e12a77866cafd1aae4463d89cef2c01d9b1 (patch)
tree96164f699e204dbc733f3810f7e534fa7265bc8e
parent3a52c7a528e41cc28e69e68ef817f0b2d7f130e5 (diff)
Move argp_program_version_hook and argp_program_bug_address variables
in all programs into the .rodata section.
-rw-r--r--lib/ChangeLog5
-rw-r--r--lib/system.h14
-rw-r--r--src/ChangeLog18
-rw-r--r--src/addr2line.c6
-rw-r--r--src/ar.c5
-rw-r--r--src/elfcmp.c5
-rw-r--r--src/elflint.c5
-rw-r--r--src/findtextrel.c6
-rw-r--r--src/ld.c4
-rw-r--r--src/nm.c4
-rw-r--r--src/objdump.c4
-rw-r--r--src/ranlib.c4
-rw-r--r--src/readelf.c4
-rw-r--r--src/size.c4
-rw-r--r--src/strings.c4
-rw-r--r--src/strip.c4
-rw-r--r--src/unstrip.c5
17 files changed, 70 insertions, 31 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 8791640b..0774524c 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,8 @@
+2009-01-17 Ulrich Drepper <[email protected]>
+
+ * system.h (ARGP_PROGRAM_VERSION_HOOK_DEF): Define.
+ (ARGP_PROGRAM_BUG_ADDRESS_DEF): Define.
+
2009-01-10 Ulrich Drepper <[email protected]>
* eu-config.h: Remove tls_key_t, key_create, getspecific, setspecific,
diff --git a/lib/system.h b/lib/system.h
index 23c666ad..10b4734a 100644
--- a/lib/system.h
+++ b/lib/system.h
@@ -1,5 +1,5 @@
/* Declarations for common convenience functions.
- Copyright (C) 2006 Red Hat, Inc.
+ Copyright (C) 2006, 2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -78,4 +78,16 @@ extern int crc32_file (int fd, uint32_t *resp);
#define pread_retry(fd, buf, len, off) \
TEMP_FAILURE_RETRY (pread (fd, buf, len, off))
+
+/* 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 /* system.h */
diff --git a/src/ChangeLog b/src/ChangeLog
index 4a9b6316..97fd4495 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,21 @@
+2009-01-17 Ulrich Drepper <[email protected]>
+
+ * addr2line.c: Use ARGP_PROGRAM_VERSION_HOOK_DEF and
+ ARGP_PROGRAM_BUG_ADDRESS_DEF.
+ * ar.c: Likewise.
+ * elfcmp.c: Likewise.
+ * elflint.c: Likewise.
+ * findtextrel.c: Likewise.
+ * ld.c: Likewise.
+ * nm.c: Likewise.
+ * objdump.c: Likewise.
+ * ranlib.c: Likewise.
+ * readelf.c: Likewise.
+ * size.c: Likewise.
+ * strings.c: Likewise.
+ * strip.c: Likewise.
+ * unstrip.c: Likewise.
+
2009-01-16 Ulrich Drepper <[email protected]>
* elflint.c (check_program_header): Check that PT_GNU_EH_FRAME entry
diff --git a/src/addr2line.c b/src/addr2line.c
index 7141e269..5a7b0456 100644
--- a/src/addr2line.c
+++ b/src/addr2line.c
@@ -46,13 +46,15 @@
#include <string.h>
#include <unistd.h>
+#include <system.h>
+
/* Name and version of program. */
static void print_version (FILE *stream, struct argp_state *state);
-void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;
+ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
/* Bug report address. */
-const char *argp_program_bug_address = PACKAGE_BUGREPORT;
+ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT;
/* Values for the parameters which have no short form. */
diff --git a/src/ar.c b/src/ar.c
index 961db241..a7a12329 100644
--- a/src/ar.c
+++ b/src/ar.c
@@ -55,7 +55,8 @@
/* Name and version of program. */
static void print_version (FILE *stream, struct argp_state *state);
-void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;
+ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
+
/* Prototypes for local functions. */
static int do_oper_extract (int oper, const char *arfname, char **argv,
int argc, long int instance);
@@ -66,7 +67,7 @@ static int do_oper_insert (int oper, const char *arfname, char **argv,
/* Bug report address. */
-const char *argp_program_bug_address = PACKAGE_BUGREPORT;
+ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT;
/* Definitions of arguments for argp functions. */
diff --git a/src/elfcmp.c b/src/elfcmp.c
index 8903efb1..a1596365 100644
--- a/src/elfcmp.c
+++ b/src/elfcmp.c
@@ -41,6 +41,7 @@
#include <string.h>
#include <unistd.h>
+#include <system.h>
#include "../libelf/elf-knowledge.h"
#include "../libebl/libeblP.h"
@@ -53,10 +54,10 @@ static int regioncompare (const void *p1, const void *p2);
/* Name and version of program. */
static void print_version (FILE *stream, struct argp_state *state);
-void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;
+ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
/* Bug report address. */
-const char *argp_program_bug_address = PACKAGE_BUGREPORT;
+ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT;
/* Values for the parameters which have no short form. */
#define OPT_GAPS 0x100
diff --git a/src/elflint.c b/src/elflint.c
index 35368a5e..1c508c47 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -56,10 +56,10 @@
/* Name and version of program. */
static void print_version (FILE *stream, struct argp_state *state);
-void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;
+ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
/* Bug report address. */
-const char *argp_program_bug_address = PACKAGE_BUGREPORT;
+ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT;
#define ARGP_strict 300
#define ARGP_gnuld 301
@@ -67,7 +67,6 @@ const char *argp_program_bug_address = PACKAGE_BUGREPORT;
/* Definitions of arguments for argp functions. */
static const struct argp_option options[] =
{
-
{ "strict", ARGP_strict, NULL, 0,
N_("Be extremely strict, flag level 2 features."), 0 },
{ "quiet", 'q', NULL, 0, N_("Do not print anything if successful"), 0 },
diff --git a/src/findtextrel.c b/src/findtextrel.c
index 2fd99c96..9d10982f 100644
--- a/src/findtextrel.c
+++ b/src/findtextrel.c
@@ -44,6 +44,8 @@
#include <string.h>
#include <unistd.h>
+#include <system.h>
+
struct segments
{
@@ -54,10 +56,10 @@ struct segments
/* Name and version of program. */
static void print_version (FILE *stream, struct argp_state *state);
-void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;
+ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
/* Bug report address. */
-const char *argp_program_bug_address = PACKAGE_BUGREPORT;
+ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT;
/* Values for the parameters which have no short form. */
#define OPT_DEBUGINFO 0x100
diff --git a/src/ld.c b/src/ld.c
index b4cc6cc7..989bfaba 100644
--- a/src/ld.c
+++ b/src/ld.c
@@ -48,10 +48,10 @@
/* Name and version of program. */
static void print_version (FILE *stream, struct argp_state *state);
-void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;
+ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
/* Bug report address. */
-const char *argp_program_bug_address = PACKAGE_BUGREPORT;
+ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT;
/* Values for the various options. */
diff --git a/src/nm.c b/src/nm.c
index 8b8f547f..8833948a 100644
--- a/src/nm.c
+++ b/src/nm.c
@@ -58,10 +58,10 @@
/* Name and version of program. */
static void print_version (FILE *stream, struct argp_state *state);
-void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;
+ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
/* Bug report address. */
-const char *argp_program_bug_address = PACKAGE_BUGREPORT;
+ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT;
/* Values for the parameters which have no short form. */
diff --git a/src/objdump.c b/src/objdump.c
index 55d3ae2e..7f639410 100644
--- a/src/objdump.c
+++ b/src/objdump.c
@@ -49,10 +49,10 @@
/* Name and version of program. */
static void print_version (FILE *stream, struct argp_state *state);
-void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;
+ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
/* Bug report address. */
-const char *argp_program_bug_address = PACKAGE_BUGREPORT;
+ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT;
/* Definitions of arguments for argp functions. */
diff --git a/src/ranlib.c b/src/ranlib.c
index f456b997..e92dc89b 100644
--- a/src/ranlib.c
+++ b/src/ranlib.c
@@ -58,10 +58,10 @@ static int handle_file (const char *fname);
/* Name and version of program. */
static void print_version (FILE *stream, struct argp_state *state);
-void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;
+ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
/* Bug report address. */
-const char *argp_program_bug_address = PACKAGE_BUGREPORT;
+ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT;
/* Definitions of arguments for argp functions. */
diff --git a/src/readelf.c b/src/readelf.c
index 5d74cb56..a3223eb4 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -61,10 +61,10 @@
/* Name and version of program. */
static void print_version (FILE *stream, struct argp_state *state);
-void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;
+ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
/* Bug report address. */
-const char *argp_program_bug_address = PACKAGE_BUGREPORT;
+ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT;
/* Definitions of arguments for argp functions. */
static const struct argp_option options[] =
diff --git a/src/size.c b/src/size.c
index 9f59cceb..f6f23d55 100644
--- a/src/size.c
+++ b/src/size.c
@@ -50,10 +50,10 @@
/* Name and version of program. */
static void print_version (FILE *stream, struct argp_state *state);
-void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;
+ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
/* Bug report address. */
-const char *argp_program_bug_address = PACKAGE_BUGREPORT;
+ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT;
/* Values for the parameters which have no short form. */
diff --git a/src/strings.c b/src/strings.c
index aebf07bd..b69f2ad2 100644
--- a/src/strings.c
+++ b/src/strings.c
@@ -59,10 +59,10 @@ static int read_elf (Elf *elf, int fd, const char *fname, off64_t fdlen);
/* Name and version of program. */
static void print_version (FILE *stream, struct argp_state *state);
-void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;
+ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
/* Bug report address. */
-const char *argp_program_bug_address = PACKAGE_BUGREPORT;
+ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT;
/* Definitions of arguments for argp functions. */
static const struct argp_option options[] =
diff --git a/src/strip.c b/src/strip.c
index 3ca047af..1958bb51 100644
--- a/src/strip.c
+++ b/src/strip.c
@@ -55,10 +55,10 @@
/* Name and version of program. */
static void print_version (FILE *stream, struct argp_state *state);
-void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;
+ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
/* Bug report address. */
-const char *argp_program_bug_address = PACKAGE_BUGREPORT;
+ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT;
/* Values for the parameters which have no short form. */
diff --git a/src/unstrip.c b/src/unstrip.c
index 4a6fd197..97b73c6f 100644
--- a/src/unstrip.c
+++ b/src/unstrip.c
@@ -64,11 +64,10 @@
/* Name and version of program. */
static void print_version (FILE *stream, struct argp_state *state);
-void (*argp_program_version_hook) (FILE *, struct argp_state *)
- = print_version;
+ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
/* Bug report address. */
-const char *argp_program_bug_address = PACKAGE_BUGREPORT;
+ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT;
/* Definitions of arguments for argp functions. */
static const struct argp_option options[] =