diff options
author | Harald Seiler <hws@denx.de> | 2023-01-05 01:08:47 +0100 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-01-12 14:06:16 -0500 |
commit | ea3d28ec31d64cd059683947746ac71c8a90a1f9 (patch) | |
tree | 244e5993ab9969fb4519f50ad0c6dccaf3d62535 | |
parent | f4426fd68d604fc3f823979d7f643938894df167 (diff) | |
download | u-boot-ea3d28ec31d64cd059683947746ac71c8a90a1f9.tar.gz |
Revert "time: add weak annotation to timer_read_counter declaration"
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 <q3k@q3k.org>
Signed-off-by: Harald Seiler <hws@denx.de>
-rw-r--r-- | lib/time.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/time.c b/lib/time.c index 82350260ea..0c95d12f61 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) |