Re: [PATCH 2/3] selftests/nolibc: avoid function pointer comparisons

Helge Deller <[email protected]>
Newsgroups org.kernel.vger.linux-parisc,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On 4/7/26 18:37, Thomas Weißschuh wrote:
> The upcoming parisc support would require libgcc to implement function
> pointer comparisons. As we try to avoid the libgcc dependency rework
> the logic to work without such comparisons.

Instead of working around at this specific code, I think it makes more sense
to simply add the __canonicalize_funcptr_for_compare() symbol somewhere.
Code is in arch/parisc/kernel/real2.S:
  
ENTRY_CFI(__canonicalize_funcptr_for_compare)
#ifdef CONFIG_64BIT
         bve (%r2)
#else
         bv %r0(%r2)
#endif
         copy %r26,%r28
ENDPROC_CFI(__canonicalize_funcptr_for_compare)

Or am I missing something?

Btw, since you want to avoid libgcc, I think this is quite hard, since
gcc automatically adds lots of parisc specific millicode functions (see the "$$" symbols
in parisc_ksyms.c) and many of the gcc helper functions (e.g. __muldi3).

So, I'm not sure if it makes sense to try to avoid libgcc....

Helge
  
> Signed-off-by: Thomas Weißschuh <[email protected]>
> ---
>   tools/testing/selftests/nolibc/nolibc-test.c | 13 +++++++++----
>   1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
> index d3c4facb54c0..de4e87586d75 100644
> --- a/tools/testing/selftests/nolibc/nolibc-test.c
> +++ b/tools/testing/selftests/nolibc/nolibc-test.c
> @@ -647,20 +647,25 @@ int expect_str_buf_eq(size_t expr, const char *buf, size_t val, int llen, const
>   	return 0;
>   }
>   
> +enum strtox_func {
> +	strtox_func_strtol,
> +	strtox_func_strtoul,
> +};
> +
>   #define EXPECT_STRTOX(cond, func, input, base, expected, chars, expected_errno)				\
> -	do { if (!(cond)) result(llen, SKIPPED); else ret += expect_strtox(llen, func, input, base, expected, chars, expected_errno); } while (0)
> +	do { if (!(cond)) result(llen, SKIPPED); else ret += expect_strtox(llen, strtox_func_ ## func, input, base, expected, chars, expected_errno); } while (0)
>   
>   static __attribute__((unused))
> -int expect_strtox(int llen, void *func, const char *input, int base, intmax_t expected, int expected_chars, int expected_errno)
> +int expect_strtox(int llen, enum strtox_func func, const char *input, int base, intmax_t expected, int expected_chars, int expected_errno)
>   {
>   	char *endptr;
>   	int actual_errno, actual_chars;
>   	intmax_t r;
>   
>   	errno = 0;
> -	if (func == strtol) {
> +	if (func == strtox_func_strtol) {
>   		r = strtol(input, &endptr, base);
> -	} else if (func == strtoul) {
> +	} else if (func == strtox_func_strtoul) {
>   		r = strtoul(input, &endptr, base);
>   	} else {
>   		result(llen, FAIL);
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.