From owner-svn-src-head@freebsd.org Tue Sep 1 15:57:05 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0F3309C6D1E; Tue, 1 Sep 2015 15:57:05 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DA1101B41; Tue, 1 Sep 2015 15:57:04 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t81Fv4kQ072560; Tue, 1 Sep 2015 15:57:04 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t81Fv4Yh072558; Tue, 1 Sep 2015 15:57:04 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201509011557.t81Fv4Yh072558@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Tue, 1 Sep 2015 15:57:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r287370 - head/libexec/rtld-elf/aarch64 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 15:57:05 -0000 Author: andrew Date: Tue Sep 1 15:57:03 2015 New Revision: 287370 URL: https://svnweb.freebsd.org/changeset/base/287370 Log: Fix how we place each objects thread local data. The code used was based on the Variant II code, however arm64 uses Variant I. The former placed the thread pointer after the data, pointing at the thread control block, while the latter places these before said data. Because of this we need to use the size of the previous entry to calculate where to place the current entry. We also need to reserve 16 bytes at the start for the thread control block. This also fixes the value of TLS_TCB_SIZE to be correct. This is the size of two unsigned longs, i.e. 2 * 8 bytes. While here remove the bogus adjustment of the pointer in the R_AARCH64_TLS_TPREL64 case. It should be the offset of the data relative to the thread pointer, including the thread control block. Sponsored by: ABT Systems Ltd Modified: head/libexec/rtld-elf/aarch64/reloc.c head/libexec/rtld-elf/aarch64/rtld_machdep.h Modified: head/libexec/rtld-elf/aarch64/reloc.c ============================================================================== --- head/libexec/rtld-elf/aarch64/reloc.c Tue Sep 1 15:43:56 2015 (r287369) +++ head/libexec/rtld-elf/aarch64/reloc.c Tue Sep 1 15:57:03 2015 (r287370) @@ -381,7 +381,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry } *where = def->st_value + rela->r_addend + - defobj->tlsoffset - TLS_TCB_SIZE; + defobj->tlsoffset; break; case R_AARCH64_RELATIVE: *where = (Elf_Addr)(obj->relocbase + rela->r_addend); Modified: head/libexec/rtld-elf/aarch64/rtld_machdep.h ============================================================================== --- head/libexec/rtld-elf/aarch64/rtld_machdep.h Tue Sep 1 15:43:56 2015 (r287369) +++ head/libexec/rtld-elf/aarch64/rtld_machdep.h Tue Sep 1 15:57:03 2015 (r287370) @@ -64,12 +64,12 @@ Elf_Addr reloc_jmpslot(Elf_Addr *where, #define round(size, align) \ (((size) + (align) - 1) & ~((align) - 1)) #define calculate_first_tls_offset(size, align) \ - round(size, align) + round(16, align) #define calculate_tls_offset(prev_offset, prev_size, size, align) \ - round((prev_offset) + (size), align) + round(prev_offset + prev_size, align) #define calculate_tls_end(off, size) ((off) + (size)) -#define TLS_TCB_SIZE 8 +#define TLS_TCB_SIZE 16 typedef struct { unsigned long ti_module; unsigned long ti_offset;