From patchwork Sun Apr 5 11:35:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yann Sionneau X-Patchwork-Id: 1266528 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=uclibc-ng.org (client-ip=2a00:1828:2000:679::23; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=sionneau.net Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=sionneau.net header.i=@sionneau.net header.a=rsa-sha1 header.s=selectormx3 header.b=rD0b0Ccz; dkim-atps=neutral Received: from helium.openadk.org (helium.openadk.org [IPv6:2a00:1828:2000:679::23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48wBT32YcFz9sR4 for ; Sun, 5 Apr 2020 21:36:23 +1000 (AEST) Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id 769A3100DF; Sun, 5 Apr 2020 13:36:14 +0200 (CEST) X-Original-To: devel@uclibc-ng.org Delivered-To: devel@helium.openadk.org Received: from mx3.sionneau.net (mx3.sionneau.net [163.172.183.177]) by helium.openadk.org (Postfix) with ESMTPS id 02BDE100D2 for ; Sun, 5 Apr 2020 13:36:05 +0200 (CEST) Received: from mx3.sionneau.net (localhost [127.0.0.1]) by mx3.sionneau.net. (OpenSMTPD) with ESMTP id ea6c0585 for ; Sun, 5 Apr 2020 11:36:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=simple; d=sionneau.net; h=from:to:cc :subject:date:message-id:in-reply-to:references; s=selectormx3; bh=U0yL4W5KFX6krKFwCxz5y30emEg=; b=rD0b0CczYnT37M3s26fB9aLcFtY6 HbhMGEUSvgmru4tT3gJRYF9iaaZuRobbLRvnLZr3KptvVn1fe8Hg50NjsUg0mzcl SIb/l2MShsmgXTmY91oZyYaPjPf3wZxhvyi9duhjxUZJ3LRbPuGFsdEvRwueGnHc V+OIy7sTO5SD2OQ= DomainKey-Signature: a=rsa-sha1; c=simple; d=sionneau.net; h=from:to:cc :subject:date:message-id:in-reply-to:references; q=dns; s= selectormx3; b=WrG8DG17VM9hh7QdjZFfZQMNkZVqHnkT74VsSpECnBYMMF3Iv CF/C4r6Yvp7xYX9nx3Gmwy+4sGtFLTHC/sp/NPdKeiWCzhPEWV72S16/UBZOOZ5W qkyJQ78TOhN/Q+i12YQCtf1YA1jRGgAeC8vqDJHEtDBGA+9qskl601mJaA= Received: by mx3.sionneau.net (OpenSMTPD) with ESMTPSA id 33077938 (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128:NO); Sun, 5 Apr 2020 11:36:04 +0000 (UTC) From: Yann Sionneau To: devel@uclibc-ng.org Date: Sun, 5 Apr 2020 13:35:37 +0200 Message-Id: <20200405113540.25084-2-yann@sionneau.net> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200405113540.25084-1-yann@sionneau.net> References: <20200405113540.25084-1-yann@sionneau.net> Subject: [uclibc-ng-devel] [PATCH 1/4] or1k: add missing tls macros X-BeenThere: devel@uclibc-ng.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: uClibc-ng Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: devel-bounces@uclibc-ng.org Sender: "devel" Signed-off-by: Yann Sionneau --- test/tls/tls-macros-or1k.h | 75 ++++++++++++++++++++++++++++++++++++++ test/tls/tls-macros.h | 4 ++ 2 files changed, 79 insertions(+) create mode 100644 test/tls/tls-macros-or1k.h diff --git a/test/tls/tls-macros-or1k.h b/test/tls/tls-macros-or1k.h new file mode 100644 index 0000000..dcf78d6 --- /dev/null +++ b/test/tls/tls-macros-or1k.h @@ -0,0 +1,75 @@ +/* Macros to support TLS testing, OpenRISC version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#define TLS_LOAD_GOT \ + ({ register long lr __asm__ ("r9"); \ + long got; \ + asm ("l.jal 0x8\n\t" \ + " l.movhi %0, gotpchi(_GLOBAL_OFFSET_TABLE_-4)\n\t" \ + "l.ori %0, %0, gotpclo(_GLOBAL_OFFSET_TABLE_+0)\n\t" \ + "l.add %0, %0, %1" \ + : "=r" (got), "=r" (lr)); \ + got; }) + +/* General Dynamic: + l.movhi r17, tlsgdhi(symbol) + l.ori r17, r17, tlsgdlo(symbol) + l.add r17, r17, r16 + l.or r3, r17, r17 + l.jal plt(__tls_get_addr) + l.nop */ + +#define TLS_GD(x) \ + ({ void *__tlsgd; \ + extern void *__tls_get_addr (void *); \ + asm ("l.movhi %0, tlsgdhi(" #x ")\n\t" \ + "l.ori %0, %0, tlsgdlo(" #x ")\n\t" \ + : "=r" (__tlsgd)); \ + (int *) __tls_get_addr (TLS_LOAD_GOT + __tlsgd); }) + +#define TLS_LD(x) TLS_GD(x) + +/* Initial Exec: + l.movhi r17, gottpoffhi(symbol) + l.add r17, r17, r16 + l.lwz r17, gottpofflo(symbol)(r17) + l.add r17, r17, r10 + l.lbs r17, 0(r17) */ + +#define TLS_IE(x) \ + ({ register long __tls __asm__ ("r10"); \ + void *__tlsie; \ + asm ("l.movhi %0, gottpoffhi(" #x ")\n\t" \ + "l.add %0, %0, %1\n\t" \ + "l.lwz %0, gottpofflo(" #x ")(%0)\n\t" \ + "l.add %0, %0, %2\n\t" \ + : "=&r" (__tlsie) : "r" (TLS_LOAD_GOT), \ + "r" (__tls) : "memory"); \ + __tlsie; }) + +/* Local Exec: + l.movhi r17, tpoffha(symbol) + l.add r17, r17, r10 + l.addi r17, r17, tpofflo(symbol) + l.lbs r17, 0(r17) */ + +#define TLS_LE(x) \ + ({ register long __tls __asm__ ("r10"); \ + void *__tlsle; \ + asm ("l.movhi %0, tpoffha(" #x ")\n\t" \ + "l.add %0, %0, %1\n\t" \ + "l.addi %0, %0, tpofflo(" #x ")\n\t" \ + : "=&r" (__tlsle) : "r" (__tls) : "memory"); \ + __tlsle; }) diff --git a/test/tls/tls-macros.h b/test/tls/tls-macros.h index 9053d8d..71e8ef4 100644 --- a/test/tls/tls-macros.h +++ b/test/tls/tls-macros.h @@ -76,6 +76,10 @@ #include #endif +#ifdef __or1k__ +#include +#endif + #if !defined TLS_LE || !defined TLS_IE \ || !defined TLS_LD || !defined TLS_GD # error "No support for this architecture so far."