From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 42604 invoked by alias); 4 Mar 2020 01:54:41 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 42595 invoked by uid 89); 4 Mar 2020 01:54:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=H*f:sk:CAFyWVa, H*f:sk:MYZ1XZj, H*RU:209.85.166.66, H*r:ip*209.85.166.66 X-HELO: mail-io1-f66.google.com Received: from mail-io1-f66.google.com (HELO mail-io1-f66.google.com) (209.85.166.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 04 Mar 2020 01:54:39 +0000 Received: by mail-io1-f66.google.com with SMTP id s24so607556iog.5 for ; Tue, 03 Mar 2020 17:54:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=XatWNDTu2irZ5fkCqpLLeP9MVYjW3C+1RuClM+YqDYo=; b=WjB/rbWAZc9oKPtpl9bxMEtw5ncbiu3nu0n7VI5D18mUtQSzulXI7aqbCO1OyVoZrv hPVbq+2SMGtikEOSRfk6OvA7yrgstxBr3Se4/0/7BnZAZ4fvoA+QSHh59MPYI7oe1Yvs saDNDMimk7cLHXkdFu647UANE6NNGl+LP4teHjZuLnRQtOt0lPogTuQ7IDh4gS7Bxrq0 vvNhjelTLPS3ablDXPE2Wh9sTgJsR+Q6MQicYL/8lfZjn86G/rauFkLkAWxlolE3R5J4 nz3u6e7kVAmRrFVfP1Lj/Dp2ZGEUuXKFxA9ERQ8KrxueVaMG9sFd3phpDlANMMEa+Hha 0xmw== MIME-Version: 1.0 References: <1583230959-11401-1-git-send-email-nelson.chu@sifive.com> <1583230959-11401-3-git-send-email-nelson.chu@sifive.com> <20200304000721.ujbcawqjzv3eeweq@google.com> In-Reply-To: <20200304000721.ujbcawqjzv3eeweq@google.com> From: Nelson Chu Date: Wed, 04 Mar 2020 01:54:00 -0000 Message-ID: Subject: Re: [PATCH 2/2] RISC-V: Support assembler modifier %got_pcrel_hi. To: Fangrui Song Cc: Binutils , James Clarke , Kito Cheng , Palmer Dabbelt , Jim Wilson Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2020-03/txt/msg00063.txt Hi MaskRay, On Wed, Mar 4, 2020 at 8:07 AM Fangrui Song wrote: > > What if %got_pcrel_hi refers to a STB_LOCAL symbol? For example, > > auipc a0, %got_pcrel_hi(.L1) > > It may be worth a test. > > FWIW, llvm-mc -triple=riscv64 -filetype=obj a.s # create a R_RISCV_GOT_HI20 referencing .L1 > There is no special treatment. Consider the following case tmp.s: .option pic .option norelax .global foo foo: la a0, foo .L1: auipc a0, %got_pcrel_hi(foo) ld a0, %pcrel_lo(.L1)(a0) .L2: auipc a0, %got_pcrel_hi(.L1) addi a0, a0, %pcrel_lo(.L2) la a0, .L1 $ ~/binutils-dev/build-elf64-upstream/build-install/bin/riscv64-unknown-elf-as tmp.s -o tmp.o $ ~/binutils-dev/build-elf64-upstream/build-install/bin/riscv64-unknown-elf-objdump -dr tmp.o tmp.o: file format elf64-littleriscv Disassembly of section .text: 0000000000000000 : 0: 00000517 auipc a0,0x0 0: R_RISCV_GOT_HI20 foo 4: 00053503 ld a0,0(a0) # 0 4: R_RISCV_PCREL_LO12_I .L0 0000000000000008 <.L1>: 8: 00000517 auipc a0,0x0 8: R_RISCV_GOT_HI20 foo c: 00053503 ld a0,0(a0) # 8 <.L1> c: R_RISCV_PCREL_LO12_I .L1 0000000000000010 <.L2>: 10: 00000517 auipc a0,0x0 10: R_RISCV_GOT_HI20 .L1 14: 00050513 mv a0,a0 14: R_RISCV_PCREL_LO12_I .L2 18: 00000517 auipc a0,0x0 18: R_RISCV_GOT_HI20 .L1 1c: 00053503 ld a0,0(a0) # 18 <.L2+0x8> 1c: R_RISCV_PCREL_LO12_I .L0 `foo` is a global symbol. `.L1` and `.L2` are local symbols. I think the current upstream GNU assembler treats them all the same for LA macro with pic and %got_pcrel_hi. So yes, the behavior should be the same as llvm-mc. BTW I get the same result for the linux toolchain. Thanks Nelson