[uclibc-ng-devel,32/32,ARM] rtld: Avoid crash on R_ARM_NONE relocation

Message ID 20180704160941.3261-3-christophe.lyon@st.com
State New
Headers show
Series
  • Untitled series #53742
Related show

Commit Message

Christophe Lyon July 4, 2018, 4:09 p.m.
R_ARM_NONE contains no data, so avoid dereferencing it.

	* ldso/ldso/arm/elfinterp.c (_dl_do_reloc): Handle R_ARM_NONE
	relocation
	(_dl_do_reloc_lazy): 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/arm/elfinterp.c b/ldso/ldso/arm/elfinterp.c
index 3bcd675..2444ed7 100644
--- a/ldso/ldso/arm/elfinterp.c
+++ b/ldso/ldso/arm/elfinterp.c
@@ -289,7 +289,10 @@  _dl_do_reloc (struct elf_resolve *tpnt,struct r_scope_elem *scope,
 
 #if defined (__SUPPORT_LD_DEBUG__)
 	{
-		unsigned long old_val = *reloc_addr;
+		unsigned long old_val;
+
+		if (reloc_type != R_ARM_NONE)
+			old_val = *reloc_addr;
 #endif
 		switch (reloc_type) {
 			case R_ARM_NONE:
@@ -386,7 +389,7 @@  _dl_do_reloc (struct elf_resolve *tpnt,struct r_scope_elem *scope,
 				return -1; /*call _dl_exit(1) */
 		}
 #if defined (__SUPPORT_LD_DEBUG__)
-		if (_dl_debug_reloc && _dl_debug_detail)
+		if (_dl_debug_reloc && _dl_debug_detail && reloc_type != R_ARM_NONE)
 			_dl_dprintf(_dl_debug_file, "\tpatch: %x ==> %x @ %x", old_val, *reloc_addr, reloc_addr);
 	}
 
@@ -407,7 +410,10 @@  _dl_do_lazy_reloc (struct elf_resolve *tpnt, struct r_scope_elem *scope,
 
 #if defined (__SUPPORT_LD_DEBUG__)
 	{
-		unsigned long old_val = *reloc_addr;
+		unsigned long old_val;
+
+		if (reloc_type != R_ARM_NONE)
+			old_val = *reloc_addr;
 #endif
 		switch (reloc_type) {
 			case R_ARM_NONE:
@@ -428,7 +434,7 @@  _dl_do_lazy_reloc (struct elf_resolve *tpnt, struct r_scope_elem *scope,
 				return -1; /*call _dl_exit(1) */
 		}
 #if defined (__SUPPORT_LD_DEBUG__)
-		if (_dl_debug_reloc && _dl_debug_detail)
+		if (_dl_debug_reloc && _dl_debug_detail && reloc_type != R_ARM_NONE)
 			_dl_dprintf(_dl_debug_file, "\tpatch: %x ==> %x @ %x", old_val, *reloc_addr, reloc_addr);
 	}