Index: glibc/elf/dl-runtime.c
===================================================================
--- glibc.orig/elf/dl-runtime.c	2018-02-16 20:46:56.344044379 +0000
+++ glibc/elf/dl-runtime.c	2018-02-16 20:54:42.827281181 +0000
@@ -124,14 +124,13 @@ _dl_fixup (
 	 of the object that defines sym.  Now add in the symbol
 	 offset.  */
       value = DL_FIXUP_MAKE_VALUE (result,
-				   sym ? (LOOKUP_VALUE_ADDRESS (result)
-					  + sym->st_value) : 0);
+				   SYMBOL_ADDRESS (result, sym, false));
     }
   else
     {
       /* We already found the symbol.  The module (and therefore its load
 	 address) is also known.  */
-      value = DL_FIXUP_MAKE_VALUE (l, l->l_addr + sym->st_value);
+      value = DL_FIXUP_MAKE_VALUE (l, SYMBOL_ADDRESS (l, sym, true));
       result = l;
     }
 
@@ -241,9 +240,7 @@ _dl_profile_fixup (
 	     of the object that defines sym.  Now add in the symbol
 	     offset.  */
 	  value = DL_FIXUP_MAKE_VALUE (result,
-				       defsym != NULL
-				       ? LOOKUP_VALUE_ADDRESS (result)
-					 + defsym->st_value : 0);
+				       SYMBOL_ADDRESS (result, defsym, false));
 
 	  if (defsym != NULL
 	      && __builtin_expect (ELFW(ST_TYPE) (defsym->st_info)
@@ -254,7 +251,7 @@ _dl_profile_fixup (
 	{
 	  /* We already found the symbol.  The module (and therefore its load
 	     address) is also known.  */
-	  value = DL_FIXUP_MAKE_VALUE (l, l->l_addr + refsym->st_value);
+	  value = DL_FIXUP_MAKE_VALUE (l, SYMBOL_ADDRESS (l, refsym, true));
 
 	  if (__builtin_expect (ELFW(ST_TYPE) (refsym->st_info)
 				== STT_GNU_IFUNC, 0))
Index: glibc/elf/dl-symaddr.c
===================================================================
--- glibc.orig/elf/dl-symaddr.c	2018-02-16 20:46:56.361461070 +0000
+++ glibc/elf/dl-symaddr.c	2018-02-16 20:54:42.848453422 +0000
@@ -22,7 +22,7 @@
 void *
 _dl_symbol_address (struct link_map *map, const ElfW(Sym) *ref)
 {
-  ElfW(Addr) value = (map ? map->l_addr : 0) + ref->st_value;
+  ElfW(Addr) value = SYMBOL_ADDRESS (map, ref, false);
 
   /* Return the pointer to function descriptor. */
   if (ELFW(ST_TYPE) (ref->st_info) == STT_FUNC)
Index: glibc/elf/rtld.c
===================================================================
--- glibc.orig/elf/rtld.c	2018-02-16 20:46:56.383646539 +0000
+++ glibc/elf/rtld.c	2018-02-16 20:54:42.874625658 +0000
@@ -1917,7 +1917,7 @@ ERROR: ld.so: object '%s' cannot be load
 					  NULL, ELF_RTYPE_CLASS_PLT,
 					  DL_LOOKUP_ADD_DEPENDENCY, NULL);
 
-	    loadbase = LOOKUP_VALUE_ADDRESS (result);
+	    loadbase = LOOKUP_VALUE_ADDRESS (result, false);
 
 	    _dl_printf ("%s found at 0x%0*Zd in object at 0x%0*Zd\n",
 			_dl_argv[i],
Index: glibc/sysdeps/aarch64/dl-machine.h
===================================================================
--- glibc.orig/sysdeps/aarch64/dl-machine.h	2018-02-16 20:46:56.395887386 +0000
+++ glibc/sysdeps/aarch64/dl-machine.h	2018-02-16 20:54:42.916987949 +0000
@@ -254,7 +254,7 @@ elf_machine_rela (struct link_map *map, 
     {
       const ElfW(Sym) *const refsym = sym;
       struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
-      ElfW(Addr) value = sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value;
+      ElfW(Addr) value = SYMBOL_ADDRESS (sym_map, sym, true);
 
       if (sym != NULL
 	  && __glibc_unlikely (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC)
Index: glibc/sysdeps/alpha/dl-machine.h
===================================================================
--- glibc.orig/sysdeps/alpha/dl-machine.h	2018-02-16 20:46:56.412270344 +0000
+++ glibc/sysdeps/alpha/dl-machine.h	2018-02-16 20:54:42.961274109 +0000
@@ -419,7 +419,7 @@ elf_machine_rela (struct link_map *map,
       if (sym_map)
 	{
 	  sym_raw_value += sym->st_value;
-	  sym_value = sym_raw_value + sym_map->l_addr;
+	  sym_value += SYMBOL_ADDRESS (sym_map, sym, true);
 	}
 
       if (r_type == R_ALPHA_GLOB_DAT)
Index: glibc/sysdeps/arm/dl-machine.h
===================================================================
--- glibc.orig/sysdeps/arm/dl-machine.h	2018-02-16 20:46:56.432577001 +0000
+++ glibc/sysdeps/arm/dl-machine.h	2018-02-16 20:54:42.985498628 +0000
@@ -392,7 +392,7 @@ elf_machine_rel (struct link_map *map, c
     {
       const Elf32_Sym *const refsym = sym;
       struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
-      Elf32_Addr value = sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value;
+      Elf32_Addr value = SYMBOL_ADDRESS (sym_map, sym, true);
 
       if (sym != NULL
 	  && __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0)
@@ -452,7 +452,7 @@ elf_machine_rel (struct link_map *map, c
 		 binding found in the user program or a loaded library
 		 rather than the dynamic linker's built-in definitions
 		 used while loading those libraries.  */
-	      value -= map->l_addr + refsym->st_value;
+	      value -= SYMBOL_ADDRESS (map, refsym, true);
 # endif
 	    /* Support relocations on mis-aligned offsets.  */
 	    ((struct unaligned *) reloc_addr)->x += value;
@@ -553,7 +553,7 @@ elf_machine_rela (struct link_map *map, 
       const Elf32_Sym *const refsym = sym;
 # endif
       struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
-      Elf32_Addr value = sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value;
+      Elf32_Addr value = SYMBOL_ADDRESS (sym_map, sym, true);
 
       if (sym != NULL
 	  && __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0)
Index: glibc/sysdeps/generic/ldsodefs.h
===================================================================
--- glibc.orig/sysdeps/generic/ldsodefs.h	2018-02-16 20:46:56.455844235 +0000
+++ glibc/sysdeps/generic/ldsodefs.h	2018-02-16 20:54:43.029923370 +0000
@@ -66,14 +66,20 @@ __BEGIN_DECLS
 /* Result of the lookup functions and how to retrieve the base address.  */
 typedef struct link_map *lookup_t;
 #define LOOKUP_VALUE(map) map
-#define LOOKUP_VALUE_ADDRESS(map) ((map) ? (map)->l_addr : 0)
+#define LOOKUP_VALUE_ADDRESS(map, set) ((set) || (map) ? (map)->l_addr : 0)
+
+/* Calculate the address of symbol REF using the base address from map MAP,
+   if non-NULL.  Don't check for NULL map if MAP_SET is TRUE.  */
+#define SYMBOL_ADDRESS(map, ref, map_set)				\
+  ((ref) == NULL ? 0							\
+   : LOOKUP_VALUE_ADDRESS ((map), (map_set)) + (ref)->st_value)
 
 /* On some architectures a pointer to a function is not just a pointer
    to the actual code of the function but rather an architecture
    specific descriptor. */
 #ifndef ELF_FUNCTION_PTR_IS_SPECIAL
 # define DL_SYMBOL_ADDRESS(map, ref) \
- (void *) (LOOKUP_VALUE_ADDRESS (map) + ref->st_value)
+ (void *) SYMBOL_ADDRESS ((map), (ref), false)
 # define DL_LOOKUP_ADDRESS(addr) ((ElfW(Addr)) (addr))
 # define DL_CALL_DT_INIT(map, start, argc, argv, env) \
  ((init_t) (start)) (argc, argv, env)
Index: glibc/sysdeps/hppa/dl-machine.h
===================================================================
--- glibc.orig/sysdeps/hppa/dl-machine.h	2018-02-16 20:46:56.478223642 +0000
+++ glibc/sysdeps/hppa/dl-machine.h	2018-02-16 20:54:43.092691786 +0000
@@ -562,7 +562,7 @@ elf_machine_rela (struct link_map *map,
 
   if (sym_map)
     {
-      value = sym ? sym_map->l_addr + sym->st_value : 0;
+      value = SYMBOL_ADDRESS (sym_map, sym, true);
       value += reloc->r_addend;
     }
   else
@@ -586,8 +586,8 @@ elf_machine_rela (struct link_map *map,
     case R_PARISC_DIR21L:
       {
 	unsigned int insn = *(unsigned int *)reloc_addr;
-	value = sym_map->l_addr + sym->st_value
-		+ ((reloc->r_addend + 0x1000) & -0x2000);
+	value = (SYMBOL_ADDRESS (sym_map, sym, true)
+		 + ((reloc->r_addend + 0x1000) & -0x2000));
 	value = value >> 11;
 	insn = (insn &~ 0x1fffff) | reassemble_21 (value);
 	*(unsigned int *)reloc_addr = insn;
@@ -597,8 +597,8 @@ elf_machine_rela (struct link_map *map,
     case R_PARISC_DIR14R:
       {
 	unsigned int insn = *(unsigned int *)reloc_addr;
-	value = ((sym_map->l_addr + sym->st_value) & 0x7ff)
-		+ (((reloc->r_addend & 0x1fff) ^ 0x1000) - 0x1000);
+	value = ((SYMBOL_ADDRESS (sym_map, sym, true) & 0x7ff)
+ 		 + (((reloc->r_addend & 0x1fff) ^ 0x1000) - 0x1000));
 	insn = (insn &~ 0x3fff) | reassemble_14 (value);
 	*(unsigned int *)reloc_addr = insn;
       }
Index: glibc/sysdeps/hppa/dl-symaddr.c
===================================================================
--- glibc.orig/sysdeps/hppa/dl-symaddr.c	2018-02-16 20:46:56.491539052 +0000
+++ glibc/sysdeps/hppa/dl-symaddr.c	2018-02-16 20:54:43.107920827 +0000
@@ -23,7 +23,7 @@ void *
 _dl_symbol_address (struct link_map *map, const ElfW(Sym) *ref)
 {
   /* Find the "ip" from the "map" and symbol "ref" */
-  Elf32_Addr value = (map ? map->l_addr : 0) + ref->st_value;
+  Elf32_Addr value = SYMBOL_ADDRESS (map, ref, false);
 
   /* On hppa, we have to return the pointer to function descriptor.
      This involves an "| 2" to inform $$dyncall that this is a plabel32  */
Index: glibc/sysdeps/i386/dl-machine.h
===================================================================
--- glibc.orig/sysdeps/i386/dl-machine.h	2018-02-16 20:46:56.528128512 +0000
+++ glibc/sysdeps/i386/dl-machine.h	2018-02-16 20:54:43.137242301 +0000
@@ -320,7 +320,7 @@ elf_machine_rel (struct link_map *map, c
       const Elf32_Sym *const refsym = sym;
 # endif
       struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
-      Elf32_Addr value = sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value;
+      Elf32_Addr value = SYMBOL_ADDRESS (sym_map, sym, true);
 
       if (sym != NULL
 	  && __glibc_unlikely (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC)
@@ -500,7 +500,7 @@ elf_machine_rela (struct link_map *map, 
       const Elf32_Sym *const refsym = sym;
 #  endif
       struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
-      Elf32_Addr value = sym == NULL ? 0 : sym_map->l_addr + sym->st_value;
+      Elf32_Addr value = SYMBOL_ADDRESS (sym_map, sym, true);
 
       if (sym != NULL
 	  && __glibc_likely (sym->st_shndx != SHN_UNDEF)
Index: glibc/sysdeps/ia64/dl-machine.h
===================================================================
--- glibc.orig/sysdeps/ia64/dl-machine.h	2018-02-16 20:46:56.570036056 +0000
+++ glibc/sysdeps/ia64/dl-machine.h	2018-02-16 20:54:43.186984876 +0000
@@ -419,7 +419,7 @@ elf_machine_rela (struct link_map *map,
       /* RESOLVE_MAP() will return NULL if it fail to locate the symbol.  */
       if ((sym_map = RESOLVE_MAP (&sym, version, r_type)))
 	{
-	  value = sym_map->l_addr + sym->st_value + reloc->r_addend;
+	  value = SYMBOL_ADDRESS (sym_map, sym, true) + reloc->r_addend;
 
 	  if (R_IA64_TYPE (r_type) == R_IA64_TYPE (R_IA64_DIR64LSB))
 	    ;/* No adjustment.  */
Index: glibc/sysdeps/m68k/dl-machine.h
===================================================================
--- glibc.orig/sysdeps/m68k/dl-machine.h	2018-02-16 20:46:56.605638852 +0000
+++ glibc/sysdeps/m68k/dl-machine.h	2018-02-16 20:54:43.228597824 +0000
@@ -229,7 +229,7 @@ elf_machine_rela (struct link_map *map, 
     {
       const Elf32_Sym *const refsym = sym;
       struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
-      Elf32_Addr value = sym == NULL ? 0 : sym_map->l_addr + sym->st_value;
+      Elf32_Addr value = SYMBOL_ADDRESS (sym_map, sym, true);
 
       switch (r_type)
 	{
Index: glibc/sysdeps/microblaze/dl-machine.h
===================================================================
--- glibc.orig/sysdeps/microblaze/dl-machine.h	2018-02-16 20:46:56.624987751 +0000
+++ glibc/sysdeps/microblaze/dl-machine.h	2018-02-16 20:54:43.263890597 +0000
@@ -223,7 +223,7 @@ elf_machine_rela (struct link_map *map, 
     {
       const Elf32_Sym *const refsym = sym;
       struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
-      Elf32_Addr value = sym == NULL ? 0 : sym_map->l_addr + sym->st_value;
+      Elf32_Addr value = SYMBOL_ADDRESS (sym_map, sym, true);
 
       value += reloc->r_addend;
       if (r_type == R_MICROBLAZE_GLOB_DAT ||
Index: glibc/sysdeps/mips/dl-machine.h
===================================================================
--- glibc.orig/sysdeps/mips/dl-machine.h	2018-02-16 20:46:56.638514990 +0000
+++ glibc/sysdeps/mips/dl-machine.h	2018-02-16 20:54:43.292066191 +0000
@@ -220,7 +220,7 @@ do {									\
   while (i--)								\
     {									\
       if (sym->st_shndx == SHN_UNDEF || sym->st_shndx == SHN_COMMON)	\
-	*got = map->l_addr + sym->st_value;				\
+	*got = SYMBOL_ADDRESS (map, sym, true);				\
       else if (ELFW(ST_TYPE) (sym->st_info) == STT_FUNC			\
 	       && *got != sym->st_value)				\
 	*got += map->l_addr;						\
@@ -230,7 +230,7 @@ do {									\
 	    *got += map->l_addr;					\
 	}								\
       else								\
-	*got = map->l_addr + sym->st_value;				\
+	*got = SYMBOL_ADDRESS (map, sym, true);				\
 									\
       got++;								\
       sym++;								\
@@ -598,7 +598,7 @@ elf_machine_reloc (struct link_map *map,
 #ifndef RTLD_BOOTSTRAP
 		if (map != &GL(dl_rtld_map))
 #endif
-		  reloc_value += sym->st_value + map->l_addr;
+		  reloc_value += SYMBOL_ADDRESS (map, sym, true);
 	      }
 	    else
 	      {
@@ -663,7 +663,7 @@ elf_machine_reloc (struct link_map *map,
 			    "found jump slot relocation with non-zero addend");
 
 	sym_map = RESOLVE_MAP (&sym, version, r_type);
-	value = sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value;
+	value = SYMBOL_ADDRESS (sym_map, sym, true);
 	*addr_field = value;
 
 	break;
@@ -677,7 +677,7 @@ elf_machine_reloc (struct link_map *map,
 
 	/* Calculate the address of the symbol.  */
 	sym_map = RESOLVE_MAP (&sym, version, r_type);
-	value = sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value;
+	value = SYMBOL_ADDRESS (sym_map, sym, true);
 
 	if (__builtin_expect (sym == NULL, 0))
 	  /* This can happen in trace mode if an object could not be
@@ -798,7 +798,7 @@ elf_machine_got_rel (struct link_map *ma
 	= vernum ? &map->l_versions[vernum[sym_index] & 0x7fff] : NULL;	  \
       struct link_map *sym_map;						  \
       sym_map = RESOLVE_MAP (&ref, version, reloc);			  \
-      ref ? sym_map->l_addr + ref->st_value : 0;			  \
+      SYMBOL_ADDRESS (sym_map, ref, true);				  \
     })
 
   if (map->l_info[VERSYMIDX (DT_VERSYM)] != NULL)
@@ -842,7 +842,7 @@ elf_machine_got_rel (struct link_map *ma
 	      && !(sym->st_other & STO_MIPS_PLT))
 	    {
 	      if (lazy)
-		*got = sym->st_value + map->l_addr;
+		*got = SYMBOL_ADDRESS (map, sym, true);
 	      else
 		/* This is a lazy-binding stub, so we don't need the
 		   canonical address.  */
Index: glibc/sysdeps/mips/dl-trampoline.c
===================================================================
--- glibc.orig/sysdeps/mips/dl-trampoline.c	2018-02-16 20:46:56.668816567 +0000
+++ glibc/sysdeps/mips/dl-trampoline.c	2018-02-16 20:54:43.311233564 +0000
@@ -192,12 +192,12 @@ __dl_runtime_resolve (ElfW(Word) sym_ind
 
       /* Currently value contains the base load address of the object
 	 that defines sym.  Now add in the symbol offset.  */
-      value = (sym ? sym_map->l_addr + sym->st_value : 0);
+      value = SYMBOL_ADDRESS (sym_map, sym, true);
     }
   else
     /* We already found the symbol.  The module (and therefore its load
        address) is also known.  */
-    value = l->l_addr + sym->st_value;
+    value = SYMBOL_ADDRESS (l, sym, true);
 
   /* Apply the relocation with that value.  */
   *(got + local_gotno + sym_index - gotsym) = value;
Index: glibc/sysdeps/nios2/dl-machine.h
===================================================================
--- glibc.orig/sysdeps/nios2/dl-machine.h	2018-02-16 20:46:56.681975495 +0000
+++ glibc/sysdeps/nios2/dl-machine.h	2018-02-16 20:54:43.336907477 +0000
@@ -250,7 +250,7 @@ elf_machine_rela (struct link_map *map, 
     {
       const Elf32_Sym *const refsym = sym;
       struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
-      Elf32_Addr value = sym == NULL ? 0 : sym_map->l_addr + sym->st_value;
+      Elf32_Addr value = SYMBOL_ADDRESS (sym_map, sym, true);
 
       switch (r_type)
 	{
Index: glibc/sysdeps/powerpc/powerpc32/dl-machine.h
===================================================================
--- glibc.orig/sysdeps/powerpc/powerpc32/dl-machine.h	2018-02-16 20:46:56.716736305 +0000
+++ glibc/sysdeps/powerpc/powerpc32/dl-machine.h	2018-02-16 20:54:43.372769690 +0000
@@ -317,7 +317,7 @@ elf_machine_rela (struct link_map *map, 
   else
     {
       sym_map = RESOLVE_MAP (&sym, version, r_type);
-      value = sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value;
+      value = SYMBOL_ADDRESS (sym_map, sym, true);
     }
   value += reloc->r_addend;
 #else
Index: glibc/sysdeps/powerpc/powerpc64/dl-machine.h
===================================================================
--- glibc.orig/sysdeps/powerpc/powerpc64/dl-machine.h	2018-02-16 20:46:56.750293648 +0000
+++ glibc/sysdeps/powerpc/powerpc64/dl-machine.h	2018-02-16 20:54:43.394096592 +0000
@@ -708,8 +708,7 @@ elf_machine_rela (struct link_map *map,
   /* We need SYM_MAP even in the absence of TLS, for elf_machine_fixup_plt
      and STT_GNU_IFUNC.  */
   struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
-  Elf64_Addr value = ((sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value)
-		      + reloc->r_addend);
+  Elf64_Addr value = SYMBOL_ADDRESS (sym_map, sym, true) + reloc->r_addend;
 
   if (sym != NULL
       && __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0)
Index: glibc/sysdeps/riscv/dl-machine.h
===================================================================
--- glibc.orig/sysdeps/riscv/dl-machine.h	2018-02-16 20:46:56.779683134 +0000
+++ glibc/sysdeps/riscv/dl-machine.h	2018-02-16 20:54:43.444499991 +0000
@@ -172,7 +172,7 @@ elf_machine_rela (struct link_map *map, 
   struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
   ElfW(Addr) value = 0;
   if (sym_map != NULL)
-    value = sym_map->l_addr + sym->st_value + reloc->r_addend;
+    value = SYMBOL_ADDRESS (sym_map, sym, true) + reloc->r_addend;
 
   switch (r_type)
     {
Index: glibc/sysdeps/s390/s390-32/dl-machine.h
===================================================================
--- glibc.orig/sysdeps/s390/s390-32/dl-machine.h	2018-02-16 20:46:56.798057189 +0000
+++ glibc/sysdeps/s390/s390-32/dl-machine.h	2018-02-16 20:54:43.591117697 +0000
@@ -358,7 +358,7 @@ elf_machine_rela (struct link_map *map, 
       const Elf32_Sym *const refsym = sym;
 #endif
       struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
-      Elf32_Addr value = sym == NULL ? 0 : sym_map->l_addr + sym->st_value;
+      Elf32_Addr value = SYMBOL_ADDRESS (sym_map, sym, true);
 
       if (sym != NULL
 	  && __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0)
Index: glibc/sysdeps/s390/s390-64/dl-machine.h
===================================================================
--- glibc.orig/sysdeps/s390/s390-64/dl-machine.h	2018-02-16 20:46:56.818280183 +0000
+++ glibc/sysdeps/s390/s390-64/dl-machine.h	2018-02-16 20:54:43.646792665 +0000
@@ -305,7 +305,7 @@ elf_machine_rela (struct link_map *map, 
       const Elf64_Sym *const refsym = sym;
 #endif
       struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
-      Elf64_Addr value = sym == NULL ? 0 : sym_map->l_addr + sym->st_value;
+      Elf64_Addr value = SYMBOL_ADDRESS (sym_map, sym, true);
 
       if (sym != NULL
 	  && __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC,
Index: glibc/sysdeps/sh/dl-machine.h
===================================================================
--- glibc.orig/sysdeps/sh/dl-machine.h	2018-02-16 20:46:56.833350822 +0000
+++ glibc/sysdeps/sh/dl-machine.h	2018-02-16 20:54:43.665902503 +0000
@@ -320,7 +320,7 @@ elf_machine_rela (struct link_map *map, 
       const Elf32_Sym *const refsym = sym;
       struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
 
-      value = sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value;
+      value = SYMBOL_ADDRESS (sym_map, sym, true);
       value += reloc->r_addend;
 
       switch (r_type)
@@ -406,7 +406,7 @@ elf_machine_rela (struct link_map *map, 
 		 binding found in the user program or a loaded library
 		 rather than the dynamic linker's built-in definitions
 		 used while loading those libraries.  */
-	      value -= map->l_addr + refsym->st_value + reloc->r_addend;
+	      value -= SYMBOL_ADDRESS (map, refsym, true) + reloc->r_addend;
 #endif
 	    COPY_UNALIGNED_WORD (&value, reloc_addr_arg,
 				 (int) reloc_addr_arg & 3);
Index: glibc/sysdeps/sparc/sparc32/dl-machine.h
===================================================================
--- glibc.orig/sysdeps/sparc/sparc32/dl-machine.h	2018-02-16 20:46:56.847628573 +0000
+++ glibc/sysdeps/sparc/sparc32/dl-machine.h	2018-02-16 20:54:43.720201843 +0000
@@ -382,7 +382,7 @@ elf_machine_rela (struct link_map *map, 
   else
     {
       sym_map = RESOLVE_MAP (&sym, version, r_type);
-      value = sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value;
+      value = SYMBOL_ADDRESS (sym_map, sym, true);
     }
 #else
   value = 0;
Index: glibc/sysdeps/sparc/sparc64/dl-machine.h
===================================================================
--- glibc.orig/sysdeps/sparc/sparc64/dl-machine.h	2018-02-16 20:46:56.890051750 +0000
+++ glibc/sysdeps/sparc/sparc64/dl-machine.h	2018-02-16 20:54:43.747398602 +0000
@@ -409,7 +409,7 @@ elf_machine_rela (struct link_map *map, 
   else
     {
       sym_map = RESOLVE_MAP (&sym, version, r_type);
-      value = sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value;
+      value = SYMBOL_ADDRESS (sym_map, sym, true);
     }
 #else
   value = 0;
Index: glibc/sysdeps/tile/dl-machine.h
===================================================================
--- glibc.orig/sysdeps/tile/dl-machine.h	2018-02-16 20:46:56.913292170 +0000
+++ glibc/sysdeps/tile/dl-machine.h	2018-02-16 20:54:43.772866201 +0000
@@ -430,7 +430,7 @@ elf_machine_rela (struct link_map *map, 
   else if (ELFW_ST_TYPE (sym->st_info) == STT_SECTION)
     value = map->l_addr;  /* like a RELATIVE reloc */
   else
-    value = sym_map->l_addr + sym->st_value;
+    value = SYMBOL_ADDRESS (sym_map, sym, true);
 
   if (sym != NULL
       && __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0)
Index: glibc/sysdeps/x86_64/dl-machine.h
===================================================================
--- glibc.orig/sysdeps/x86_64/dl-machine.h	2018-02-16 20:46:56.932570604 +0000
+++ glibc/sysdeps/x86_64/dl-machine.h	2018-02-16 20:54:43.797250981 +0000
@@ -306,8 +306,7 @@ elf_machine_rela (struct link_map *map, 
       const ElfW(Sym) *const refsym = sym;
 # endif
       struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
-      ElfW(Addr) value = (sym == NULL ? 0
-			  : (ElfW(Addr)) sym_map->l_addr + sym->st_value);
+      ElfW(Addr) value = SYMBOL_ADDRESS (sym_map, sym, true);
 
       if (sym != NULL
 	  && __glibc_unlikely (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC)
