svn commit: r312764 - head/libexec/rtld-elf/aarch64

Andrew Turner andrew at FreeBSD.org
Wed Jan 25 17:35:12 UTC 2017


Author: andrew
Date: Wed Jan 25 17:35:11 2017
New Revision: 312764
URL: https://svnweb.freebsd.org/changeset/base/312764

Log:
  Pull the R_AARCH64_TLSDESC code out into a common function and use them in
  both the plt and non-plt case.
  
  This fixes an issue where libraries built with LLD can fail with
  "Unhandled relocation 1031"
  
  PR:		214971
  Obtained from:	1 week
  Sponsored by:	DARPA, AFRL

Modified:
  head/libexec/rtld-elf/aarch64/reloc.c

Modified: head/libexec/rtld-elf/aarch64/reloc.c
==============================================================================
--- head/libexec/rtld-elf/aarch64/reloc.c	Wed Jan 25 16:35:57 2017	(r312763)
+++ head/libexec/rtld-elf/aarch64/reloc.c	Wed Jan 25 17:35:11 2017	(r312764)
@@ -184,6 +184,18 @@ rtld_tlsdesc_handle(struct tls_data *tls
 	return (tlsdesc->index);
 }
 
+static void
+reloc_tlsdesc(Obj_Entry *obj, const Elf_Rela *rela, Elf_Addr *where)
+{
+	if (ELF_R_SYM(rela->r_info) == 0) {
+		where[0] = (Elf_Addr)_rtld_tlsdesc;
+		where[1] = obj->tlsoffset + rela->r_addend;
+	} else {
+		where[0] = (Elf_Addr)_rtld_tlsdesc_dynamic;
+		where[1] = (Elf_Addr)reloc_tlsdesc_alloc(obj, rela);
+	}
+}
+
 /*
  * Process the PLT relocations.
  */
@@ -204,14 +216,7 @@ reloc_plt(Obj_Entry *obj)
 			*where += (Elf_Addr)obj->relocbase;
 			break;
 		case R_AARCH64_TLSDESC:
-			if (ELF_R_SYM(rela->r_info) == 0) {
-				where[0] = (Elf_Addr)_rtld_tlsdesc;
-				where[1] = obj->tlsoffset + rela->r_addend;
-			} else {
-				where[0] = (Elf_Addr)_rtld_tlsdesc_dynamic;
-				where[1] = (Elf_Addr)reloc_tlsdesc_alloc(obj,
-				    rela);
-			}
+			reloc_tlsdesc(obj, rela, where);
 			break;
 		default:
 			_rtld_error("Unknown relocation type %u in PLT",
@@ -362,6 +367,9 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry 
 				return (-1);
 			}
 			break;
+		case R_AARCH64_TLSDESC:
+			reloc_tlsdesc(obj, rela, where);
+			break;
 		case R_AARCH64_TLS_TPREL64:
 			def = find_symdef(symnum, obj, &defobj, flags, cache,
 			    lockstate);


More information about the svn-src-head mailing list