[v2,0/7] Support DT_RELR relative relocation format
Message ID | 20220205172446.652011-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 C16A33858419 for <patchwork@sourceware.org>; Sat, 5 Feb 2022 17:25:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C16A33858419 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1644081951; bh=JO+peiT2qapc8uTy4lFCvmdwGh3ltWUWvV6plZ+JR+s=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=yHY4/UygvrfGkcLmCWEyCpJveg7Yhfr9cIAG3MtHWIgIEqY5HPyo3YzFzH37yfyXI 3xz7fz3WZTugfeNWiIdxY+XzyTwWfG3l3TNd3OZiqDrR0TjZIOfdiKQ0sKI0dhAa3k ohZvVDCI/CBRntwjC4aJFjGQD9jdYYVyh7iRpxtE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by sourceware.org (Postfix) with ESMTPS id AFEA23858415 for <libc-alpha@sourceware.org>; Sat, 5 Feb 2022 17:24:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AFEA23858415 Received: by mail-pl1-x630.google.com with SMTP id c9so7836123plg.11 for <libc-alpha@sourceware.org>; Sat, 05 Feb 2022 09:24:48 -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=JO+peiT2qapc8uTy4lFCvmdwGh3ltWUWvV6plZ+JR+s=; b=p/j3bCpkqzZ5Xguu/pNEJyegYvBEOkR5u47YhtUCTVWUoqq7S1+SGCjxrIDWDLn3RB jzW5umrE0NqwlMvg5isk37OdJPK3mnX8ZK++bdK2MuJ+Jq0e/gKkK54I+BG9pKDViU5V qJ3Gc9WmWMScr5Zx6Ff4ix66KDyB63IV7bWvI5mQWIMExdTosUTCyyk2JviX7F9pOsgV q692sWE8hnOkXw33lvAThj2t8Cv5GId1Dw/8FHURnjX0mgXIrsAPKgUdUU25iBlSQlQw ct/PjdK1mH6TiWYcvTNCvP3nk0053ntDFpdMOj6YojLhVbtPSsr5Z5H5iU2NA0LRKsz1 2vfA== X-Gm-Message-State: AOAM531KJGtDyKyBzr+ZmQG3T9H7qeKXVu87vaN1i7IlwQq53Ei7on1J OzwrmgunEhVNHAvMcQBTvqw= X-Google-Smtp-Source: ABdhPJzDCr8B/v1cnySemwRfvIg+EprK6+nYd9fmxFd+HG8z+u9/s5HNqM6VHqmZSMzzH6em6VJVyg== X-Received: by 2002:a17:903:22c2:: with SMTP id y2mr8857906plg.132.1644081887661; Sat, 05 Feb 2022 09:24:47 -0800 (PST) Received: from gnu-tgl-2.localdomain ([172.58.38.240]) by smtp.gmail.com with ESMTPSA id q2sm7041550pfj.94.2022.02.05.09.24.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Feb 2022 09:24:47 -0800 (PST) Received: from gnu-tgl-2.. (localhost [IPv6:::1]) by gnu-tgl-2.localdomain (Postfix) with ESMTP id 6B2D13004A3; Sat, 5 Feb 2022 09:24:46 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 0/7] Support DT_RELR relative relocation format Date: Sat, 5 Feb 2022 09:24:39 -0800 Message-Id: <20220205172446.652011-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3023.1 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
Feb. 5, 2022, 5:24 p.m. UTC
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 nd the architecture defines SUPPORT_DT_RELR in config.h. At the moment, only x86 targets define SUPPORT_DT_RELR. 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 (6): elf: Properly handle zero DT_RELA/DT_REL values Add GLIBC_ABI_DT_RELR for DT_RELR support x86/configure.ac: Define PI_STATIC_AND_HIDDEN/SUPPORT_STATIC_PIE x86: Define SUPPORT_DT_RELR Add --disable-default-dt-relr NEWS: Mention DT_RELR support INSTALL | 6 +++ Makeconfig | 19 +++++++++ Makerules | 2 + NEWS | 2 +- config.h.in | 3 ++ configure | 80 +++++++++++++++++++++++++++++++++++++ configure.ac | 33 +++++++++++++++ elf/Makefile | 36 +++++++++++++++-- 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 +++- sysdeps/i386/configure | 6 --- sysdeps/i386/configure.ac | 7 ---- sysdeps/x86/configure | 9 +++++ sysdeps/x86/configure.ac | 10 +++++ sysdeps/x86_64/configure | 6 --- sysdeps/x86_64/configure.ac | 7 ---- 26 files changed, 383 insertions(+), 39 deletions(-) create mode 100644 elf/libc-abi-version.exp create mode 100644 elf/tst-relr-pie.c create mode 100644 elf/tst-relr.c