Fix Wundef warning for ELF_MACHINE_NO_RELA

Message ID 20140626094725.GW4477@spoyarek.pnq.redhat.com
State Committed
Headers

Commit Message

Siddhesh Poyarekar June 26, 2014, 9:47 a.m. UTC
  Hi,

This patch defines ELF_MACHINE_NO_RELA on all architectures.  Tested
only on x86_64 to verify that the sources before and after are
identical except for two instructions that pass the current line
number in dl-machine.h to assert_fail.

OK to commit?

Siddhesh

	* elf/dl-runtime.c: Check for value of ELF_MACHINE_NO_RELA
	instead of whether it is defined.
	* sysdeps/aarch64/dl-machine.h: Define ELF_MACHINE_NO_RELA.
	* sysdeps/hppa/dl-machine.h: Likewise.
	* sysdeps/ia64/dl-machine.h: Likewise.
	* sysdeps/m68k/dl-machine.h: Likewise.
	* sysdeps/microblaze/dl-machine.h: Likewise.
	* sysdeps/mips/dl-machine.: Likewise.
	* sysdeps/powerpc/powerpc32/dl-machine.h: Likewise.
	* sysdeps/powerpc/powerpc64/dl-machine.h: Likewise.
	* sysdeps/s390/s390-32/dl-machine.h: Likewise.
	* sysdeps/s390/s390-64/dl-machine.h: Likewise.
	* sysdeps/sh/dl-machine.h: Likewise.
	* sysdeps/sparc/sparc32/dl-machine.h: Likewise.
	* sysdeps/sparc/sparc64/dl-machine.h: Likewise.
	* sysdeps/tile/dl-machine.h: Likewise.
	* sysdeps/x86_64/dl-machine.h: Likewise.
  

Comments

Will Newton June 26, 2014, 10:07 a.m. UTC | #1
On 26 June 2014 10:47, Siddhesh Poyarekar <siddhesh@redhat.com> wrote:
> Hi,
>
> This patch defines ELF_MACHINE_NO_RELA on all architectures.  Tested
> only on x86_64 to verify that the sources before and after are
> identical except for two instructions that pass the current line
> number in dl-machine.h to assert_fail.
>
> OK to commit?
>
> Siddhesh
>
>         * elf/dl-runtime.c: Check for value of ELF_MACHINE_NO_RELA
>         instead of whether it is defined.
>         * sysdeps/aarch64/dl-machine.h: Define ELF_MACHINE_NO_RELA.
>         * sysdeps/hppa/dl-machine.h: Likewise.
>         * sysdeps/ia64/dl-machine.h: Likewise.
>         * sysdeps/m68k/dl-machine.h: Likewise.
>         * sysdeps/microblaze/dl-machine.h: Likewise.
>         * sysdeps/mips/dl-machine.: Likewise.
>         * sysdeps/powerpc/powerpc32/dl-machine.h: Likewise.
>         * sysdeps/powerpc/powerpc64/dl-machine.h: Likewise.
>         * sysdeps/s390/s390-32/dl-machine.h: Likewise.
>         * sysdeps/s390/s390-64/dl-machine.h: Likewise.
>         * sysdeps/sh/dl-machine.h: Likewise.
>         * sysdeps/sparc/sparc32/dl-machine.h: Likewise.
>         * sysdeps/sparc/sparc64/dl-machine.h: Likewise.
>         * sysdeps/tile/dl-machine.h: Likewise.
>         * sysdeps/x86_64/dl-machine.h: Likewise.

This looks ok to me. It's verbose but as architectures can support REL
and RELA I don't see an obvious other option.

> diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
> index 773cb42..11eba4a 100644
> --- a/elf/dl-runtime.c
> +++ b/elf/dl-runtime.c
> @@ -29,7 +29,7 @@
>  #include <dl-irel.h>
>
>
> -#if (!defined ELF_MACHINE_NO_RELA && !defined ELF_MACHINE_PLT_REL) \
> +#if (!ELF_MACHINE_NO_RELA && !defined ELF_MACHINE_PLT_REL) \
>      || ELF_MACHINE_NO_REL
>  # define PLTREL  ElfW(Rela)
>  #else
> diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h
> index 997c860..6615b8f 100644
> --- a/sysdeps/aarch64/dl-machine.h
> +++ b/sysdeps/aarch64/dl-machine.h
> @@ -198,6 +198,7 @@ _dl_start_user:                                                     \n\
>
>  /* AArch64 uses RELA not REL */
>  #define ELF_MACHINE_NO_REL 1
> +#define ELF_MACHINE_NO_RELA 0
>
>  static inline ElfW(Addr)
>  elf_machine_fixup_plt (struct link_map *map, lookup_t t,
> diff --git a/sysdeps/hppa/dl-machine.h b/sysdeps/hppa/dl-machine.h
> index ba21f07..9c7471e 100644
> --- a/sysdeps/hppa/dl-machine.h
> +++ b/sysdeps/hppa/dl-machine.h
> @@ -488,6 +488,7 @@ asm (                                                                       \
>
>  /* We only use RELA. */
>  #define ELF_MACHINE_NO_REL 1
> +#define ELF_MACHINE_NO_RELA 0
>
>  /* Return the address of the entry point. */
>  #define ELF_MACHINE_START_ADDRESS(map, start)                  \
> diff --git a/sysdeps/ia64/dl-machine.h b/sysdeps/ia64/dl-machine.h
> index 853e6fd..7d3be04 100644
> --- a/sysdeps/ia64/dl-machine.h
> +++ b/sysdeps/ia64/dl-machine.h
> @@ -320,6 +320,7 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
>
>  /* According to the IA-64 specific documentation, Rela is always used.  */
>  #define ELF_MACHINE_NO_REL 1
> +#define ELF_MACHINE_NO_RELA 0
>
>  /* Return the address of the entry point. */
>  #define ELF_MACHINE_START_ADDRESS(map, start)                  \
> diff --git a/sysdeps/m68k/dl-machine.h b/sysdeps/m68k/dl-machine.h
> index 3ec9862..4e7c7db 100644
> --- a/sysdeps/m68k/dl-machine.h
> +++ b/sysdeps/m68k/dl-machine.h
> @@ -178,6 +178,7 @@ _dl_start_user:\n\
>
>  /* The m68k never uses Elf32_Rel relocations.  */
>  #define ELF_MACHINE_NO_REL 1
> +#define ELF_MACHINE_NO_RELA 0
>
>  static inline Elf32_Addr
>  elf_machine_fixup_plt (struct link_map *map, lookup_t t,
> diff --git a/sysdeps/microblaze/dl-machine.h b/sysdeps/microblaze/dl-machine.h
> index 848e822..d230a1b 100644
> --- a/sysdeps/microblaze/dl-machine.h
> +++ b/sysdeps/microblaze/dl-machine.h
> @@ -170,6 +170,7 @@ _dl_start_user:\n\
>
>  /* The microblaze never uses Elf32_Rel relocations.  */
>  #define ELF_MACHINE_NO_REL 1
> +#define ELF_MACHINE_NO_RELA 0
>
>  static inline Elf32_Addr
>  elf_machine_fixup_plt (struct link_map *map, lookup_t t,
> diff --git a/sysdeps/mips/dl-machine.h b/sysdeps/mips/dl-machine.h
> index b5bf4ad..eef0384 100644
> --- a/sysdeps/mips/dl-machine.h
> +++ b/sysdeps/mips/dl-machine.h
> @@ -60,6 +60,8 @@
>     | (((type) == R_MIPS_COPY) * ELF_RTYPE_CLASS_COPY))
>
>  #define ELF_MACHINE_PLT_REL 1
> +#define ELF_MACHINE_NO_REL 0
> +#define ELF_MACHINE_NO_RELA 0
>
>  /* Translate a processor specific dynamic tag to the index
>     in l_info array.  */
> diff --git a/sysdeps/powerpc/powerpc32/dl-machine.h b/sysdeps/powerpc/powerpc32/dl-machine.h
> index 23b610f..42fd374 100644
> --- a/sysdeps/powerpc/powerpc32/dl-machine.h
> +++ b/sysdeps/powerpc/powerpc32/dl-machine.h
> @@ -148,6 +148,7 @@ __elf_preferred_address(struct link_map *loader, size_t maplength,
>
>  /* The PowerPC never uses REL relocations.  */
>  #define ELF_MACHINE_NO_REL 1
> +#define ELF_MACHINE_NO_RELA 0
>
>  /* Set up the loaded object described by MAP so its unrelocated PLT
>     entries will jump to the on-demand fixup code in dl-runtime.c.
> diff --git a/sysdeps/powerpc/powerpc64/dl-machine.h b/sysdeps/powerpc/powerpc64/dl-machine.h
> index bc99183..735a549 100644
> --- a/sysdeps/powerpc/powerpc64/dl-machine.h
> +++ b/sysdeps/powerpc/powerpc64/dl-machine.h
> @@ -294,6 +294,7 @@ BODY_PREFIX "_dl_start_user:\n"                                             \
>
>  /* The PowerPC never uses REL relocations.  */
>  #define ELF_MACHINE_NO_REL 1
> +#define ELF_MACHINE_NO_RELA 0
>
>  /* Stuff for the PLT.  */
>  #if _CALL_ELF != 2
> diff --git a/sysdeps/s390/s390-32/dl-machine.h b/sysdeps/s390/s390-32/dl-machine.h
> index 4fd2745..527233b 100644
> --- a/sysdeps/s390/s390-32/dl-machine.h
> +++ b/sysdeps/s390/s390-32/dl-machine.h
> @@ -226,6 +226,7 @@ _dl_start_user:\n\
>
>  /* The S390 never uses Elf32_Rel relocations.  */
>  #define ELF_MACHINE_NO_REL 1
> +#define ELF_MACHINE_NO_RELA 0
>
>  /* We define an initialization functions.  This is called very early in
>     _dl_sysdep_start.  */
> diff --git a/sysdeps/s390/s390-64/dl-machine.h b/sysdeps/s390/s390-64/dl-machine.h
> index 2f37169..e48d355 100644
> --- a/sysdeps/s390/s390-64/dl-machine.h
> +++ b/sysdeps/s390/s390-64/dl-machine.h
> @@ -205,6 +205,7 @@ _dl_start_user:\n\
>
>  /* The 64 bit S/390 never uses Elf64_Rel relocations.  */
>  #define ELF_MACHINE_NO_REL 1
> +#define ELF_MACHINE_NO_RELA 0
>
>  /* We define an initialization functions.  This is called very early in
>     _dl_sysdep_start.  */
> diff --git a/sysdeps/sh/dl-machine.h b/sysdeps/sh/dl-machine.h
> index 4f3db89..81a417d 100644
> --- a/sysdeps/sh/dl-machine.h
> +++ b/sysdeps/sh/dl-machine.h
> @@ -251,6 +251,7 @@ elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc,
>
>  /* SH never uses Elf32_Rel relocations.         */
>  #define ELF_MACHINE_NO_REL 1
> +#define ELF_MACHINE_NO_RELA 0
>
>  #ifdef RESOLVE_MAP
>
> diff --git a/sysdeps/sparc/sparc32/dl-machine.h b/sysdeps/sparc/sparc32/dl-machine.h
> index e7d31b4..4b79cd6 100644
> --- a/sysdeps/sparc/sparc32/dl-machine.h
> +++ b/sysdeps/sparc/sparc32/dl-machine.h
> @@ -197,6 +197,7 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
>
>  /* The SPARC never uses Elf32_Rel relocations.  */
>  #define ELF_MACHINE_NO_REL 1
> +#define ELF_MACHINE_NO_RELA 0
>
>  /* Undo the sub %sp, 6*4, %sp; add %sp, 22*4, %o0 below to get at the
>     value we want in __libc_stack_end.  */
> diff --git a/sysdeps/sparc/sparc64/dl-machine.h b/sysdeps/sparc/sparc64/dl-machine.h
> index ef4ad4c..d6d263e 100644
> --- a/sysdeps/sparc/sparc64/dl-machine.h
> +++ b/sysdeps/sparc/sparc64/dl-machine.h
> @@ -119,6 +119,7 @@ elf_machine_plt_value (struct link_map *map, const Elf64_Rela *reloc,
>
>  /* The SPARC never uses Elf64_Rel relocations.  */
>  #define ELF_MACHINE_NO_REL 1
> +#define ELF_MACHINE_NO_RELA 0
>
>  /* Set up the loaded object described by L so its unrelocated PLT
>     entries will jump to the on-demand fixup code in dl-runtime.c.  */
> diff --git a/sysdeps/tile/dl-machine.h b/sysdeps/tile/dl-machine.h
> index d686a65..8be6758 100644
> --- a/sysdeps/tile/dl-machine.h
> +++ b/sysdeps/tile/dl-machine.h
> @@ -223,6 +223,7 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
>
>  /* TILE never uses Elf32_Rel relocations.  */
>  #define ELF_MACHINE_NO_REL 1
> +#define ELF_MACHINE_NO_RELA 0
>
>  /* We define an initialization functions.  This is called very early in
>     _dl_sysdep_start.  */
> diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
> index 8df04a9..f9ee1f7 100644
> --- a/sysdeps/x86_64/dl-machine.h
> +++ b/sysdeps/x86_64/dl-machine.h
> @@ -189,6 +189,7 @@ _dl_start_user:\n\
>
>  /* The x86-64 never uses Elf64_Rel/Elf32_Rel relocations.  */
>  #define ELF_MACHINE_NO_REL 1
> +#define ELF_MACHINE_NO_RELA 0
>
>  /* We define an initialization function.  This is called very early in
>     _dl_sysdep_start.  */
  
Roland McGrath June 26, 2014, 4:24 p.m. UTC | #2
Looks OK.
  

Patch

diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
index 773cb42..11eba4a 100644
--- a/elf/dl-runtime.c
+++ b/elf/dl-runtime.c
@@ -29,7 +29,7 @@ 
 #include <dl-irel.h>
 
 
-#if (!defined ELF_MACHINE_NO_RELA && !defined ELF_MACHINE_PLT_REL) \
+#if (!ELF_MACHINE_NO_RELA && !defined ELF_MACHINE_PLT_REL) \
     || ELF_MACHINE_NO_REL
 # define PLTREL  ElfW(Rela)
 #else
diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h
index 997c860..6615b8f 100644
--- a/sysdeps/aarch64/dl-machine.h
+++ b/sysdeps/aarch64/dl-machine.h
@@ -198,6 +198,7 @@  _dl_start_user:							\n\
 
 /* AArch64 uses RELA not REL */
 #define ELF_MACHINE_NO_REL 1
+#define ELF_MACHINE_NO_RELA 0
 
 static inline ElfW(Addr)
 elf_machine_fixup_plt (struct link_map *map, lookup_t t,
diff --git a/sysdeps/hppa/dl-machine.h b/sysdeps/hppa/dl-machine.h
index ba21f07..9c7471e 100644
--- a/sysdeps/hppa/dl-machine.h
+++ b/sysdeps/hppa/dl-machine.h
@@ -488,6 +488,7 @@  asm (									\
 
 /* We only use RELA. */
 #define ELF_MACHINE_NO_REL 1
+#define ELF_MACHINE_NO_RELA 0
 
 /* Return the address of the entry point. */
 #define ELF_MACHINE_START_ADDRESS(map, start)			\
diff --git a/sysdeps/ia64/dl-machine.h b/sysdeps/ia64/dl-machine.h
index 853e6fd..7d3be04 100644
--- a/sysdeps/ia64/dl-machine.h
+++ b/sysdeps/ia64/dl-machine.h
@@ -320,6 +320,7 @@  elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
 
 /* According to the IA-64 specific documentation, Rela is always used.  */
 #define ELF_MACHINE_NO_REL 1
+#define ELF_MACHINE_NO_RELA 0
 
 /* Return the address of the entry point. */
 #define ELF_MACHINE_START_ADDRESS(map, start)			\
diff --git a/sysdeps/m68k/dl-machine.h b/sysdeps/m68k/dl-machine.h
index 3ec9862..4e7c7db 100644
--- a/sysdeps/m68k/dl-machine.h
+++ b/sysdeps/m68k/dl-machine.h
@@ -178,6 +178,7 @@  _dl_start_user:\n\
 
 /* The m68k never uses Elf32_Rel relocations.  */
 #define ELF_MACHINE_NO_REL 1
+#define ELF_MACHINE_NO_RELA 0
 
 static inline Elf32_Addr
 elf_machine_fixup_plt (struct link_map *map, lookup_t t,
diff --git a/sysdeps/microblaze/dl-machine.h b/sysdeps/microblaze/dl-machine.h
index 848e822..d230a1b 100644
--- a/sysdeps/microblaze/dl-machine.h
+++ b/sysdeps/microblaze/dl-machine.h
@@ -170,6 +170,7 @@  _dl_start_user:\n\
 
 /* The microblaze never uses Elf32_Rel relocations.  */
 #define ELF_MACHINE_NO_REL 1
+#define ELF_MACHINE_NO_RELA 0
 
 static inline Elf32_Addr
 elf_machine_fixup_plt (struct link_map *map, lookup_t t,
diff --git a/sysdeps/mips/dl-machine.h b/sysdeps/mips/dl-machine.h
index b5bf4ad..eef0384 100644
--- a/sysdeps/mips/dl-machine.h
+++ b/sysdeps/mips/dl-machine.h
@@ -60,6 +60,8 @@ 
    | (((type) == R_MIPS_COPY) * ELF_RTYPE_CLASS_COPY))
 
 #define ELF_MACHINE_PLT_REL 1
+#define ELF_MACHINE_NO_REL 0
+#define ELF_MACHINE_NO_RELA 0
 
 /* Translate a processor specific dynamic tag to the index
    in l_info array.  */
diff --git a/sysdeps/powerpc/powerpc32/dl-machine.h b/sysdeps/powerpc/powerpc32/dl-machine.h
index 23b610f..42fd374 100644
--- a/sysdeps/powerpc/powerpc32/dl-machine.h
+++ b/sysdeps/powerpc/powerpc32/dl-machine.h
@@ -148,6 +148,7 @@  __elf_preferred_address(struct link_map *loader, size_t maplength,
 
 /* The PowerPC never uses REL relocations.  */
 #define ELF_MACHINE_NO_REL 1
+#define ELF_MACHINE_NO_RELA 0
 
 /* Set up the loaded object described by MAP so its unrelocated PLT
    entries will jump to the on-demand fixup code in dl-runtime.c.
diff --git a/sysdeps/powerpc/powerpc64/dl-machine.h b/sysdeps/powerpc/powerpc64/dl-machine.h
index bc99183..735a549 100644
--- a/sysdeps/powerpc/powerpc64/dl-machine.h
+++ b/sysdeps/powerpc/powerpc64/dl-machine.h
@@ -294,6 +294,7 @@  BODY_PREFIX "_dl_start_user:\n"						\
 
 /* The PowerPC never uses REL relocations.  */
 #define ELF_MACHINE_NO_REL 1
+#define ELF_MACHINE_NO_RELA 0
 
 /* Stuff for the PLT.  */
 #if _CALL_ELF != 2
diff --git a/sysdeps/s390/s390-32/dl-machine.h b/sysdeps/s390/s390-32/dl-machine.h
index 4fd2745..527233b 100644
--- a/sysdeps/s390/s390-32/dl-machine.h
+++ b/sysdeps/s390/s390-32/dl-machine.h
@@ -226,6 +226,7 @@  _dl_start_user:\n\
 
 /* The S390 never uses Elf32_Rel relocations.  */
 #define ELF_MACHINE_NO_REL 1
+#define ELF_MACHINE_NO_RELA 0
 
 /* We define an initialization functions.  This is called very early in
    _dl_sysdep_start.  */
diff --git a/sysdeps/s390/s390-64/dl-machine.h b/sysdeps/s390/s390-64/dl-machine.h
index 2f37169..e48d355 100644
--- a/sysdeps/s390/s390-64/dl-machine.h
+++ b/sysdeps/s390/s390-64/dl-machine.h
@@ -205,6 +205,7 @@  _dl_start_user:\n\
 
 /* The 64 bit S/390 never uses Elf64_Rel relocations.  */
 #define ELF_MACHINE_NO_REL 1
+#define ELF_MACHINE_NO_RELA 0
 
 /* We define an initialization functions.  This is called very early in
    _dl_sysdep_start.  */
diff --git a/sysdeps/sh/dl-machine.h b/sysdeps/sh/dl-machine.h
index 4f3db89..81a417d 100644
--- a/sysdeps/sh/dl-machine.h
+++ b/sysdeps/sh/dl-machine.h
@@ -251,6 +251,7 @@  elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc,
 
 /* SH never uses Elf32_Rel relocations.	 */
 #define ELF_MACHINE_NO_REL 1
+#define ELF_MACHINE_NO_RELA 0
 
 #ifdef RESOLVE_MAP
 
diff --git a/sysdeps/sparc/sparc32/dl-machine.h b/sysdeps/sparc/sparc32/dl-machine.h
index e7d31b4..4b79cd6 100644
--- a/sysdeps/sparc/sparc32/dl-machine.h
+++ b/sysdeps/sparc/sparc32/dl-machine.h
@@ -197,6 +197,7 @@  elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
 
 /* The SPARC never uses Elf32_Rel relocations.  */
 #define ELF_MACHINE_NO_REL 1
+#define ELF_MACHINE_NO_RELA 0
 
 /* Undo the sub %sp, 6*4, %sp; add %sp, 22*4, %o0 below to get at the
    value we want in __libc_stack_end.  */
diff --git a/sysdeps/sparc/sparc64/dl-machine.h b/sysdeps/sparc/sparc64/dl-machine.h
index ef4ad4c..d6d263e 100644
--- a/sysdeps/sparc/sparc64/dl-machine.h
+++ b/sysdeps/sparc/sparc64/dl-machine.h
@@ -119,6 +119,7 @@  elf_machine_plt_value (struct link_map *map, const Elf64_Rela *reloc,
 
 /* The SPARC never uses Elf64_Rel relocations.  */
 #define ELF_MACHINE_NO_REL 1
+#define ELF_MACHINE_NO_RELA 0
 
 /* Set up the loaded object described by L so its unrelocated PLT
    entries will jump to the on-demand fixup code in dl-runtime.c.  */
diff --git a/sysdeps/tile/dl-machine.h b/sysdeps/tile/dl-machine.h
index d686a65..8be6758 100644
--- a/sysdeps/tile/dl-machine.h
+++ b/sysdeps/tile/dl-machine.h
@@ -223,6 +223,7 @@  elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
 
 /* TILE never uses Elf32_Rel relocations.  */
 #define ELF_MACHINE_NO_REL 1
+#define ELF_MACHINE_NO_RELA 0
 
 /* We define an initialization functions.  This is called very early in
    _dl_sysdep_start.  */
diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
index 8df04a9..f9ee1f7 100644
--- a/sysdeps/x86_64/dl-machine.h
+++ b/sysdeps/x86_64/dl-machine.h
@@ -189,6 +189,7 @@  _dl_start_user:\n\
 
 /* The x86-64 never uses Elf64_Rel/Elf32_Rel relocations.  */
 #define ELF_MACHINE_NO_REL 1
+#define ELF_MACHINE_NO_RELA 0
 
 /* We define an initialization function.  This is called very early in
    _dl_sysdep_start.  */