[uclibc-ng-devel,12/32,ARM,FDPIC] TLS: fix relocation computation

Message ID 20180704155605.1892-13-christophe.lyon@st.com
State New
Headers show
Series
  • FDPIC ABI for ARM
Related show

Commit Message

Christophe Lyon July 4, 2018, 3:55 p.m.
* ldso/ldso/dl-elf.c (_dl_load_elf_shared_library): Fix
	l_tls_initimage computation.
	* ldso/ldso/ldso.c (_dl_get_ready_to_run): Likewise.

Signed-off-by: Mickaël Guêné <mickael.guene@st.com>
Signed-off-by: Christophe Lyon <christophe.lyon@st.com>

Patch

diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c
index 1768b5b..9cb46de 100644
--- a/ldso/ldso/dl-elf.c
+++ b/ldso/ldso/dl-elf.c
@@ -863,11 +863,11 @@  struct elf_resolve *_dl_load_elf_shared_library(unsigned int rflags,
 		{
 # ifdef __SUPPORT_LD_DEBUG_EARLY__
 			char *tmp = (char *) tpnt->l_tls_initimage;
-			tpnt->l_tls_initimage = (char *) tlsppnt->p_vaddr + tpnt->loadaddr;
+			tpnt->l_tls_initimage = (char *) DL_RELOC_ADDR(tpnt->loadaddr, tlsppnt->p_vaddr;
 			_dl_debug_early("Relocated TLS initial image from %x to %x (size = %x)\n", tmp, tpnt->l_tls_initimage, tpnt->l_tls_initimage_size);
 			tmp = 0;
 # else
-			tpnt->l_tls_initimage = (char *) tlsppnt->p_vaddr + tpnt->loadaddr;
+			tpnt->l_tls_initimage = (char *) DL_RELOC_ADDR(tpnt->loadaddr, tlsppnt->p_vaddr);
 # endif
 		}
 	}
diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c
index c625757..06b0ac8 100644
--- a/ldso/ldso/ldso.c
+++ b/ldso/ldso/ldso.c
@@ -772,7 +772,7 @@  of this helper program; chances are you did not intend to run this program.\n\
 		char *tmp attribute_unused =
 			(char *) app_tpnt->l_tls_initimage;
 		app_tpnt->l_tls_initimage =
-			(char *) app_tpnt->l_tls_initimage + app_tpnt->loadaddr;
+			(char *) DL_RELOC_ADDR(app_tpnt->loadaddr, app_tpnt->l_tls_initimage);
 		_dl_debug_early("Relocated TLS initial image from %x to %x (size = %x)\n",
 			tmp, app_tpnt->l_tls_initimage, app_tpnt->l_tls_initimage_size);
 	}