From patchwork Mon Oct 18 18:00:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 46359 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 3B4A33858433 for ; Mon, 18 Oct 2021 18:01:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3B4A33858433 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1634580097; bh=BAWa90iShdP41waPGnPV6AcjU0+LkSI5IA1hJb/otzo=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=qMclp2TVhy1JrY+t4H5vnyptoIdOeYorwz+e5SxvAy2rEdny9Dns2ZdBbt6fCbBZJ 9Yx68ZIyj7vI08vWXZxVH+e1lFHQJjz/W01rl7x+xnC3tFLVveUXhuB2ML9EHwP5OG rfGigkZ8ojCUCmEfTA6unr8hpLTX3bEbk9+5oDCc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by sourceware.org (Postfix) with ESMTPS id 5B2053858433 for ; Mon, 18 Oct 2021 18:00:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5B2053858433 Received: by mail-pj1-x1031.google.com with SMTP id nn3-20020a17090b38c300b001a03bb6c4ebso590937pjb.1 for ; Mon, 18 Oct 2021 11:00:27 -0700 (PDT) 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=BAWa90iShdP41waPGnPV6AcjU0+LkSI5IA1hJb/otzo=; b=OwtgJhS+pgdEGYKSk3FDWun7Lt5sSmIlGO/zshtosd6an0qtYGD155u7fr0KtWnK7Z AV943IEZP/MNhm98VuPTTjf1xXZXmteN2v6jha4OYskaWsupEo9A5o61hS7FL1ioAMsX 0MF/Fbj9AUbqbPBg4cRYrvKd1Hekrve+N1xmghiRbJWPJl6b0hexY0FAqHSSx9qgEVfl af1ZN8xyz7p8WiWr2MlwgnHbeh7uXDc0/VWMiDlYQy4QX6PKUCReZpDPSRT9GVfKlhr9 /xHSmeh65cEgvxftndzgl9yXfsYmm8jOyl16mHQUwMLejbkq+DUnnWinMtED6LcURjfF ieog== X-Gm-Message-State: AOAM531smnbvOFkP+6QHG7zl4SexHOzXRXbFYXOUjo9pbOmjvoFndvmi 9NyT1UeDiserKkOoVw6c3uU= X-Google-Smtp-Source: ABdhPJxadwLXAVPGUQOiK45MGMiP2jCKi7dBnzIht6lurzvep8BqYySMbmQG+P5KMe9SsahtNijZcw== X-Received: by 2002:a17:90a:642:: with SMTP id q2mr418499pje.55.1634580026411; Mon, 18 Oct 2021 11:00:26 -0700 (PDT) Received: from gnu-cfl-2.localdomain ([172.58.39.6]) by smtp.gmail.com with ESMTPSA id r8sm13882579pgp.30.2021.10.18.11.00.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 11:00:26 -0700 (PDT) Received: from gnu-cfl-2.lan (localhost [IPv6:::1]) by gnu-cfl-2.localdomain (Postfix) with ESMTP id F2DCD1A041B; Mon, 18 Oct 2021 11:00:24 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v3] ld.so: Initialize bootstrap_map.l_ld_readonly [BZ #28340] Date: Mon, 18 Oct 2021 11:00:24 -0700 Message-Id: <20211018180024.2009071-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Spam-Status: No, score=-3032.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "H.J. Lu via Libc-alpha" From: "H.J. Lu" Reply-To: "H.J. Lu" Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Before calling elf_get_dynamic_info to get dynamic info in bootstrap_map, initalize bootstrap_map.l_ld_readonly with BOOTSTRAP_MAP_RO_DYN_SECTION. This updates BZ #28340 fix. --- elf/rtld.c | 1 + sysdeps/generic/dl-relocate-ld.h | 3 +++ sysdeps/mips/dl-relocate-ld.h | 3 +++ sysdeps/riscv/dl-relocate-ld.h | 4 ++++ 4 files changed, 11 insertions(+) diff --git a/elf/rtld.c b/elf/rtld.c index c66a1d00bc..51a471e6b7 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -547,6 +547,7 @@ _dl_start (void *arg) /* Read our own dynamic section and fill in the info array. */ bootstrap_map.l_ld = (void *) bootstrap_map.l_addr + elf_machine_dynamic (); + bootstrap_map.l_ld_readonly = BOOTSTRAP_MAP_RO_DYN_SECTION; elf_get_dynamic_info (&bootstrap_map, true, false); #if NO_TLS_OFFSET != 0 diff --git a/sysdeps/generic/dl-relocate-ld.h b/sysdeps/generic/dl-relocate-ld.h index 5fae206db9..09c7ba0448 100644 --- a/sysdeps/generic/dl-relocate-ld.h +++ b/sysdeps/generic/dl-relocate-ld.h @@ -19,6 +19,9 @@ #ifndef _DL_RELOCATE_LD_H #define _DL_RELOCATE_LD_H +/* The dynamic section in bootstrap_map is writable. */ +#define BOOTSTRAP_MAP_RO_DYN_SECTION 0 + /* Return true if dynamic section in the shared library L should be relocated. */ diff --git a/sysdeps/mips/dl-relocate-ld.h b/sysdeps/mips/dl-relocate-ld.h index 0c18d9a567..2c4edbe9f4 100644 --- a/sysdeps/mips/dl-relocate-ld.h +++ b/sysdeps/mips/dl-relocate-ld.h @@ -19,6 +19,9 @@ #ifndef _DL_RELOCATE_LD_H #define _DL_RELOCATE_LD_H +/* The dynamic section in bootstrap_map is readonly. */ +#define BOOTSTRAP_MAP_RO_DYN_SECTION 1 + /* Return true if dynamic section in the shared library L should be relocated. */ diff --git a/sysdeps/riscv/dl-relocate-ld.h b/sysdeps/riscv/dl-relocate-ld.h index 10327454b1..240f85b79e 100644 --- a/sysdeps/riscv/dl-relocate-ld.h +++ b/sysdeps/riscv/dl-relocate-ld.h @@ -19,6 +19,10 @@ #ifndef _DL_RELOCATE_LD_H #define _DL_RELOCATE_LD_H +/* The dynamic section in bootstrap_map is writable. This is ignored + on RISC-V. */ +#define BOOTSTRAP_MAP_RO_DYN_SECTION 0 + /* Return true if dynamic section in the shared library L should be relocated. */