From patchwork Tue Nov 21 15:56:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 745698 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1956719wrt; Tue, 21 Nov 2023 07:57:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IH0U3bdoaN8HyOPy2mY/RYc0dczqFt1cDTPF2R+rMeiZ0Oyt14aeLu28ZtrMt1GXfTAhBF7 X-Received: by 2002:a05:6358:2911:b0:16b:a87a:3423 with SMTP id y17-20020a056358291100b0016ba87a3423mr11257897rwb.0.1700582273694; Tue, 21 Nov 2023 07:57:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700582273; cv=none; d=google.com; s=arc-20160816; b=J3aeVLJ4RKSe2Mbljp2ig5N0fwpdo6fk1Mt2X5OBZpgEaPbpfvmpyK24avmhqzihLh 0IIjZAqV61WPR8ZnDddPFX+wR62MtbaBd2xRwgsAoPbHHsR8bPETXV5R6vkY5pJBcAen Cl45dv+2EXl8Cg6MLUGcQZnPxzn0d89g6CxskoetVgMoa/mq/BAxdrV/1MZrUaPwDU7b 1ThAUNTpVCmftiOYON786R41M/AF0bFLiEtNE2TQAn39MAehR4v2cM01diQocY0faDEU Rr1OH0A5PyJLRCSbm96xG0Fdx4V2nnpQVaR0PrHs8YmQ1s+axwSd8hj59qB+L8QC38eh 6hcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CTjER+jT+9VVHqyYdg2i5cJ66ptGMsZM63IndAeZ5lQ=; fh=L7empYteKoZwGFCGMlp9qDTgHTnX02hHuViDUGZLQvE=; b=dBG90Rn+mGRnuGkV+Tq+6Hfci0X8xmi13mRkcSLtl5BO5BUrP32MrAnjIaqRl6uAKr yx447IuS2ZHRHQQZfVNRi+owasIjnCAqeAFFF5J3A/fJAvtxaec73FzCPzNB913WcfXV 25NU9YUWyKW+XlXxqUEVQl+VKZq5edvSBKfORO/Tbk6XqtGJ+N8WAGtURobq+OAFWAzQ oZUOAUDdjP2XY04L6R789QqJS9jaH5O+JDje0zgLZMAYBESAUR5OQFQlvmQ+NxVgymzQ S/uFVxAJRcW5E4U0xwLjlZb9qGR8+bJicjRfVzrPBQfTgO51Uq0G9kyNJic1C9SLqysf uM/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=X8Raq6ad; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id fv21-20020a05622a4a1500b0042370d03b88si1345799qtb.133.2023.11.21.07.57.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Nov 2023 07:57:53 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=X8Raq6ad; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5T7k-0004Xs-O0; Tue, 21 Nov 2023 10:57:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5T7i-0004WX-JM for qemu-devel@nongnu.org; Tue, 21 Nov 2023 10:57:14 -0500 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r5T7e-0002ea-VC for qemu-devel@nongnu.org; Tue, 21 Nov 2023 10:57:12 -0500 Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-6d7e6df999fso258060a34.1 for ; Tue, 21 Nov 2023 07:57:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700582229; x=1701187029; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CTjER+jT+9VVHqyYdg2i5cJ66ptGMsZM63IndAeZ5lQ=; b=X8Raq6adkF8U8A/h2PaFMKHTO2IGSfI3DLjKFv0gwunkMSeLH8DBYvnoTnaEc7HzBN usw58tznUSjKeS2aSJJR0/fJATviCbQaQvZziFXJWpu+guGNCtaOOq1o+VtuAUZ/HRR+ ieJXUHe5A1etZH9Lfs+yLFtBiO3OS+/zK27m6txnSAz8UFwAgD1WtvrUDyYpbjhhvU6C aKRm+uSGzTmcwIDgBSHxDfprNHE7arl0CHLHU1D9aet5dWejlR5KyKSU0z0sUuyXrhdY CzRFRzUAsten+HxQsC5OahZoMELy/id9SotgxgmulAMXmdAR7nUL9eXdIe4Gsq4B/SIh z3Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700582229; x=1701187029; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CTjER+jT+9VVHqyYdg2i5cJ66ptGMsZM63IndAeZ5lQ=; b=a5MttXxQ/7RVHYEykBC1oa6ncWrR9BHmO3XEjRbekk7AzS0Vlcz896WI5EEJtSAZQQ ik0Ui9m+ux8/PaUkwucUTEolxgeoaiRuTVirIxcwFxumvsArdkSOZvzIbpq9qFaPZmol IvRlVdVazhbw85qkPTbzTD+k/RptMc7S1J1YeMQ6gAF54L0n1JC/6myk4GMWJr0JLM2F Uo8faZua84sm3vP5F/4lslott0Qa86Z7G93s463mcFn/vl3KqZTVoh/+MDLCdpl7i1cb 6emggMihtJw4d26HwoKicgZQALhr5+CUt1nvFE1iBpKMUlR5Aef3eRxraFmIO2b8xeYz 2cuw== X-Gm-Message-State: AOJu0YytbCx4JLc7AbkzYTXjRs8ox1E8NkbVvI8zrldYlVSAgsBhq9g/ q6OxFzSEyvD5LZSxS/k4kw+ozSnCH3lJsqRW6LcnFg== X-Received: by 2002:a05:6830:6b81:b0:6d3:132a:5350 with SMTP id dd1-20020a0568306b8100b006d3132a5350mr11149313otb.11.1700582229667; Tue, 21 Nov 2023 07:57:09 -0800 (PST) Received: from stoup.. ([187.217.227.247]) by smtp.gmail.com with ESMTPSA id n22-20020a9d4d16000000b006cd0a04b56esm1543574otf.56.2023.11.21.07.57.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 07:57:09 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Michael Tokarev Subject: [PULL 1/1] linux-user: Fix loaddr computation for some elf files Date: Tue, 21 Nov 2023 09:56:57 -0600 Message-Id: <20231121155657.798505-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231121155657.798505-1-richard.henderson@linaro.org> References: <20231121155657.798505-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::329; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x329.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The file offset of the load segment is not relevant to the low address, only the beginning of the virtual address page. Cc: qemu-stable@nongnu.org Fixes: a93934fecd4 ("elf: take phdr offset into account when calculating the program load address") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1952 Signed-off-by: Richard Henderson Reviewed-by: Michael Tokarev --- linux-user/elfload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 4cd6891d7b..cf9e74468b 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -3308,7 +3308,7 @@ static void load_elf_image(const char *image_name, const ImageSource *src, for (i = 0; i < ehdr->e_phnum; ++i) { struct elf_phdr *eppnt = phdr + i; if (eppnt->p_type == PT_LOAD) { - abi_ulong a = eppnt->p_vaddr - eppnt->p_offset; + abi_ulong a = eppnt->p_vaddr & TARGET_PAGE_MASK; if (a < loaddr) { loaddr = a; }