From patchwork Thu Jun 8 15:52:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 105015 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp372309vqr; Thu, 8 Jun 2023 08:52:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4nVkWPyzAVmpiLyMcbszAOcpF3wCwfdlBovachL7irKDmLX1Koocq2R1K7qRAb9ILHe9/c X-Received: by 2002:a17:907:7291:b0:978:66bd:d771 with SMTP id dt17-20020a170907729100b0097866bdd771mr139939ejc.55.1686239562712; Thu, 08 Jun 2023 08:52:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686239562; cv=none; d=google.com; s=arc-20160816; b=GAHTNVVjpUB1semkNA4dHzMVqL3XVrxvMJKCjiC8xZLNgltJZ8RlAE4mKf6JLbX9ND TbEtbDJBKcLOk6zig1mZBRXQeSatEDkvg/1uoEr9aoDMqLfMUM42LPc9t8h3E+/yC8Br LA+FLf4nnPlFZ7eZ+7qYFG5KQ3xMkzG/QGvSPAUtw9Z1Gf2IbfWd1ueEwqhUOQqgfPJw mClSPB12rupHEnpIWrBksEyFLKQlh13lbWXm8MuVrJtMBXRV+KBc0/TXgYPS1sfjwe8q qm0zkCVz3RLIR44m3sIN6FSP114jXbROnmmgsOsKViJexvlpxVljbqUVe8+NfiNxaKNm yJUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:to:from:cc :content-transfer-encoding:mime-version:message-id:date:subject :dkim-signature:dmarc-filter:delivered-to; bh=ZJPlFf5jlASoczC4VK7pHksIzNxBaEsBmlP7RxB4hxQ=; b=KwT7itb0RDxCfmaMeojQS1OF38WwcHEbL+znIOEazFsql6+TxIZ7AqTM0WJWeWfNgs sVgDR6EsxwLOVDrF0zcD/qPLPZr7syLAG365+ZEo/e8P/dSgfQkRqGnr3CMscUVZ3H0g /n2ZmYxZXgBYyFpMyDqxeWkMBMBz/cV6Tta3M3HhCM+CabQ0AX+k1rac4Why0ZBB58bi /7YKkEK0oHmCugc096mBjlnZJhDqh92bUeKgp4wsrK2jcLpIH50039OyG4mTa9oQktXN 9ecP3r4vfaXDmTgstJt2QezG1h+7ZeWkCS13BvlLrlCk53/KG8/srXrPKyhJKpQa+PYa /rmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=KysmoVSE; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id u24-20020a170906b11800b0096b247ef9aesi885118ejy.509.2023.06.08.08.52.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 08:52:42 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=KysmoVSE; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 32A303857357 for ; Thu, 8 Jun 2023 15:52:39 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id 719083857708 for ; Thu, 8 Jun 2023 15:52:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 719083857708 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-650c89c7e4fso706713b3a.0 for ; Thu, 08 Jun 2023 08:52:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1686239552; x=1688831552; h=to:from:cc:content-transfer-encoding:mime-version:message-id:date :subject:from:to:cc:subject:date:message-id:reply-to; bh=ZJPlFf5jlASoczC4VK7pHksIzNxBaEsBmlP7RxB4hxQ=; b=KysmoVSEXV5rztxiSeOFCggJNvYzzpT2KixKxLd+4ntH8Wo5Ib5dGI0kml8YeSb8ZQ 2u2QAa2Y9ihCOFgt6J7o+wND118v9tJKm0WaRjpWcHQ/vN3/o1OmSznRAI43I+kgBjaA c9uCK+wT4DE7Rzplxd7gQskPIwVFxk9xzOgLCc25FT79yBetyFP1O5pc+XGJ7PYkb+zE x4bBuTCOPKo1k7X0hBkJJF8YFEFjWWbp8t4GRS/2G9O70Cu2r2YpNJqLw6hSl7oZyi/d 9Q3Buq2i26mjOGF1F+euQ3flrm+um6z7KeWeAo9eozqkZZMI3EcppU4+d4aCuIcvHlKM P8bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686239552; x=1688831552; h=to:from:cc:content-transfer-encoding:mime-version:message-id:date :subject:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ZJPlFf5jlASoczC4VK7pHksIzNxBaEsBmlP7RxB4hxQ=; b=Kg0NsIy5iYxsOX37W4dwzvIuSC22VOMocHr9Jzb5xhCYjYGFGq9aRjOP78sPzQDmGQ kAI2oxQR3+pRup7QlQOFkwiMEc7HhfxaU0ayE4owhhcXjl9YQLVctgPkrtQ8FX8bWyGH 0m9i6AyiOhoALr26EKhkhMtnlD144sXHSFO30FfnqEm9arhSnfb13dpXDLyDm93i7EZL N4yN2T39CKeAKUfhmPW3Y6K24vhAAeFEEbFtjzf3MQQFN2/WkEHOQ0P1UEZqKTjK4g0i jgV/zlplB4ptJgAme83c3To0YUOQhY9Cgdh2NkYjEoEXn0wIBSCEJuMRSg6p5CKI9NW/ rHdw== X-Gm-Message-State: AC+VfDwL8C6kM9XQYMwYpPJX32pDgV37ARKl1pSQX+5Xenr5+PJGiBqR Ta298gsiIcsinvdBrPCksdu0iT87PFtcWD8SQGI= X-Received: by 2002:a05:6a20:be9e:b0:110:d78f:813e with SMTP id gf30-20020a056a20be9e00b00110d78f813emr5107117pzb.40.1686239552376; Thu, 08 Jun 2023 08:52:32 -0700 (PDT) Received: from localhost ([135.180.227.0]) by smtp.gmail.com with ESMTPSA id c26-20020aa7881a000000b0066199088a2dsm1250626pfo.193.2023.06.08.08.52.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 08:52:31 -0700 (PDT) Subject: [PATCH] RISC-V: Move __global_pointer$ to .sdata Date: Thu, 8 Jun 2023 08:52:14 -0700 Message-Id: <20230608155214.32435-1-palmer@rivosinc.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Cc: Jeff Law , Palmer Dabbelt From: Palmer Dabbelt To: binutils@sourceware.org X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768150335360591495?= X-GMAIL-MSGID: =?utf-8?q?1768150335360591495?= We're putting __global_pointer$ in SHN_ABS right now, but glibc uses PC-relative references to load up those symbols. It turns out we allow these references to resolve even in PIC, which is at best odd and possibly just a bug. Let's at least stop emitting these for now, we can try and figure out how to stop resolving them later. --- I haven't tested any of this at all, but it come up during the RISC-V LLVM sync meeting today so I figured I'd send the patch to start a discusion. I'd very much bet this is broken... Jim has a bug for the odd symbol placement . IIRC I also filed a bug to stop allowing PC-relative references against SHN_ABS, but I can't find it. --- ld/emulparams/elf32lriscv-defs.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ld/emulparams/elf32lriscv-defs.sh b/ld/emulparams/elf32lriscv-defs.sh index b823cedacab..186f2bf6e11 100644 --- a/ld/emulparams/elf32lriscv-defs.sh +++ b/ld/emulparams/elf32lriscv-defs.sh @@ -33,17 +33,17 @@ COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)" DATA_START_SYMBOLS="${CREATE_SHLIB-__DATA_BEGIN__ = .;}" -SDATA_START_SYMBOLS="${CREATE_SHLIB-__SDATA_BEGIN__ = .;} - *(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata .srodata.*)" - -INITIAL_READONLY_SECTIONS=".interp : { *(.interp) } ${CREATE_PIE-${INITIAL_READONLY_SECTIONS}}" -INITIAL_READONLY_SECTIONS="${RELOCATING+${CREATE_SHLIB-${INITIAL_READONLY_SECTIONS}}}" - # We must cover as much of sdata as possible if it exists. If sdata+bss is # smaller than 0x1000 then we should start from bss end to cover as much of # the program as possible. But we can't allow gp to cover any of rodata, as # the address of variables in rodata may change during relaxation, so we start # from data in that case. -OTHER_END_SYMBOLS="${CREATE_SHLIB-__BSS_END__ = .; +SDATA_START_SYMBOLS="${CREATE_SHLIB-__SDATA_BEGIN__ = .;} + *(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata .srodata.*) __global_pointer$ = MIN(__SDATA_BEGIN__ + 0x800, MAX(__DATA_BEGIN__ + 0x800, __BSS_END__ - 0x800));}" + +INITIAL_READONLY_SECTIONS=".interp : { *(.interp) } ${CREATE_PIE-${INITIAL_READONLY_SECTIONS}}" +INITIAL_READONLY_SECTIONS="${RELOCATING+${CREATE_SHLIB-${INITIAL_READONLY_SECTIONS}}}" + +OTHER_END_SYMBOLS="${CREATE_SHLIB-__BSS_END__ = .;"