Date: Mon, 26 May 2025 15:24:32 +0200 From: Dimitry Andric <dim@FreeBSD.org> To: "Bjoern A. Zeeb" <bzeeb-lists@lists.zabbadoz.net> Cc: "current@freebsd.org" <current@FreeBSD.org> Subject: Re: (arm64) link_elf: symbol __floatundidf undefined ... Message-ID: <F702EB0A-1265-4F82-AF19-655B6767AE14@FreeBSD.org> In-Reply-To: <B8278D86-38F2-4792-839B-2246A5C9A2E2@FreeBSD.org> References: <0r5n4p87-3pn0-3247-8n6q-n20qn0ro27r9@yvfgf.mnoonqbm.arg> <74650476-D42E-4074-A18F-D7F474EC271B@FreeBSD.org> <n773q04n-p268-581p-o4qs-595412n0qr7s@yvfgf.mnoonqbm.arg> <B8278D86-38F2-4792-839B-2246A5C9A2E2@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 26 May 2025, at 15:15, Dimitry Andric <dim@FreeBSD.org> wrote:
>=20
> On 26 May 2025, at 15:05, Bjoern A. Zeeb =
<bzeeb-lists@lists.zabbadoz.net> wrote:
>>=20
>> On Mon, 26 May 2025, Dimitry Andric wrote:
>>=20
>> Hi,
>>=20
>> thanks for the quick answer.
>>=20
>>> On 26 May 2025, at 14:25, Bjoern A. Zeeb =
<bzeeb-lists@lists.zabbadoz.net> wrote:
>>>>=20
>>>> I've just compiled and installed a new arm64/main with my own =
kernel
>>>> config to have wifi bits as modules.
>>>>=20
>>>> I am a bit puzzed as to where this comes from in the kernel.
>>>>=20
>>>> # kldload wlan
>>>> link_elf: symbol __floatundidf undefined: 0xffff000143ed1370 =
0xffff000143ecf9f0 11496 0xffff000143ed26d8 0x2
>>>> kldload: can't load wlan: No such file or directory
>>>>=20
>>>> % nm modules/usr/src/sys/modules/wlan/wlan.ko.full | grep float
>>>>               U __floatundidf
>>>>=20
>>>> Anyone any idea?
>>>=20
>>> _Something_ is converting a unsigned long to a double, but what? Can =
you figure out which object file it is?
>>=20
>> % nm ieee80211_ioctl.o | grep __floatundidf
>>                U __floatundidf
>>=20
>> This may be a local change I have adding an extra 10% of space in the
>> ioctl code to accomodate for enlargement of a result set for testing.
>> size_t space;
>> ...
>> space *=3D 1.10;
>>=20
>> Given it's likely that it's that I think the real question is, why is =
this
>> not an issue on amd64 but on arm64 as I've been running that change =
for
>> days on amd64?
>=20
> My guess is that it's inlined on amd64. For me simple cases also =
inline on arm64, but maybe you are doing something more complicated:
>=20
> $ cat convert.c
> #include <stddef.h>
>=20
> size_t f(size_t s)
> {
>  return s * 1.10;
> }
>=20
> $ cc -target aarch64-freebsd -S convert.c -o -
>        .text
>        .file   "convert.c"
>        .section        .rodata.cst8,"aM",@progbits,8
>        .p2align        3, 0x0                          // -- Begin =
function f
> .LCPI0_0:
>        .xword  0x3ff199999999999a              // double =
1.1000000000000001
>        .text
>        .globl  f
>        .p2align        2
>        .type   f,@function
> f:                                      // @f
>        .cfi_startproc
> // %bb.0:                               // %entry
>        sub     sp, sp, #16
>        .cfi_def_cfa_offset 16
>        str     x0, [sp, #8]
>        ldr     d0, [sp, #8]
>        ucvtf   d0, d0
>        adrp    x8, .LCPI0_0
>        ldr     d1, [x8, :lo12:.LCPI0_0]
>        fmul    d0, d0, d1
>        fcvtzu  x0, d0
>        add     sp, sp, #16
>        .cfi_def_cfa_offset 0
>        ret
> .Lfunc_end0:
>        .size   f, .Lfunc_end0-f
>        .cfi_endproc
>                                        // -- End function
>        .ident  "FreeBSD clang version 19.1.7 =
(https://github.com/llvm/llvm-project.git =
llvmorg-19.1.7-0-gcd708029e0b2)"
>        .section        ".note.GNU-stack","",@progbits
>        .addrsig
Aha, the behavior changes when you use -mgeneral-regs-only (as in =
https://cgit.freebsd.org/src/tree/sys/conf/kern.mk#n140):
f:                                      // @f
	.cfi_startproc
// %bb.0:                               // %entry
	stp	x29, x30, [sp, #-16]!           // 16-byte Folded Spill
	.cfi_def_cfa_offset 16
	mov	x29, sp
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	bl	__floatundidf
	mov	x1, #-7378697629483820647       // =3D0x9999999999999999
	movk	x1, #39322
	movk	x1, #16369, lsl #48
	bl	__muldf3
	bl	__fixunsdfdi
	.cfi_def_cfa wsp, 16
	ldp	x29, x30, [sp], #16             // 16-byte Folded Reload
	.cfi_def_cfa_offset 0
	.cfi_restore w30
	.cfi_restore w29
	ret
Hence, try to refrain from using doubles. :) Your use case should also =
be covered with:
  space =3D (space * 110 + 50) / 100
-Dimitry
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?F702EB0A-1265-4F82-AF19-655B6767AE14>
