From patchwork Tue Feb 20 02:54:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: DJ Delorie X-Patchwork-Id: 25972 Received: (qmail 92588 invoked by alias); 20 Feb 2018 02:54:55 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 92578 invoked by uid 89); 20 Feb 2018 02:54:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=2319, 3315, UD:gd, UD:ie X-HELO: mx1.redhat.com Date: Mon, 19 Feb 2018 21:54:49 -0500 Message-Id: From: DJ Delorie To: libc-alpha@sourceware.org Subject: riscv: TLS init fix RISC-V TLS doesn't require GP to be initialized, and doing so breaks TLS in a shared object. diff --git a/sysdeps/riscv/tls-macros.h b/sysdeps/riscv/tls-macros.h index 5433ed9d16..7f0dd926d0 100644 --- a/sysdeps/riscv/tls-macros.h +++ b/sysdeps/riscv/tls-macros.h @@ -23,19 +23,9 @@ #include #include "dl-tls.h" -#define LOAD_GP \ - ".option push\n\t" \ - ".option norelax\n\t" \ - "la gp, __global_pointer$\n\t" \ - ".option pop\n\t" - -#define UNLOAD_GP - #define TLS_GD(x) \ ({ void *__result; \ - asm (LOAD_GP \ - "la.tls.gd %0, " #x "\n\t" \ - UNLOAD_GP \ + asm ("la.tls.gd %0, " #x "\n\t" \ : "=r" (__result)); \ __tls_get_addr (__result); }) @@ -43,19 +33,15 @@ #define TLS_IE(x) \ ({ void *__result; \ - asm (LOAD_GP \ - "la.tls.ie %0, " #x "\n\t" \ + asm ("la.tls.ie %0, " #x "\n\t" \ "add %0, %0, tp\n\t" \ - UNLOAD_GP \ : "=r" (__result)); \ __result; }) #define TLS_LE(x) \ ({ void *__result; \ - asm (LOAD_GP \ - "lui %0, %%tprel_hi(" #x ")\n\t" \ + asm ("lui %0, %%tprel_hi(" #x ")\n\t" \ "add %0, %0, tp, %%tprel_add(" #x ")\n\t" \ "addi %0, %0, %%tprel_lo(" #x ")\n\t" \ - UNLOAD_GP \ : "=r" (__result)); \ __result; })