From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7877) id 3D1803858C52; Thu, 25 Jan 2024 07:38:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3D1803858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706168299; bh=d9/7pCz5SIvU6AAZE5HPtQffqpRZtluVO2W/mKsDQZc=; h=From:To:Subject:Date:From; b=kq4Uqt7P14A31fVCUNJGnlNOzhppNyUCsoDyoB0PwT+ko1iXPaceTsTyzS75AxkI3 p0ydT6yv0Fx4D2wJLmeaE/r2gMjot/ZxJNp23NgLImWgzwFol48ET3+bIu8jAcmp/j /kKYRpZavoPYkqaults01QvLROFnHCXZG/MDwvGw= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: LuluCheng To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-8412] LoongArch: Disable TLS type symbols from generating non-zero offsets. X-Act-Checkin: gcc X-Git-Author: Lulu Cheng X-Git-Refname: refs/heads/master X-Git-Oldrev: 464de9c283f7f4717280c515a192e479d7a840a3 X-Git-Newrev: 0801a88af40e4bb41c240788a2365ca1e30e281a Message-Id: <20240125073819.3D1803858C52@sourceware.org> Date: Thu, 25 Jan 2024 07:38:19 +0000 (GMT) List-Id: https://gcc.gnu.org/g:0801a88af40e4bb41c240788a2365ca1e30e281a commit r14-8412-g0801a88af40e4bb41c240788a2365ca1e30e281a Author: Lulu Cheng Date: Tue Jan 23 11:28:09 2024 +0800 LoongArch: Disable TLS type symbols from generating non-zero offsets. TLS gd ld and ie type symbols will generate corresponding GOT entries, so non-zero offsets cannot be generated. The address of TLS le type symbol+addend is not implemented in binutils, so non-zero offset is not generated here for the time being. gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_symbolic_constant_p): For symbols of type tls, non-zero Offset is not generated. Diff: --- gcc/config/loongarch/loongarch.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index 072c68d97e3..da22fd63e91 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -1924,11 +1924,7 @@ loongarch_symbolic_constant_p (rtx x, enum loongarch_symbol_type *symbol_type) x = UNSPEC_ADDRESS (x); } else if (SYMBOL_REF_P (x) || LABEL_REF_P (x)) - { - *symbol_type = loongarch_classify_symbol (x); - if (*symbol_type == SYMBOL_TLS) - return true; - } + *symbol_type = loongarch_classify_symbol (x); else return false; @@ -1939,17 +1935,21 @@ loongarch_symbolic_constant_p (rtx x, enum loongarch_symbol_type *symbol_type) relocations. */ switch (*symbol_type) { - case SYMBOL_TLS_IE: - case SYMBOL_TLS_LE: - case SYMBOL_TLSGD: - case SYMBOL_TLSLDM: case SYMBOL_PCREL: case SYMBOL_PCREL64: /* GAS rejects offsets outside the range [-2^31, 2^31-1]. */ return sext_hwi (INTVAL (offset), 32) == INTVAL (offset); + /* The following symbol types do not allow non-zero offsets. */ case SYMBOL_GOT_DISP: + case SYMBOL_TLS_IE: + case SYMBOL_TLSGD: + case SYMBOL_TLSLDM: case SYMBOL_TLS: + /* From an implementation perspective, tls_le symbols are allowed to + have non-zero offsets, but currently binutils has not added support, + so the generation of non-zero offsets is prohibited here. */ + case SYMBOL_TLS_LE: return false; } gcc_unreachable ();