[PATCH] Define VERSYMIDX/VALIDX/ADDRIDX in include/elf.h
H.J. Lu
hjl.tools@gmail.com
Fri Sep 28 16:46:00 GMT 2012
Hi,
We define the same VERSYMIDX/VALIDX/ADDRIDX macros all over the places.
This patch defines them in include/elf.h and removes the rest. I also
enclosed patches for arm and mips. Tested on x86-64 and ia32. OK to
install?
Thanks.
H.J.
---
ChangeLog | 16 ++++++++++++++++
elf/dl-runtime.c | 4 ----
elf/dl-version.c | 5 -----
elf/do-rel.h | 8 --------
elf/dynamic-link.h | 4 ----
elf/rtld.c | 9 ---------
include/elf.h | 6 ++++++
sysdeps/sparc/sparc32/dl-machine.h | 5 -----
sysdeps/sparc/sparc64/dl-machine.h | 5 -----
sysdeps/x86_64/dl-tlsdesc.h | 6 ------
10 files changed, 22 insertions(+), 46 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c277677..f906b16 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2012-09-28 H.J. Lu <hongjiu.lu@intel.com>
+
+ * elf/dl-runtime.c (VERSYMIDX): Removed.
+ * elf/dl-version.c (VERSYMIDX): Likewise.
+ * elf/do-rel.h (VERSYMIDX): Likewise.
+ (VALIDX): Likewise.
+ * elf/dynamic-link.h (VERSYMIDX): Likewise.
+ * elf/rtld.c (VALIDX): Likewise.
+ (ADDRIDX): Likewise.
+ * include/elf.h (VERSYMIDX): New macro.
+ (VALIDX): Likewise.
+ (ADDRIDX): Likewise.
+ * sysdeps/sparc/sparc32/dl-machine.h (VALIDX): Likewise.
+ * sysdeps/sparc/sparc64/dl-machine.h (VALIDX): Likewise.
+ * sysdeps/x86_64/dl-tlsdesc.h (ADDRIDX): Likewise.
+
2012-09-28 Siddhesh Poyarekar <siddhesh@redhat.com>
[BZ #5298]
diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
index fdaa364..2e02a21 100644
--- a/elf/dl-runtime.c
+++ b/elf/dl-runtime.c
@@ -36,10 +36,6 @@
# define PLTREL ElfW(Rel)
#endif
-#ifndef VERSYMIDX
-# define VERSYMIDX(sym) (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGIDX (sym))
-#endif
-
/* The fixup functions might have need special attributes. If none
are provided define the macro as empty. */
#ifndef ARCH_FIXUP_ATTRIBUTE
diff --git a/elf/dl-version.c b/elf/dl-version.c
index af7f899..b2ebb16 100644
--- a/elf/dl-version.c
+++ b/elf/dl-version.c
@@ -28,11 +28,6 @@
#include <assert.h>
-#ifndef VERSYMIDX
-# define VERSYMIDX(tag) (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGIDX (tag))
-#endif
-
-
#define make_string(string, rest...) \
({ \
const char *all[] = { string, ## rest }; \
diff --git a/elf/do-rel.h b/elf/do-rel.h
index 10d8f31..272b782 100644
--- a/elf/do-rel.h
+++ b/elf/do-rel.h
@@ -32,14 +32,6 @@
(void *) (l_addr + relative->r_offset))
#endif
-#ifndef VERSYMIDX
-# define VERSYMIDX(sym) (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGIDX (sym))
-#endif
-#ifndef VALIDX
-# define VALIDX(tag) (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM \
- + DT_EXTRANUM + DT_VALTAGIDX (tag))
-#endif
-
/* Perform the relocations in MAP on the running program image as specified
by RELTAG, SZTAG. If LAZY is nonzero, this is the first pass on PLT
relocations; they should be set up to call _dl_runtime_resolve, rather
diff --git a/elf/dynamic-link.h b/elf/dynamic-link.h
index e1ec01f..bdf7497 100644
--- a/elf/dynamic-link.h
+++ b/elf/dynamic-link.h
@@ -88,10 +88,6 @@ elf_machine_lazy_rel (struct link_map *map,
#include <dl-machine.h>
-#ifndef VERSYMIDX
-# define VERSYMIDX(sym) (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGIDX (sym))
-#endif
-
#include "get-dynamic-info.h"
#ifdef RESOLVE_MAP
diff --git a/elf/rtld.c b/elf/rtld.c
index ed0a86b..ed5d062 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -254,15 +254,6 @@ RTLD_START
# error "sysdeps/MACHINE/dl-machine.h fails to define RTLD_START"
#endif
-#ifndef VALIDX
-# define VALIDX(tag) (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM \
- + DT_EXTRANUM + DT_VALTAGIDX (tag))
-#endif
-#ifndef ADDRIDX
-# define ADDRIDX(tag) (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM \
- + DT_EXTRANUM + DT_VALNUM + DT_ADDRTAGIDX (tag))
-#endif
-
/* This is the second half of _dl_start (below). It can be inlined safely
under DONT_USE_BOOTSTRAP_MAP, where it is careful not to make any GOT
references. When the tools don't permit us to avoid using a GOT entry
diff --git a/include/elf.h b/include/elf.h
index cdedd85..7bda6af 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -3,4 +3,10 @@
/* Some information which is not meant for the public and therefore not
in <elf.h>. */
# include <dl-dtprocnum.h>
+
+# define VERSYMIDX(sym) (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGIDX (sym))
+# define VALIDX(tag) (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM \
+ + DT_EXTRANUM + DT_VALTAGIDX (tag))
+# define ADDRIDX(tag) (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM \
+ + DT_EXTRANUM + DT_VALNUM + DT_ADDRTAGIDX (tag))
#endif
diff --git a/sysdeps/sparc/sparc32/dl-machine.h b/sysdeps/sparc/sparc32/dl-machine.h
index 2dfeeb2..04ce785 100644
--- a/sysdeps/sparc/sparc32/dl-machine.h
+++ b/sysdeps/sparc/sparc32/dl-machine.h
@@ -29,11 +29,6 @@
#include <tls.h>
#include <dl-plt.h>
-#ifndef VALIDX
-# define VALIDX(tag) (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM \
- + DT_EXTRANUM + DT_VALTAGIDX (tag))
-#endif
-
/* Return nonzero iff ELF header is compatible with the running host. */
static inline int
elf_machine_matches_host (const Elf32_Ehdr *ehdr)
diff --git a/sysdeps/sparc/sparc64/dl-machine.h b/sysdeps/sparc/sparc64/dl-machine.h
index 2f8bbe1..dec2fa0 100644
--- a/sysdeps/sparc/sparc64/dl-machine.h
+++ b/sysdeps/sparc/sparc64/dl-machine.h
@@ -27,11 +27,6 @@
#include <sysdep.h>
#include <dl-plt.h>
-#ifndef VALIDX
-# define VALIDX(tag) (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM \
- + DT_EXTRANUM + DT_VALTAGIDX (tag))
-#endif
-
#define ELF64_R_TYPE_ID(info) ((info) & 0xff)
#define ELF64_R_TYPE_DATA(info) ((info) >> 8)
diff --git a/sysdeps/x86_64/dl-tlsdesc.h b/sysdeps/x86_64/dl-tlsdesc.h
index 06ede02..ec75090 100644
--- a/sysdeps/x86_64/dl-tlsdesc.h
+++ b/sysdeps/x86_64/dl-tlsdesc.h
@@ -20,12 +20,6 @@
#ifndef _X86_64_DL_TLSDESC_H
# define _X86_64_DL_TLSDESC_H 1
-/* Use this to access DT_TLSDESC_PLT and DT_TLSDESC_GOT. */
-#ifndef ADDRIDX
-# define ADDRIDX(tag) (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM \
- + DT_EXTRANUM + DT_VALNUM + DT_ADDRTAGIDX (tag))
-#endif
-
/* Type used to represent a TLS descriptor in the GOT. */
struct tlsdesc
{
--
1.7.11.4
-------------- next part --------------
>From 15ce05a81f840621098d3b64f6a85f8ffe4e993c Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 28 Sep 2012 09:41:16 -0700
Subject: [PATCH 1/3] Remove arm ADDRIDX macro definition
---
ports/ChangeLog.arm | 4 ++++
ports/sysdeps/arm/dl-tlsdesc.h | 6 ------
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/ports/ChangeLog.arm b/ports/ChangeLog.arm
index b6c0225..6fb7cba 100644
--- a/ports/ChangeLog.arm
+++ b/ports/ChangeLog.arm
@@ -1,3 +1,7 @@
+2012-09-28 H.J. Lu <hongjiu.lu@intel.com>
+
+ * sysdeps/arm/dl-tlsdesc.h (ADDRIDX): Removed.
+
2012-09-21 Joseph Myers <joseph@codesourcery.com>
* sysdeps/arm/bits/atomic.h [!__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4]
diff --git a/ports/sysdeps/arm/dl-tlsdesc.h b/ports/sysdeps/arm/dl-tlsdesc.h
index 2b1131c..97951c0 100644
--- a/ports/sysdeps/arm/dl-tlsdesc.h
+++ b/ports/sysdeps/arm/dl-tlsdesc.h
@@ -20,12 +20,6 @@
#ifndef _ARM_DL_TLSDESC_H
# define _ARM_DL_TLSDESC_H 1
-/* Use this to access DT_TLSDESC_PLT and DT_TLSDESC_GOT. */
-#ifndef ADDRIDX
-# define ADDRIDX(tag) (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM \
- + DT_EXTRANUM + DT_VALNUM + DT_ADDRTAGIDX (tag))
-#endif
-
/* Type used to represent a TLS descriptor in the GOT. */
struct tlsdesc
{
--
1.7.11.4
-------------- next part --------------
>From 5240ef43afa87348390d78c84964e63a822cb4b8 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 28 Sep 2012 09:42:08 -0700
Subject: [PATCH 2/3] Remove mips VERSYMIDX macro definition
---
ports/ChangeLog.mips | 4 ++++
ports/sysdeps/mips/dl-trampoline.c | 2 --
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/ports/ChangeLog.mips b/ports/ChangeLog.mips
index 8c41753..9df62cc 100644
--- a/ports/ChangeLog.mips
+++ b/ports/ChangeLog.mips
@@ -1,3 +1,7 @@
+2012-09-28 H.J. Lu <hongjiu.lu@intel.com>
+
+ * sysdeps/mips/dl-trampoline.c (VERSYMIDX): Likewise.
+
2012-08-27 Joseph Myers <joseph@codesourcery.com>
* sysdeps/unix/sysv/linux/mips/kernel-features.h
diff --git a/ports/sysdeps/mips/dl-trampoline.c b/ports/sysdeps/mips/dl-trampoline.c
index 3454eb3..e4886cc 100644
--- a/ports/sysdeps/mips/dl-trampoline.c
+++ b/ports/sysdeps/mips/dl-trampoline.c
@@ -112,8 +112,6 @@ elf_machine_runtime_link_map (ElfW(Addr) gpreg, ElfW(Addr) stub_pc)
generated by the gnu linker. */
int _dl_mips_gnu_objects = 1;
-#define VERSYMIDX(sym) (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGIDX (sym))
-
/* This is called from assembly stubs below which the compiler can't see. */
static ElfW(Addr)
__dl_runtime_resolve (ElfW(Word), ElfW(Word), ElfW(Addr), ElfW(Addr))
--
1.7.11.4
More information about the Libc-alpha
mailing list