From owner-svn-src-stable@freebsd.org Fri Dec 14 10:20:27 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BB2E813299C7; Fri, 14 Dec 2018 10:20:27 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5B87997376; Fri, 14 Dec 2018 10:20:27 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3525D2DD3B; Fri, 14 Dec 2018 10:20:27 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wBEAKRpi057421; Fri, 14 Dec 2018 10:20:27 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wBEAKQVD057420; Fri, 14 Dec 2018 10:20:26 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201812141020.wBEAKQVD057420@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Fri, 14 Dec 2018 10:20:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r342074 - stable/12/libexec/rtld-elf/aarch64 X-SVN-Group: stable-12 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: stable/12/libexec/rtld-elf/aarch64 X-SVN-Commit-Revision: 342074 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 5B87997376 X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-1.58 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.86)[-0.864,0]; NEURAL_HAM_SHORT(-0.71)[-0.715,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Dec 2018 10:20:28 -0000 Author: mmel Date: Fri Dec 14 10:20:26 2018 New Revision: 342074 URL: https://svnweb.freebsd.org/changeset/base/342074 Log: MFC r341511,r341512,r341513: r341511: Fix style(9). Not a functional change. r341512: Implement arm64 version of __tls_get_addr(). r341513: Tidy up arm64 reloc_jmpslots() implementation. - don't relocate jump slots multiple times (if LD_BIND_NOW is defined). - process only R_AARCH64_JUMP_SLOT here, other relocation types are handled by reloc_plt(). Modified: stable/12/libexec/rtld-elf/aarch64/reloc.c stable/12/libexec/rtld-elf/aarch64/rtld_start.S Directory Properties: stable/12/ (props changed) Modified: stable/12/libexec/rtld-elf/aarch64/reloc.c ============================================================================== --- stable/12/libexec/rtld-elf/aarch64/reloc.c Fri Dec 14 09:30:43 2018 (r342073) +++ stable/12/libexec/rtld-elf/aarch64/reloc.c Fri Dec 14 10:20:26 2018 (r342074) @@ -109,9 +109,8 @@ do_copy_relocations(Obj_Entry *dstobj) } } if (srcobj == NULL) { - _rtld_error( -"Undefined symbol \"%s\" referenced from COPY relocation in %s", - name, dstobj->path); + _rtld_error("Undefined symbol \"%s\" referenced from " + "COPY relocation in %s", name, dstobj->path); return (-1); } @@ -241,8 +240,10 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockStat const Elf_Rela *relalim; const Elf_Rela *rela; const Elf_Sym *def; - struct tls_data *tlsdesc; + if (obj->jmpslots_done) + return (0); + relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize); for (rela = obj->pltrela; rela < relalim; rela++) { Elf_Addr *where, target; @@ -262,20 +263,9 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockStat reloc_jmpslot(where, target, defobj, obj, (const Elf_Rel *)rela); break; - case R_AARCH64_TLSDESC: - if (ELF_R_SYM(rela->r_info) != 0) { - tlsdesc = (struct tls_data *)where[1]; - if (tlsdesc->index == -1) - rtld_tlsdesc_handle_locked(tlsdesc, - SYMLOOK_IN_PLT | flags, lockstate); - } - break; - default: - _rtld_error("Unknown relocation type %x in jmpslot", - (unsigned int)ELF_R_TYPE(rela->r_info)); - return (-1); } } + obj->jmpslots_done = true; return (0); } @@ -511,4 +501,16 @@ allocate_initial_tls(Obj_Entry *objs) tp = (Elf_Addr **) allocate_tls(objs, NULL, TLS_TCB_SIZE, 16); asm volatile("msr tpidr_el0, %0" : : "r"(tp)); +} + +void * +__tls_get_addr(tls_index* ti) +{ + char *p; + void *_tp; + + __asm __volatile("mrs %0, tpidr_el0" : "=r" (_tp)); + p = tls_get_addr_common((Elf_Addr **)(_tp), ti->ti_module, ti->ti_offset); + + return (p); } Modified: stable/12/libexec/rtld-elf/aarch64/rtld_start.S ============================================================================== --- stable/12/libexec/rtld-elf/aarch64/rtld_start.S Fri Dec 14 09:30:43 2018 (r342073) +++ stable/12/libexec/rtld-elf/aarch64/rtld_start.S Fri Dec 14 10:20:26 2018 (r342074) @@ -57,7 +57,7 @@ END(.rtld_start) ENTRY(_rtld_bind_start) .cfi_startproc mov x17, sp - + /* Save frame pointer and SP */ stp x29, x30, [sp, #-16]! mov x29, sp