From patchwork Fri Dec 10 12:39:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rongwei Wang X-Patchwork-Id: 48776 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 E2F5F3858036 for ; Fri, 10 Dec 2021 12:39:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E2F5F3858036 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1639139978; bh=uunETFUxnxlVU1+u2cPjyO0X3MqOXZVISF4KAAL9rK0=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=GBUimnHmI/8UG2jsb4+Kw6jJR9JsmbBhkO2rfO6xTdlQnhSvLm4il3i2L+Mcqodj0 VvBLerdGfg/wTFfiz8J3aSxzsZ5cjHbY6Jfuz8kk8VHr7YofgbUGBrAJHaQoMGHdF0 El0yBUcK2aLlRp/6DqL7/DSe8Uh8lEz3qlXmrcIk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from out30-44.freemail.mail.aliyun.com (out30-44.freemail.mail.aliyun.com [115.124.30.44]) by sourceware.org (Postfix) with ESMTPS id DDB363858D35 for ; Fri, 10 Dec 2021 12:39:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DDB363858D35 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R121e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=e01e04407; MF=rongwei.wang@linux.alibaba.com; NM=1; PH=DS; RN=5; SR=0; TI=SMTPD_---0V-9u4OF_1639139951; Received: from localhost.localdomain(mailfrom:rongwei.wang@linux.alibaba.com fp:SMTPD_---0V-9u4OF_1639139951) by smtp.aliyun-inc.com(127.0.0.1); Fri, 10 Dec 2021 20:39:12 +0800 To: libc-alpha@sourceware.org, hjl.tools@gmail.com, fweimer@redhat.com Subject: [PATCH v5 0/2] fix p_align on PT_LOAD segment in DSO isn't honored Date: Fri, 10 Dec 2021 20:39:09 +0800 Message-Id: <20211210123911.86568-1-rongwei.wang@linux.alibaba.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211204045848.71105-1-rongwei.wang@linux.alibaba.com> References: <20211204045848.71105-1-rongwei.wang@linux.alibaba.com> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, UNPARSEABLE_RELAY, USER_IN_DEF_SPF_WL 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: Rongwei Wang via Libc-alpha From: Rongwei Wang Reply-To: Rongwei Wang Cc: xuyu@linux.alibaba.com, gavin.dg@linux.alibaba.com Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Hi This patch mainly to fix a reported bug: "p_align on PT_LOAD segment in DSO isn't honored" https://sourceware.org/bugzilla/show_bug.cgi?id=28676 A testcase had been builded by H.J.Lu: https://sourceware.org/bugzilla/attachment.cgi?id=13838 And in Patch 1/1, I also show a simple testcase which modified from H.J.Lu. And a similar bug in ELF binary was also reported: https://bugzilla.kernel.org/show_bug.cgi?id=215275 A related fix patch could been found: https://lore.kernel.org/linux-mm/20211009092658.59665-4-rongwei.wang@linux.alibaba.com/ Originally, we send this patch for introducing .text hugepages, was not aware of it's bug. And now, I am not sure whether kernel maintainer will regards it as a bug. But it deserved try again. Thanks. Changelog: v4 -> v5 - Patch "Add a testcase to check alignment of PT_LOAD segment" add new testcase for PT_LOAD segment - Patch "elf: Properly align PT_LOAD segments" fix map_start to use map_start_aligned when second mmap failed v3 -> v4 - Patch "elf: Properly align PT_LOAD segments" Call unmap when the second mmap fails. v2 -> v3 - Patch "elf: Properly align PT_LOAD segments" move mapalign into 'struct loadcmd' fix some coding style RFC/v1 -> v2 - Patch "elf: align the mapping address of LOAD segments with p_align" fix coding format and add testcase in commit. RFC link: https://patchwork.sourceware.org/project/glibc/patch/20211204045848.71105-2-rongwei.wang@linux.alibaba.com/ H.J. Lu (1): Add a testcase to check alignment of PT_LOAD segment Rongwei Wang (1): elf: Properly align PT_LOAD segments elf/Makefile | 14 +++++++++++-- elf/dl-load.c | 1 + elf/dl-load.h | 2 +- elf/dl-map-segments.h | 49 +++++++++++++++++++++++++++++++++++++++---- elf/tst-align3.c | 37 ++++++++++++++++++++++++++++++++ elf/tst-alignmod3.c | 31 +++++++++++++++++++++++++++ 6 files changed, 127 insertions(+), 7 deletions(-) create mode 100644 elf/tst-align3.c create mode 100644 elf/tst-alignmod3.c Reviewed-by: H.J. Lu