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 88669C46467 for ; Thu, 5 Jan 2023 00:09:25 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6DE6E85587; Thu, 5 Jan 2023 01:09:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1672877363; bh=ypCmqvDTIYmxQdP2buAkpv0LMBDUX3JKI294P8OK0/Q=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=r8vsr0wDUA4H+WugImcxdML4E/tST0Z/fY7oZRZhXt7iNwt7rkNncBKP08WR2c8zy 3gF8conu4svDjcnMagSz/i/bBccjP+e+4q9XEJLDjHbCW5TxSvKUS1PV2Xap2UMiDn aOXvn02py1QiVtobyc3lhQ1/wbQCefSuVASAI4BQiLFAtlwJ6gBMH2tpiRO+jL1BxR KEY9sSvPgGCj2i7CgI5MsjblDFyj+y28JOyUEUQSP2hqDHXRvBxvmjybbHkBv/aZqX o7wdKu1YeiAEI32TUfUmMpUDZ4A9yoh4frahAgsVkW19qaUykV+biHZUAa/+IR+Lgo iWglrXxPooTAQ== Received: from sandvich.rahix.net (p200300ea271e8cff0000000000001e8c.dip0.t-ipconnect.de [IPv6:2003:ea:271e:8cff::1e8c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: hws@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 4A3ED85568; Thu, 5 Jan 2023 01:09:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1672877360; bh=ypCmqvDTIYmxQdP2buAkpv0LMBDUX3JKI294P8OK0/Q=; h=From:To:Cc:Subject:Date:From; b=STCU1nLThCfbvGRghx5e4BFxZ5oZwmq3tGidgRX4x2QnqOoHk+9Fdwa7/XQ5apza0 5FuC8aqmhaCyrvd28b7VU7ABEfjP6LPfRk2vgaW+sbPsjXUoahUY1oAtw5Tsbvxdy+ mt4SW2LsvwKwr0gTxJvXhDr3Xu4L69krEf9jOvxj1HbhnkDwaJyT6ewIC38Km4QkaA rgrfxfXtSaBPRjlxwDPD9C2eyxHD5yngXp7qs/7PiQjLvDMZQQmcCVcS+Bqh4rkQeU 7FKPJknoTM4yLnTFxtTWSfAFvlt9dJlZ1zE816/W7BgFbJgMQWuMyewCj7eNX51u2G WpTkjhZas46mQ== From: Harald Seiler To: u-boot@lists.denx.de Cc: Rob Herring , Simon Glass , Harald Seiler , Serge Bazanski Subject: [PATCH] Revert "time: add weak annotation to timer_read_counter declaration" Date: Thu, 5 Jan 2023 01:08:47 +0100 Message-Id: <20230105000847.151464-1-hws@denx.de> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 This reverts commit 65ba7add0d609bbd035b8d42fafdaf428ac24751. A weak extern is a nasty sight to behold: If the symbol is never defined, on ARM, the linker will replace the function call with a NOP. This behavior isn't well documented but there are at least some hints to it [1]. When timer_read_counter() is not defined, this obviously does the wrong thing here and it does so silently. The consequence is that a board without timer_read_counter() will sleep for random amounts and generally have erratic get_ticks() values. Drop the __weak annotation of the extern so a linker error is raised when timer_read_counter() is not defined. This is okay, the original reason for the reverted change - breaking the sandbox build - no longer applies. Final sidenote: This was the only weak extern in the entire tree at this time as far as I can tell. I guess we should avoid introduction of them again as they are obviously a very big footgun. [1]: https://stackoverflow.com/questions/31203402/gcc-behavior-for-unresolved-weak-functions Fixes: 65ba7add0d60 ("time: add weak annotation to timer_read_counter declaration") Reported-by: Serge Bazanski Signed-off-by: Harald Seiler --- lib/time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/time.c b/lib/time.c index f3aaf472d1..1e24b1b03c 100644 --- a/lib/time.c +++ b/lib/time.c @@ -63,7 +63,7 @@ ulong timer_get_boot_us(void) } #else -extern unsigned long __weak timer_read_counter(void); +extern unsigned long timer_read_counter(void); #endif #if CONFIG_IS_ENABLED(TIMER) -- 2.39.0