From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) by sourceware.org (Postfix) with ESMTPS id 2DCB13858D39 for ; Thu, 18 Apr 2024 10:56:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2DCB13858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2DCB13858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.210.42 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713437802; cv=none; b=vZlWyZCWHcUN16aQ1WUXlvL8aM3rRd3LAijRmUeVtKGEOeoQSKMTmHG4+cyE55SENnsSyPLV3eon1/cjnq2MjqpGqHDYrFmBCBfPRXjcnykCpTA7cto41S33V9+8fnz8flFbzUu90pqQBrj6AREe8H3vEBHG9gKHiAIEfZv0sxs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713437802; c=relaxed/simple; bh=cHNfijZB4O2lfbDx6Logc7JT/tAz0dGjO6Ax2q+Meh0=; h=MIME-Version:From:Date:Message-ID:Subject:To; b=RekRN5tInNL084hQWpECcJHdCn+mDLxXLpC5voWec7IJnAn5z2UU8NwZ3YCKRl/3aCjhRT9AZMajbUsp4QZ3VveD1aLkyxnjfL9YW/LRSdQZ5k0ZrZ2ENQmI+3OBLiz3yLWu3fI45NA+XoFxW/93md6z54kfO9cL8D6k0QNIbsE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-6ea2ac4607aso364909a34.3 for ; Thu, 18 Apr 2024 03:56:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713437800; x=1714042600; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p1RuSJKFci+5GWRfqjUb1SujgU0/Jpyq1W6RvENEi5o=; b=N2IUdgyZVUAlb+MRZneodprjGc2sZCh7wrYY9OVs/gezkDGXWPTBORSMSdzN4f5Y8T 3qO5+HnN3M2sKlND9a1q41fNLeYtd019E5YIBumM7PJE+6mVB/sIMPhohHhGiTpp18h0 ggO0BlUS3K/hUufrOXCRj23wj5LKpXuhgLMfanl1WAWn3wJXmNiMIi4i9FGu0FGKAogJ fh+nFmHQu8tJ5Vj1jWACmLFMQ7JcDkSDciESl52h/ruK9DYv27IugOjzqHyDilW/Xeyp gRH4hoRJwy17aJQ3sGp6hzfNvXTPkt7bJx2WxyBexe2HdtV0wklHwT2FmLyVItRithZa yC0A== X-Forwarded-Encrypted: i=1; AJvYcCUv9XJn/LkRkcW82+aAKEHmRL1DdFazNn+qXTave6mH1MiHkRVN3DoC4UQ0L5rG18p3nX137z1eiZvTeM0sXcy4NpuK4dPipw== X-Gm-Message-State: AOJu0YwwcBrPvEdwI5v26QrEvtnpeY75NZqLaieLOd19QGYJxdyK8XOx Uc/BG/OB/rr4MP54hy2YFVZjisAAHs7yfgDC1Mf4alSSAKvXdpKz2WShmB0+ X-Google-Smtp-Source: AGHT+IH99xBAqqdrzHlAvAPed5jnRBswBuCOeXPSZFksYtQWli7v4QRdk434rygPnfjzVRHvXi1jyg== X-Received: by 2002:a05:6830:328f:b0:6eb:5b4b:51fc with SMTP id m15-20020a056830328f00b006eb5b4b51fcmr2539917ott.24.1713437800114; Thu, 18 Apr 2024 03:56:40 -0700 (PDT) Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com. [209.85.214.182]) by smtp.gmail.com with ESMTPSA id 127-20020a630985000000b005dc832ed816sm1157791pgj.59.2024.04.18.03.56.39 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 18 Apr 2024 03:56:39 -0700 (PDT) Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1e2b137d666so6166395ad.2 for ; Thu, 18 Apr 2024 03:56:39 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCW7Cu+4NWBfO7J0SmyH3JA8UvuE9T2fD00N1n/U5TbGx+AbDOlQ+ntAUZ09P4RHHER//iMO4hjYypaqwK9ajs7k561TqTkxgA== X-Received: by 2002:a17:902:6805:b0:1de:e47e:116c with SMTP id h5-20020a170902680500b001dee47e116cmr2462967plk.39.1713437799489; Thu, 18 Apr 2024 03:56:39 -0700 (PDT) MIME-Version: 1.0 References: <20240316085157.488072-1-syq@gcc.gnu.org> In-Reply-To: From: YunQiang Su Date: Thu, 18 Apr 2024 18:56:27 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4] MIPS: Support PCREL GOT access To: Fangrui Song Cc: nickc@redhat.com, binutils@sourceware.org, macro@orcam.me.uk, xry111@xry111.site Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,BODY_8BITS,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Fangrui Song =E4=BA=8E2024=E5=B9=B44=E6=9C=883=E6=97=A5=E5= =91=A8=E4=B8=89 12:11=E5=86=99=E9=81=93=EF=BC=9A > > On Sat, Mar 16, 2024 at 1:51=E2=80=AFAM YunQiang Su wro= te: > > > > Current if we need to access a GOT entry, we use the > > got_base + offset. Thus we have GOT and XGOT. > > From MIPSr6, we have PCREL instructions like ALUIPC, > > so we have no need to use got_base now. > > For pre-R6, we can use BAL to get the the value of PC. > > Currently loading a GOT entry requires loading the GOT base address > first, then adding an offset. > Therefore, (elaborate the reason) we need both GOT and XGOT. > MIPSr6 introduced PC-relative instructions like ..., which allow us to > use a pair of .. and .. to materialize the GOT entry address. > Thanks. Currently loading a GOT entry requires loading the GOT base address first, then adding an offset. Therefore, (elaborate the reason) we need both GOT and XGOT. MIPSr6 introduced PC-relative instructions like ALUIPC/AUIPC, which allow us to use a pair of GOTPC_HI and GOTPC_LO to materialize the GOT entry address. > > In this patch, we add 8 new relocs: > > R_MIPS_GOTPC_HI16, R_MIPS_GOTPC_LO16, > > R_MIPS_GOTPC_CALL_HI16, R_MIPS_GOTPC_CALL_LO16, > > R_MIPS_GOTPC_AHI16, R_MIPS_GOTPC_ALO16, > > R_MIPS_GOTPC_CALL_AHI16, R_MIPS_GOTPC_CALL_ALO16. > > These asm notes can be used for them: > > %gotpc_hi(sym), %gotpc_lo(sym), > > %gotpc_call_hi(sym), %gotpc_call_lo(sym), > > %gotpc_ahi(sym), %gotpc_alo(sym), > > %gotpc_call_ahi(sym), %gotpc_call_alo(sym). > > GCC's mips port names assembler relocation operators > (gas/config/tc-mips.c names them `mips_percent_op`). > Other ports seem to prefer "modifiers" (assembler modifiers, > expression modifiers). > These percent_op can be used for them > > * bfd-in2.h: Add new MIPS GOTPC BFD_RELOC defination. > > typo > Thanks. Ping again.