Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4B470C433FE for ; Wed, 23 Nov 2022 23:15:28 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B9AF7855CC; Thu, 24 Nov 2022 00:15:25 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="Y2tJFVb3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A7361855CD; Thu, 24 Nov 2022 00:15:23 +0100 (CET) Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 33744855C7 for ; Thu, 24 Nov 2022 00:15:21 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qt1-x82a.google.com with SMTP id z6so180513qtv.5 for ; Wed, 23 Nov 2022 15:15:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=EQ5YomkM7lJrYuxVtXTI5vtAA3HEcUEpoXMApmJZMYg=; b=Y2tJFVb38SSyAwAKE54+6RSVsl8buaNc166G8HIvKkOj3LF7NrhDhd8PF20cK3VfeA RU6jFaYxpC8IqY7PsVOdEdEj/N+3eDk/DfNs8zF0KU2R3zT30ZLzI5IC7H8/9bSQnOFs hm6GBNjEXnKD165DMdSyBQMtAw0T9ovCp9yNA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=EQ5YomkM7lJrYuxVtXTI5vtAA3HEcUEpoXMApmJZMYg=; b=x8nmzjoel58Jj9kADZ0csPjqn1Tgj9+3Wnav00UbC3S4FeECEe0rdminMvqsQDM6nH ebZALpbmNZiCVwXqET68GQxzowRu0mV1fXHfV7WRdsJwhuF6r7wdsNoUcyu/ktMW/O/V WWKWktptnHjIoJO4ZAJCyx9POUbJuWAwXGns4yoCg/QlU5Cz79weUDUBUTtXE7vVtNEU j68Lj/kTv0xEE2xkIH5+nogmT6euuIjRaUlhHDglpVMywGKv6zUV8iB8OI8s4Mpd9Tba W5sblHP2NpkaKtnnQ3nCrFicS6LoSZht/WZJONOCAxWvP2Z6Hwm8IDvQLkXA6vMwmhMu /Tbw== X-Gm-Message-State: ANoB5pkjY5K7J5+DTaAq5padwN4uze0sQYrV1R+VIhHcodTov82XBl3q vLvBuw2+ApLyRzZmADLBf8UKpFv4R5oJPg== X-Google-Smtp-Source: AA0mqf44nagvtpcRB35Kt8goLCvWJNbbHu6UUkDg1b6JJiEamFhzhkkJJ1iMd1oO+SxQurm8N04BiQ== X-Received: by 2002:ac8:4d4e:0:b0:3a6:5afc:9a20 with SMTP id x14-20020ac84d4e000000b003a65afc9a20mr5174451qtv.183.1669245319924; Wed, 23 Nov 2022 15:15:19 -0800 (PST) Received: from bill-the-cat (2603-6081-7b00-6400-b4e9-18be-6c79-e0de.res6.spectrum.com. [2603:6081:7b00:6400:b4e9:18be:6c79:e0de]) by smtp.gmail.com with ESMTPSA id x10-20020a05620a258a00b006bb82221013sm13013787qko.0.2022.11.23.15.15.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 15:15:19 -0800 (PST) Date: Wed, 23 Nov 2022 18:15:17 -0500 From: Tom Rini To: Pali =?iso-8859-1?Q?Roh=E1r?= Cc: u-boot@lists.denx.de Subject: Re: [PATCH 4/6] arm: Use the WEAK assembly entry point consistently Message-ID: <20221123231517.GD3787616@bill-the-cat> References: <20221122173158.2231821-1-trini@konsulko.com> <20221122173158.2231821-4-trini@konsulko.com> <20221123225059.4vjzixzmzjwvgfxi@pali> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Ycz6tD7Th1CMF4v7" Content-Disposition: inline In-Reply-To: <20221123225059.4vjzixzmzjwvgfxi@pali> X-Clacks-Overhead: GNU Terry Pratchett X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean --Ycz6tD7Th1CMF4v7 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Nov 23, 2022 at 11:50:59PM +0100, Pali Roh=E1r wrote: > On Tuesday 22 November 2022 12:31:56 Tom Rini wrote: > > It is a bad idea, and more modern toolchains will fail, if you declare > > an assembly function to be global and then weak, instead of declaring it > > weak to start with. Update assorted assembly files to use the WEAK macro > > directly. > >=20 > > Signed-off-by: Tom Rini >=20 > During debugging of Nokia N900 code I was looking at this and I > originally thought that this redefinition is the issue why N900 u-boot > did not work... (but as we now know, the n900 issue was somewhere else). >=20 > So I agree with this change, feel free to add my: >=20 > Reviewed-by: Pali Roh=E1r >=20 > ... but even after this change, linked u-boot.bin binary is > not-so-correct. It works but has an issue: In final u-boot.bin binary > there is both weak and non-weak version of every weak function. You can > verify it for example by looking at "save_boot_params" code (really > code, not just symbol) in u-boot ELF binary. >=20 > The reason for this is that linker (even LTO enabled) cannot eliminate > code for weak version of function because it does not know how to > "drop" it from binary/assembly code. So linker just set that non-weak > version of function is active and let non-weak version present in binary > as probably dead code. >=20 > This is affected only by assembly files, not by C files, because gcc is > called with -ffunction-sections -fdata-sections flags which cause that > every (weak) function is in its separate section (so C function > "int abc() { ... }" is put into the section ".text.abc" instead of > ".text") and linker's flag --gc-sections (or LTO optimization) then drop > all unreferenced sections. >=20 > I do not know how fix this issue in assembly files. But cannot be WEAK > macro modified to change section to ".text." to mimic C > compiler behavior? Would this cause any issues? Yes, you're right about the cause, and potential solution. If you can come up with a way to get each assembly function put in to a separate =2Etext.funcname section, that would be great and much appreciated. I think I tried this at one point a long long time ago and it did work, but I didn't have something clean, either. I think I was hoping that the linux kernel folks would solve it in time, but they decided the time/effort for --gc-sections wasn't worth it, in the end. --=20 Tom --Ycz6tD7Th1CMF4v7 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmN+qYIACgkQFHw5/5Y0 tyyVLwv9ECl5dpCiUILkV7viSq5UQcqlLFkdRC7NgvUdNeILU8SqeHSrnvV+8O6I Wvbvc0PmPfjCryMuY4ijVKqtbMMMVype3+zryD5VKFsb/xZxtbGkJh3WajfYs0W1 ChXLXjpCfVt31AxPxJ53SD8tXoAA4Vme+D+uvsyJuBxV8Me7kx0D0s4yTNFnhINt oOcIMDHqo6qoWYFNOyITmDRFbplIXVq9/kUQhOZykiJDGpT6QOdw2EtrOJrRrwtz 7KHy+vDz5YDD0krkrAOnLLNbWW5DKQANJk2MSJU5uLMbv5GvGQvGAKKnyiGt1z1q C/P0QEjydLAPYQCJJ9Vd45qsKHAFiv/AgjtRX9VOC8Q8aXFTwwwEQEVXeK5iXLmB 8mWHBpvwGC+9GHokXQs3Llvy8LeCGwpIfA+VixQ8Qd8Kav3FMBIYMvSH+rRf40cc gglKqAaP+VaqTG+qqKCGOiScLh5j1QpMj23zWwDXypPinLdK0FRuNy7gFlgU3wsr pNneOmU2 =25Hq -----END PGP SIGNATURE----- --Ycz6tD7Th1CMF4v7--