From patchwork Tue Dec 15 09:16:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Chen X-Patchwork-Id: 41389 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8AAEE385043B; Tue, 15 Dec 2020 09:17:01 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by sourceware.org (Postfix) with ESMTPS id 89550385800D for ; Tue, 15 Dec 2020 09:16:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 89550385800D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vincent.chen@sifive.com Received: by mail-pf1-x441.google.com with SMTP id c79so14125126pfc.2 for ; Tue, 15 Dec 2020 01:16:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id; bh=dZNLr73Iuoei4Ou6Bt37fT0110JsDaF0X4/ghlQQQi4=; b=Q25vEfYI8DTAiclEJvmMou8c6biaFQivJflsMziWVrhfNkWc0nYQTfYp/vTdB9ZXgO GBpzcDz9FtTVYQXwdRGU/gl9Q73pgjPZEZAbRMrRe2nJrIKEunlHjWWWqYvw8NQE0Xiy OYCN14hhtIrPGU4JZ0cZkmsgD4MMTrBXzwqP4fLJGja3+Sla/7lMRpG6kdAv7sZKEmbP bYn00TVto9MGK6npH6Dp1OMynQqsuDZRfMoZM4zlNq8ipFBro6tJ2qNRAEYwTVOqlaXe jeVrCuwvX+quOx84ghKX3owdt2nudPG7li6dwxFvg4fsDL8ovx0TRLQg2nB6UuHNDlW6 r5SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=dZNLr73Iuoei4Ou6Bt37fT0110JsDaF0X4/ghlQQQi4=; b=ErnSjMadRC693acXbpOI7v/PQevm5wpeKOHrMpvZQVr5Odbq9Cub41RevwauktKQ0G FRYfzOoDtnPV4RgQumlw2JdY77BnQnU010+eH7BqSBlCsTmQ3Li3jB+bePzYp5TePp3J FUs5eTQxsQsxq+3S1uRWCZ8oKfRkK4MK8W7UFUVN7zRqjvO9tzYQTg1x1/Kg3ZIDckKu n/wpNgXZ8Of/e67mH2l/LyPFRsrDg5MXFcdltnJdWqk84C5MEJM3JjOfSn53Fuic9+Uw SOmvnbdmg/GJ3Cs2LQNa7kQqJqiClFDsM/QrpUAZ32MTgQ7v+TkOEKrH1+M7Tc89D/SZ FGyg== X-Gm-Message-State: AOAM5332FeuWZlLIj887/T+LG552Gv8BM6A/LKr7Dxk6xMJNuXGQSSc5 jzHtEgKc3bMM8lIHLk5NjOvOchYcYDIADLudhZQ= X-Google-Smtp-Source: ABdhPJxFscGodPRweX4N9t7iTRqgOI++vt6SMfNwS0GLukxZOLveOmG7Qjx/+d4jPh3nTHBQ7fYnTQ== X-Received: by 2002:a05:6a00:795:b029:19e:28de:e92a with SMTP id g21-20020a056a000795b029019e28dee92amr235798pfu.36.1608023818506; Tue, 15 Dec 2020 01:16:58 -0800 (PST) Received: from VincentChen-ThinkPad-T480s.internal.sifive.com (114-34-229-221.HINET-IP.hinet.net. [114.34.229.221]) by smtp.gmail.com with ESMTPSA id e8sm19193256pfn.176.2020.12.15.01.16.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Dec 2020 01:16:57 -0800 (PST) From: Vincent Chen To: libc-alpha@sourceware.org, palmer@dabbelt.com, darius@bluespec.com, dj@redhat.com Subject: [PATCH v2 0/2] riscv: add support for GNU indirect function Date: Tue, 15 Dec 2020 17:16:38 +0800 Message-Id: <1608023800-14560-1-git-send-email-vincent.chen@sifive.com> X-Mailer: git-send-email 2.7.4 X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nelson.chu@sifive.com, Vincent Chen , paul.walmsley@sifive.com Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The riscv Binutils supported GNU indirect function in the commit 02dd9d25. To make the entire mechanism work, these patches adds the required ports to enable Glibc to address the IRELATIVE relocation. Because the dynamic linker resolves the IRELATIVE relocation before jumping into the executable program, the $gp register is not initialized when executing the IFUNC resolver function. It may cause some unexpected error to occur when the dynamic loader resolves the IREALTIVE relocation of the position-dependent executable program. To solve this issue, the second patch enables dynamic linker to look for the __global_pointer$ symbol and use it to initialize $gp before resolving the IREALTIVE relocation of the PDE program. Changes since v1: 1. Move the riscv entry to the end of libc-abis file 2. Add the second input argument to IFUNC resolver to preserve the extension flexibility 3. Enable ld.so to initilize $gp by __global_pointer$ symbol instead of the DT_RISCV_GP dynamic entry to avoid to modify the riscv ELF psABI specification. Vincent Chen (2): riscv: support GNU indirect function riscv: Initialize $gp before resolving the IRELATIVE relocation libc-abis | 1 + sysdeps/riscv/dl-irel.h | 56 ++++++++++++++++++++++++++++++++++++++ sysdeps/riscv/dl-machine.h | 44 +++++++++++++++++++++++++++++- 3 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 sysdeps/riscv/dl-irel.h