Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Dec 2018 06:22:48 +0000 (UTC)
From:      Michal Meloun <mmel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r342110 - stable/12/libexec/rtld-elf/aarch64
Message-ID:  <201812150622.wBF6Mm5u096426@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mmel
Date: Sat Dec 15 06:22:48 2018
New Revision: 342110
URL: https://svnweb.freebsd.org/changeset/base/342110

Log:
  MFC r341738:
  
    Implement R_AARCH64_TLS_DTPMOD64 and A_AARCH64_TLS_DTPREL64 relocations.
    Although these are slightly obsolete in favor of R_AARCH64_TLSDESC, gcc
    -mtls-dialect=trad still use them.

Modified:
  stable/12/libexec/rtld-elf/aarch64/reloc.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/libexec/rtld-elf/aarch64/reloc.c
==============================================================================
--- stable/12/libexec/rtld-elf/aarch64/reloc.c	Sat Dec 15 05:47:22 2018	(r342109)
+++ stable/12/libexec/rtld-elf/aarch64/reloc.c	Sat Dec 15 06:22:48 2018	(r342110)
@@ -220,6 +220,8 @@ reloc_plt(Obj_Entry *obj)
 		case R_AARCH64_IRELATIVE:
 			obj->irelative = true;
 			break;
+		case R_AARCH64_NONE:
+			break;
 		default:
 			_rtld_error("Unknown relocation type %u in PLT",
 			    (unsigned int)ELF_R_TYPE(rela->r_info));
@@ -386,6 +388,8 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int
 		case R_AARCH64_ABS64:
 		case R_AARCH64_GLOB_DAT:
 		case R_AARCH64_TLS_TPREL64:
+		case R_AARCH64_TLS_DTPREL64:
+		case R_AARCH64_TLS_DTPMOD64:
 			def = find_symdef(ELF_R_SYM(rela->r_info), obj,
 			    &defobj, flags, cache, lockstate);
 			if (def == NULL)
@@ -472,8 +476,23 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int
 			*where = def->st_value + rela->r_addend +
 			    defobj->tlsoffset;
 			break;
+
+		/*
+		 * !!! BEWARE !!!
+		 * ARM ELF ABI defines TLS_DTPMOD64 as 1029, and TLS_DTPREL64
+		 * as 1028. But actual bfd linker and the glibc RTLD linker
+		 * treats TLS_DTPMOD64 as 1028 and TLS_DTPREL64 1029.
+		 */
+		case R_AARCH64_TLS_DTPREL64: /* efectively is TLS_DTPMOD64 */
+			*where += (Elf_Addr)defobj->tlsindex;
+			break;
+		case R_AARCH64_TLS_DTPMOD64: /* efectively is TLS_DTPREL64 */
+			*where += (Elf_Addr)(def->st_value + rela->r_addend);
+			break;
 		case R_AARCH64_RELATIVE:
 			*where = (Elf_Addr)(obj->relocbase + rela->r_addend);
+			break;
+		case R_AARCH64_NONE:
 			break;
 		default:
 			rtld_printf("%s: Unhandled relocation %lu\n",



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201812150622.wBF6Mm5u096426>