[v4,0/5] Support DT_RELR relative relocation format
Message ID | 20220301161706.185216-1-hjl.tools@gmail.com |
---|---|
Headers |
Return-Path: <libc-alpha-bounces+patchwork=sourceware.org@sourceware.org> 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 AB6DF3858423 for <patchwork@sourceware.org>; Tue, 1 Mar 2022 16:17:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AB6DF3858423 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1646151465; bh=zEw7txvYiv1+0keMRFdmsyqDYJBWZ0I8Gg/0uSV/Flw=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=hdye9pkw4vEQII8FH3HuJ+MqrJedPBeMhyYNwQFO5DWldN1Gv4mJcvof0+diUMcrY rmtPs0MV+f1iHwAN9lre10gQ7NqpnnCx6ew7h0ww7Pk3n46Kx1+9wmY5VSNfQV3XhV UutY+LJKNn/eLwQ87ZA5kCxhomfJC0ZzjfPYLBPY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by sourceware.org (Postfix) with ESMTPS id 17289385841F for <libc-alpha@sourceware.org>; Tue, 1 Mar 2022 16:17:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 17289385841F Received: by mail-pg1-x533.google.com with SMTP id o23so14726690pgk.13 for <libc-alpha@sourceware.org>; Tue, 01 Mar 2022 08:17:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=zEw7txvYiv1+0keMRFdmsyqDYJBWZ0I8Gg/0uSV/Flw=; b=JqF3eEZhvnRcddgIRyeNFRU+AMFbamo9PVSCaJ+paIMAgkLFE4tGZXoptJlWx79SWy TpkYIz4ZGGX6Z6NfGXtelvm+xRdHpcFBx8DpuFjcSn0VVplE42ZbkBER83Qwr1WKC3Qy qhtZxa8Z6eglNrNfGyGWicP610OLKBJrmBkT0jkbHAI8+4NjJr9hXJ/7emhFoDRR5IXT NlnU45vUkFvc35Y9aHrKujyvOQVNM4jGeNW4VmwecGGf9/shb/HccslxkW/hIdbnJ88A zHH882QaDomPIbuSV8YytHPPzyRUhh6TRx8cwwaNyZih5ezVMUUmXoi3sL/kepaBsV6p GZCQ== X-Gm-Message-State: AOAM530nQGViph6yTKKtnyBw+fBrf2iadaFRZHcfVaB5IgqdhT1dxouk AXlg2BMed02Rw4UZjzRAsZ1+kfU0tAI= X-Google-Smtp-Source: ABdhPJzIGvX5esKkH7y9BZmTrE46a51Kc6Q5MkzSFmU3VPDYnIWhqCMTGkDqxCwfS30GT5mNhCJzhQ== X-Received: by 2002:a63:ef4f:0:b0:375:6898:f6b8 with SMTP id c15-20020a63ef4f000000b003756898f6b8mr22488629pgk.59.1646151428150; Tue, 01 Mar 2022 08:17:08 -0800 (PST) Received: from gnu-tgl-3.localdomain ([172.58.35.88]) by smtp.gmail.com with ESMTPSA id y16-20020a056a00191000b004e155b2623bsm18286094pfi.178.2022.03.01.08.17.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Mar 2022 08:17:07 -0800 (PST) Received: from gnu-tgl-3.. (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id BA32CC021F; Tue, 1 Mar 2022 08:17:06 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v4 0/5] Support DT_RELR relative relocation format Date: Tue, 1 Mar 2022 08:17:01 -0800 Message-Id: <20220301161706.185216-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3022.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> From: "H.J. Lu via Libc-alpha" <libc-alpha@sourceware.org> Reply-To: "H.J. Lu" <hjl.tools@gmail.com> Cc: Joseph Myers <joseph@codesourcery.com> Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" <libc-alpha-bounces+patchwork=sourceware.org@sourceware.org> |
Message
H.J. Lu
March 1, 2022, 4:17 p.m. UTC
The empty version map is used for GLIBC_ABI_DT_RELR. But lld doesn't support empty version map. Should we require linker with empty version map support for glibc build? H.J. --- Changes in v4: 1. Always enable GLIBC_ABI_DT_RELR check. 2. Use $(OBJDUMP) instead of $(NM) for GLIBC_ABI_DT_RELR check. Changes in v3: 1. Don't define SUPPORT_DT_RELR. 2. Enable DT_RELR in glibc shared libraries and position independent executables (PIE) automatically if linker supports -z pack-relative-relocs. Changes in v2: 1. Enable DT_RELR for all targets. 2. Issue an error if there is a DT_RELR entry without GLIBC_ABI_DT_RELR dependency nor GLIBC_PRIVATE definition. --- PIE and shared objects usually have many relative relocations. In 2017/2018, SHT_RELR/DT_RELR was proposed on https://groups.google.com/g/generic-abi/c/bX460iggiKg/m/GxjM0L-PBAAJ ("Proposal for a new section type SHT_RELR") and is a pre-standard. RELR usually takes 3% or smaller space than R_*_RELATIVE relocations. The virtual memory size of a mostly statically linked PIE is typically 5~10% smaller. Binutils 2.38 supports DT_RELR on x86 with the -z report-relative-reloc option. When DT_RELR is enabled, ld adds a GLIBC_ABI_DT_RELR symbol version dependency on libc.so to outputs. Issue an error if there is a DT_RELR entry without GLIBC_ABI_DT_RELR dependency nor GLIBC_PRIVATE definition. DT_RELR is enabled in glibc shared libraries and position independent executables (PIE) automatically if linker supports -z pack-relative-relocs. The DT_RELR usage in glibc can be disabled with --disable-default-dt-relr. Tested with binutils 2.38 on i686, x86-64 and x32. Fangrui Song (1): elf: Support DT_RELR relative relocation format [BZ #27924] H.J. Lu (4): elf: Properly handle zero DT_RELA/DT_REL values Add GLIBC_ABI_DT_RELR for DT_RELR support Add --disable-default-dt-relr NEWS: Mention DT_RELR support INSTALL | 6 ++++ Makeconfig | 19 ++++++++++++ Makerules | 2 ++ NEWS | 2 +- configure | 60 +++++++++++++++++++++++++++++++++++++ configure.ac | 23 +++++++++++++++ elf/Makefile | 34 +++++++++++++++++++-- elf/Versions | 5 ++++ elf/dl-version.c | 33 +++++++++++++++++++-- elf/dynamic-link.h | 40 ++++++++++++++++++++++++- elf/elf.h | 13 ++++++-- elf/get-dynamic-info.h | 19 ++++++++++-- elf/libc-abi-version.exp | 1 + elf/tst-relr-pie.c | 1 + elf/tst-relr.c | 64 ++++++++++++++++++++++++++++++++++++++++ include/link.h | 6 ++++ manual/install.texi | 5 ++++ scripts/abilist.awk | 2 ++ scripts/versions.awk | 7 ++++- 19 files changed, 329 insertions(+), 13 deletions(-) create mode 100644 elf/libc-abi-version.exp create mode 100644 elf/tst-relr-pie.c create mode 100644 elf/tst-relr.c