From patchwork Fri Sep 1 20:42:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719519 Delivered-To: patch@linaro.org Received: by 2002:adf:d08b:0:b0:31d:da82:a3b4 with SMTP id y11csp466881wrh; Fri, 1 Sep 2023 13:43:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF/VXSv4VTCpPbsHIssUCQDEqwzeL2bDFkVFVPfYnR4i/2TMCYcADmvebbZDUsmduRBWIdV X-Received: by 2002:a05:620a:1aa4:b0:76d:aa23:f8e1 with SMTP id bl36-20020a05620a1aa400b0076daa23f8e1mr4291508qkb.27.1693601019955; Fri, 01 Sep 2023 13:43:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693601019; cv=none; d=google.com; s=arc-20160816; b=Pwe6tGz6mD6vACltlLG/SXLOt9dGq0Fc6dPsFDqm+lOabI+L1rzvdx3sdGzbp7HaI2 d46UyoF0/pGOK1rl4bdeRB8G8JivXlPl/VdPPF6uc/Na9KjIdgxuf4EoN6a5y7cqmf2j sXu+f9HxNaMyA0FLcu0AMkRikPfYeTHfC5obtmWu0DmJnRN+9Tm9B620r3hsKT5jTh6a fdOI1cHCplCBp0siraxPNVRCB5jb1JnRXx2qYVFDwMBFyhZK1Np9c16ggRneVIWogjmR Q1WV6+Ap/WrDc9BO7lsqPEOO0JWo0xNU1huH40v2xV0IfqqSsGH9rSiOnex2dK2Xnqp2 C75w== 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=Ll7Fcerm+Jswr+2aKJK47stIuMjiaUzk13pA9L+5+w4=; fh=fBRXHUj60rk5luGLPRGw8IH8EbaZu8RlH695BHD58a8=; b=I8bON/vxRcZBKzsY2CSeocIJvl2H/Bjuj+XQ7ggImv+95Ty64t886Il9zTab4qG1FS tzI0Wiz9ymRjBG5TerJx7DQcXHbWeKH4p5dAvDz97be0QXV5AHqcXknhCtVRMJL/mE0Y zqWTmn/mlM1BQh+VIW0fxBKND2I8epUhmqSf/3Ldtmaj5mlIZM83bxz5pAA+7/SECLp4 rHiHzBN3sKwLGbun1QaQc8T0TlBTE71e1qToULoJmedIHD+71d1wMqen0vN2DS4mx1iW c9/IBFPPguTXnll7uWbi16CO+WiGwiw1uw1G2e9GzDJQ/EEoFMnbn/vAZNYMBU5b/bAM 0q4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mTuoqtqH; 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 i17-20020a05620a249100b007671cacee6csi3279076qkn.113.2023.09.01.13.43.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Sep 2023 13:43:39 -0700 (PDT) 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=mTuoqtqH; 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 1qcAyu-0006yW-MT; Fri, 01 Sep 2023 16:43:06 -0400 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 1qcAyr-0006xv-TH for qemu-devel@nongnu.org; Fri, 01 Sep 2023 16:43:01 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcAyp-0001xK-EN for qemu-devel@nongnu.org; Fri, 01 Sep 2023 16:43:01 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-68a42d06d02so2060523b3a.0 for ; Fri, 01 Sep 2023 13:42:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693600978; x=1694205778; 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=Ll7Fcerm+Jswr+2aKJK47stIuMjiaUzk13pA9L+5+w4=; b=mTuoqtqHphL1rODik5Se1W8KUGmaWNZhfI1X3w/A1JXLJrjlnURoVV8JjWX2EoCe9m iE5E5x8pDhm2HJf6400WiRC/tWaJPM22jLDE1mLtV4nLb1fesO9gE5lznoXm1ijAMDAQ C+QiCYHO3KQgyj6u/T24Fd5FYwBLmDxTktuWupQMjPW1aEfmK/Lx0moEkpNoUdC9snQn MaOdUqaXPVzB/xCNdWk8hHvJX7FxUmO04c0H5vT165YKAj9x+uq7OhEijXPnFjDe6l0x qmXZ0rFJn8HOykKt7y/PCIvjT4kSZS/7zQ5tXsPHjrNk5Rp60pR/fhZzOvkkdBoY3If4 xOlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693600978; x=1694205778; 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=Ll7Fcerm+Jswr+2aKJK47stIuMjiaUzk13pA9L+5+w4=; b=gsDLDW822ZRfNE6cjDihDujIJREnResSE3O0I2TXV3fxShcYBZiqqaBpi01nd8F+mf 7U29BHdqt4JU2fPG4j5YZas2MlVNEPZj47L0JYbcRQXA6IY6H6i3pM2WSUsGfdOIDpJg IqY6jsUijN3ZWmiNGDFVHR7BBxUSBDmM2VQLqYK/M5QmkiOSFJpGmJdEOoJR4m411o3i x9ifcBS79Ett5wHZQkjR7fExGNyWjrsnNZsAMt00NAxAHK+MnGp1G6KPMRkVZhT7D314 mkKaAxP7iCjKI+L/R7ikIC1vhBKdGAqKxr48G/a0MIz8XezwqVGtR//Uf18MwQy6lWrt rsiw== X-Gm-Message-State: AOJu0Yym0/qvCf0asabgt99o1R5RqesnskLVFhLpx0tx5FarWh9Wsvze WtUjdgxORn/JGvCP1lf6NSHTfSPEQdOmcnFkQrU= X-Received: by 2002:a05:6a00:1587:b0:68c:42:d3d7 with SMTP id u7-20020a056a00158700b0068c0042d3d7mr4219861pfk.25.1693600978168; Fri, 01 Sep 2023 13:42:58 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id j15-20020aa78d0f000000b0068c97a4eb0dsm3320666pfe.191.2023.09.01.13.42.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 13:42:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Helge Deller , Ilya Leoshkevich , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 06/13] linux-user: Adjust brk for load_bias Date: Fri, 1 Sep 2023 13:42:44 -0700 Message-Id: <20230901204251.137307-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901204251.137307-1-richard.henderson@linaro.org> References: <20230901204251.137307-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 PIE executables are usually linked at offset 0 and are relocated somewhere during load. The hiaddr needs to be adjusted to keep the brk next to the executable. Cc: qemu-stable@nongnu.org Fixes: 1f356e8c013 ("linux-user: Adjust initial brk when interpreter is close to executable") Tested-by: Helge Deller Reviewed-by: Ilya Leoshkevich Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- 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 7c95098e3e..d52d47c5c3 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -3327,7 +3327,7 @@ static void load_elf_image(const char *image_name, int image_fd, info->start_data = -1; info->end_data = 0; /* Usual start for brk is after all sections of the main executable. */ - info->brk = TARGET_PAGE_ALIGN(hiaddr); + info->brk = TARGET_PAGE_ALIGN(hiaddr + load_bias); info->elf_flags = ehdr->e_flags; prot_exec = PROT_EXEC;