Skip to contentSkip to conversation

lib/ldiv32.c breaks arm compilation

kvm-unit-tests BUG Alexandru Elisei 2 participants 5 messages May 11, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hello,

Commit 0b2d3dafc0d3 ("libcflat: provide long division routines"), which added the lib/ldiv32.c file, breaks compilation for the arm architecture; arm64 seems to be working just fine.

On Arch Linux:

$ ./configure --arch=arm --cross-prefix=arm-none-eabi-
$ make clean && make
rm -f lib/arm/asm-offsets.h lib/arm/asm-offsets.s \
      lib/generated/asm-offsets.h
rm -f arm/*.{o,flat,elf} lib/arm/libeabi.a lib/arm/eabi_compat.o \
      arm/.*.d lib/arm/.*.d
  CLEAN (libfdt)
rm -f lib/libfdt/*.o lib/libfdt/.*.d
rm -f lib/libfdt/libfdt.so.1
rm -f lib/libfdt/libfdt.a
rm -f lib/.*.d lib/libcflat.a lib/argv.o lib/printf.o lib/string.o lib/abort.o
lib/report.o lib/stack.o lib/arm/spinlock.o lib/arm/processor.o lib/arm/stack.o
lib/ldiv32.o lib/util.o lib/getchar.o lib/alloc_phys.o lib/alloc_page.o
lib/vmalloc.o lib/alloc.o lib/devicetree.o lib/pci.o lib/pci-host-generic.o
lib/pci-testdev.o lib/virtio.o lib/virtio-mmio.o lib/chr-testdev.o lib/arm/io.o
lib/arm/setup.o lib/arm/mmu.o lib/arm/bitops.o lib/arm/psci.o lib/arm/smp.o
lib/arm/delay.o lib/arm/gic.o lib/arm/gic-v2.o lib/arm/gic-v3.o
[..]
arm-none-eabi-gcc -marm -mfpu=vfp -mcpu=cortex-a15 -mno-unaligned-access
-std=gnu99 -ffreestanding -O2 -I /home/alex/data/repos/kvm-unit-tests/lib -I
/home/alex/data/repos/kvm-unit-tests/lib/libfdt -I lib -g -MMD -MF lib/.ldiv32.d
-fno-strict-aliasing -fno-common -Wall -Wwrite-strings -Wempty-body
-Wuninitialized -Wignored-qualifiers -Werror  -fno-omit-frame-pointer 
-fno-stack-protector    -Wno-frame-address -D__U32_LONG_FMT__  -fno-pic  -no-pie 
-Wclobbered  -Wunused-but-set-parameter  -Wmissing-parameter-type 
-Wold-style-declaration -Woverride-init -Wmissing-prototypes -Wstrict-prototypes  
-c -o lib/ldiv32.o lib/ldiv32.c
lib/ldiv32.c: In function '__moddi3':
lib/ldiv32.c:73:11: error: 'rem' may be used uninitialized in this function
[-Werror=maybe-uninitialized]
   73 |  uint64_t rem;
      |           ^~~
lib/ldiv32.c: In function '__umoddi3':
lib/ldiv32.c:75:9: error: 'rem' may be used uninitialized in this function
[-Werror=maybe-uninitialized]
   75 |  return rem;
      |         ^~~
cc1: all warnings being treated as errors
make: *** [<builtin>: lib/ldiv32.o] Error 1
$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (Arch Repository) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

On Fedora 33:

$ ./configure --arch=arm --cross-prefix=arm-linux-gnu-
$ make clean && make
rm -f lib/arm/asm-offsets.h lib/arm/asm-offsets.s \
      lib/generated/asm-offsets.h
rm -f arm/*.{o,flat,elf} lib/arm/libeabi.a lib/arm/eabi_compat.o \
      arm/.*.d lib/arm/.*.d
  CLEAN (libfdt)
rm -f lib/libfdt/*.o lib/libfdt/.*.d
rm -f lib/libfdt/libfdt.so.1
rm -f lib/libfdt/libfdt.a
rm -f lib/.*.d lib/libcflat.a lib/argv.o lib/printf.o lib/string.o lib/abort.o
lib/report.o lib/stack.o lib/arm/spinlock.o lib/arm/processor.o lib/arm/stack.o
lib/ldiv32.o lib/util.o lib/getchar.o lib/alloc_phys.o lib/alloc_page.o
lib/vmalloc.o lib/alloc.o lib/devicetree.o lib/pci.o lib/pci-host-generic.o
lib/pci-testdev.o lib/virtio.o lib/virtio-mmio.o lib/chr-testdev.o lib/arm/io.o
lib/arm/setup.o lib/arm/mmu.o lib/arm/bitops.o lib/arm/psci.o lib/arm/smp.o
lib/arm/delay.o lib/arm/gic.o lib/arm/gic-v2.o lib/arm/gic-v3.o
[..]
arm-linux-gnu-gcc -marm -mfpu=vfp -mcpu=cortex-a15 -mno-unaligned-access
-std=gnu99 -ffreestanding -O2 -I /home/alex/data/repos/kvm-unit-tests/lib -I
/home/alex/data/repos/kvm-unit-tests/lib/libfdt -I lib -g -MMD -MF lib/.ldiv32.d
-fno-strict-aliasing -fno-common -Wall -Wwrite-strings -Wempty-body
-Wuninitialized -Wignored-qualifiers -Werror  -fno-omit-frame-pointer 
-fno-stack-protector    -Wno-frame-address   -fno-pic  -no-pie  -Wclobbered 
-Wunused-but-set-parameter  -Wmissing-parameter-type  -Wold-style-declaration
-Woverride-init -Wmissing-prototypes -Wstrict-prototypes   -c -o lib/ldiv32.o
lib/ldiv32.c
lib/ldiv32.c:1:10: fatal error: inttypes.h: No such file or directory
    1 | #include <inttypes.h>
      |          ^~~~~~~~~~~~
compilation terminated.
make: *** [<builtin>: lib/ldiv32.o] Error 1
$ arm-linux-gnu-gcc --version
arm-linux-gnu-gcc (GCC) 10.2.1 20200826 (Red Hat Cross 10.2.1-3)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Reverting the commit makes arm build again. I am not familiar with toolchains, and unfortunately I can't propose a fix.

Thanks,

Alex

maintainer
#1 lore raw
Quoted 5 lines · Alexandru Elisei

Hello,

Commit 0b2d3dafc0d3 ("libcflat: provide long division routines"), which added the lib/ldiv32.c file, breaks compilation for the arm architecture; arm64 seems to be working just fine.

The Fedora one is fixed in the commit immediately after, which replaces inttypes.h with stdint.h.

For Arch Linux I'm not sure what the compiler is complaining about (especially since there are no options such as -fno-null-pointer-checks) but perhaps we can just initialize rem to 0? Any chance you can check if that affects the assembly output? (It shouldn't).

Paolo

Quoted 87 lines

On Arch Linux:

$ ./configure --arch=arm --cross-prefix=arm-none-eabi-
$ make clean && make
rm -f lib/arm/asm-offsets.h lib/arm/asm-offsets.s \
       lib/generated/asm-offsets.h
rm -f arm/*.{o,flat,elf} lib/arm/libeabi.a lib/arm/eabi_compat.o \
       arm/.*.d lib/arm/.*.d
   CLEAN (libfdt)
rm -f lib/libfdt/*.o lib/libfdt/.*.d
rm -f lib/libfdt/libfdt.so.1
rm -f lib/libfdt/libfdt.a
rm -f lib/.*.d lib/libcflat.a lib/argv.o lib/printf.o lib/string.o lib/abort.o
lib/report.o lib/stack.o lib/arm/spinlock.o lib/arm/processor.o lib/arm/stack.o
lib/ldiv32.o lib/util.o lib/getchar.o lib/alloc_phys.o lib/alloc_page.o
lib/vmalloc.o lib/alloc.o lib/devicetree.o lib/pci.o lib/pci-host-generic.o
lib/pci-testdev.o lib/virtio.o lib/virtio-mmio.o lib/chr-testdev.o lib/arm/io.o
lib/arm/setup.o lib/arm/mmu.o lib/arm/bitops.o lib/arm/psci.o lib/arm/smp.o
lib/arm/delay.o lib/arm/gic.o lib/arm/gic-v2.o lib/arm/gic-v3.o
[..]
arm-none-eabi-gcc -marm -mfpu=vfp -mcpu=cortex-a15 -mno-unaligned-access
-std=gnu99 -ffreestanding -O2 -I /home/alex/data/repos/kvm-unit-tests/lib -I
/home/alex/data/repos/kvm-unit-tests/lib/libfdt -I lib -g -MMD -MF lib/.ldiv32.d
(quoted diff) +0 -6
-fno-strict-aliasing -fno-common -Wall -Wwrite-strings -Wempty-body
-Wuninitialized -Wignored-qualifiers -Werror  -fno-omit-frame-pointer
-fno-stack-protector    -Wno-frame-address -D__U32_LONG_FMT__  -fno-pic  -no-pie
-Wclobbered  -Wunused-but-set-parameter  -Wmissing-parameter-type
-Wold-style-declaration -Woverride-init -Wmissing-prototypes -Wstrict-prototypes
-c -o lib/ldiv32.o lib/ldiv32.c

lib/ldiv32.c: In function '__moddi3':
lib/ldiv32.c:73:11: error: 'rem' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   73 |  uint64_t rem;
      |           ^~~
lib/ldiv32.c: In function '__umoddi3':
lib/ldiv32.c:75:9: error: 'rem' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   75 |  return rem;
      |         ^~~
cc1: all warnings being treated as errors
make: *** [<builtin>: lib/ldiv32.o] Error 1

$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (Arch Repository) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

On Fedora 33:

$ ./configure --arch=arm --cross-prefix=arm-linux-gnu-
$ make clean && make
rm -f lib/arm/asm-offsets.h lib/arm/asm-offsets.s \
       lib/generated/asm-offsets.h
rm -f arm/*.{o,flat,elf} lib/arm/libeabi.a lib/arm/eabi_compat.o \
       arm/.*.d lib/arm/.*.d
   CLEAN (libfdt)
rm -f lib/libfdt/*.o lib/libfdt/.*.d
rm -f lib/libfdt/libfdt.so.1
rm -f lib/libfdt/libfdt.a
rm -f lib/.*.d lib/libcflat.a lib/argv.o lib/printf.o lib/string.o lib/abort.o
lib/report.o lib/stack.o lib/arm/spinlock.o lib/arm/processor.o lib/arm/stack.o
lib/ldiv32.o lib/util.o lib/getchar.o lib/alloc_phys.o lib/alloc_page.o
lib/vmalloc.o lib/alloc.o lib/devicetree.o lib/pci.o lib/pci-host-generic.o
lib/pci-testdev.o lib/virtio.o lib/virtio-mmio.o lib/chr-testdev.o lib/arm/io.o
lib/arm/setup.o lib/arm/mmu.o lib/arm/bitops.o lib/arm/psci.o lib/arm/smp.o
lib/arm/delay.o lib/arm/gic.o lib/arm/gic-v2.o lib/arm/gic-v3.o
[..]
arm-linux-gnu-gcc -marm -mfpu=vfp -mcpu=cortex-a15 -mno-unaligned-access
-std=gnu99 -ffreestanding -O2 -I /home/alex/data/repos/kvm-unit-tests/lib -I
/home/alex/data/repos/kvm-unit-tests/lib/libfdt -I lib -g -MMD -MF lib/.ldiv32.d
(quoted diff) +0 -5
-fno-strict-aliasing -fno-common -Wall -Wwrite-strings -Wempty-body
-Wuninitialized -Wignored-qualifiers -Werror  -fno-omit-frame-pointer
-fno-stack-protector    -Wno-frame-address   -fno-pic  -no-pie  -Wclobbered
-Wunused-but-set-parameter  -Wmissing-parameter-type  -Wold-style-declaration
-Woverride-init -Wmissing-prototypes -Wstrict-prototypes   -c -o lib/ldiv32.o

lib/ldiv32.c
lib/ldiv32.c:1:10: fatal error: inttypes.h: No such file or directory
    1 | #include <inttypes.h>
      |          ^~~~~~~~~~~~
compilation terminated.
make: *** [<builtin>: lib/ldiv32.o] Error 1

$ arm-linux-gnu-gcc --version
arm-linux-gnu-gcc (GCC) 10.2.1 20200826 (Red Hat Cross 10.2.1-3)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Quoted 7 lines

Reverting the commit makes arm build again. I am not familiar with toolchains, and unfortunately I can't propose a fix.

Thanks,

Alex

_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

#2 lore raw

Hi Paolo,

Quoted 9 lines · Paolo Bonzini
Quoted 5 lines · Alexandru Elisei

Hello,

Commit 0b2d3dafc0d3 ("libcflat: provide long division routines"), which added the lib/ldiv32.c file, breaks compilation for the arm architecture; arm64 seems to be working just fine.

The Fedora one is fixed in the commit immediately after, which replaces inttypes.h with stdint.h.

$ git remote -v show new
* remote new
  Fetch URL: https://gitlab.com/kvm-unit-tests/kvm-unit-tests.git/
  Push  URL: https://gitlab.com/kvm-unit-tests/kvm-unit-tests.git/
  HEAD branch: master
  Remote branches:
    master  tracked
    staging tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (up to date)
$ git pull new
Already up to date.
$ git show
commit 0b2d3dafc0d31025636201df923fa0dc8d2e380e (HEAD -> master, new/master)
Author: Paolo Bonzini <[email protected]>
Date:   Wed May 5 08:33:38 2021 -0400

    libcflat: provide long division routines
[..]

I guess the patch has not been merged yet, right?

Quoted 5 lines

For Arch Linux I'm not sure what the compiler is complaining about (especially since there are no options such as -fno-null-pointer-checks) but perhaps we can just initialize rem to 0?  Any chance you can check if that affects the assembly output?  (It shouldn't).

I think it's because I'm using the *arm-none-eabi* toolchain for compilation instead of arm-linux-gnu, that's the toolchain for cross compiling arm code that is present in the official Arch Linux repositories. Is that unsupported? I don't remember any mention of it not being supported, but it's entirely possible that I just forgot.

With rem initialized to 0 I get this:

rm-none-eabi-ld -nostdlib -Ttext=40010000 -o arm/selftest.elf -T /home/alex/data/repos/kvm-unit-tests/arm/flat.lds \
    arm/selftest.o arm/cstart.o lib/libcflat.a lib/libfdt/libfdt.a lib/arm/libeabi.a arm/selftest.aux.o
arm-none-eabi-ld: lib/libcflat.a(printf.o): in function `print_int':
/home/alex/data/repos/kvm-unit-tests/lib/printf.c:72: undefined reference to `__aeabi_ldivmod'
arm-none-eabi-ld: /home/alex/data/repos/kvm-unit-tests/lib/printf.c:73: undefined reference to `__aeabi_ldivmod'
arm-none-eabi-ld: lib/libcflat.a(printf.o): in function `print_unsigned':
/home/alex/data/repos/kvm-unit-tests/lib/printf.c:102: undefined reference to `__aeabi_uldivmod'
arm-none-eabi-ld: lib/libcflat.a(alloc_page.o): in function `_page_alloc_init_area':
/home/alex/data/repos/kvm-unit-tests/lib/alloc_page.c:482: undefined reference to `__aeabi_uldivmod'
make: *** [/home/alex/data/repos/kvm-unit-tests/arm/Makefile.common:65:
arm/selftest.elf] Error 1

Thanks,

Alex

Quoted 98 lines

Paolo

Quoted 94 lines

On Arch Linux:

$ ./configure --arch=arm --cross-prefix=arm-none-eabi-
$ make clean && make
rm -f lib/arm/asm-offsets.h lib/arm/asm-offsets.s \
       lib/generated/asm-offsets.h
rm -f arm/*.{o,flat,elf} lib/arm/libeabi.a lib/arm/eabi_compat.o \
       arm/.*.d lib/arm/.*.d
   CLEAN (libfdt)
rm -f lib/libfdt/*.o lib/libfdt/.*.d
rm -f lib/libfdt/libfdt.so.1
rm -f lib/libfdt/libfdt.a
rm -f lib/.*.d lib/libcflat.a lib/argv.o lib/printf.o lib/string.o lib/abort.o
lib/report.o lib/stack.o lib/arm/spinlock.o lib/arm/processor.o lib/arm/stack.o
lib/ldiv32.o lib/util.o lib/getchar.o lib/alloc_phys.o lib/alloc_page.o
lib/vmalloc.o lib/alloc.o lib/devicetree.o lib/pci.o lib/pci-host-generic.o
lib/pci-testdev.o lib/virtio.o lib/virtio-mmio.o lib/chr-testdev.o lib/arm/io.o
lib/arm/setup.o lib/arm/mmu.o lib/arm/bitops.o lib/arm/psci.o lib/arm/smp.o
lib/arm/delay.o lib/arm/gic.o lib/arm/gic-v2.o lib/arm/gic-v3.o
[..]
arm-none-eabi-gcc -marm -mfpu=vfp -mcpu=cortex-a15 -mno-unaligned-access
-std=gnu99 -ffreestanding -O2 -I /home/alex/data/repos/kvm-unit-tests/lib -I
/home/alex/data/repos/kvm-unit-tests/lib/libfdt -I lib -g -MMD -MF lib/.ldiv32.d
(quoted diff) +0 -6
-fno-strict-aliasing -fno-common -Wall -Wwrite-strings -Wempty-body
-Wuninitialized -Wignored-qualifiers -Werror  -fno-omit-frame-pointer
-fno-stack-protector    -Wno-frame-address -D__U32_LONG_FMT__  -fno-pic  -no-pie
-Wclobbered  -Wunused-but-set-parameter  -Wmissing-parameter-type
-Wold-style-declaration -Woverride-init -Wmissing-prototypes -Wstrict-prototypes
-c -o lib/ldiv32.o lib/ldiv32.c

lib/ldiv32.c: In function '__moddi3':
lib/ldiv32.c:73:11: error: 'rem' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    73 |  uint64_t rem;
       |           ^~~
lib/ldiv32.c: In function '__umoddi3':
lib/ldiv32.c:75:9: error: 'rem' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    75 |  return rem;
       |         ^~~
cc1: all warnings being treated as errors
make: *** [<builtin>: lib/ldiv32.o] Error 1

$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (Arch Repository) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

On Fedora 33:

$ ./configure --arch=arm --cross-prefix=arm-linux-gnu-
$ make clean && make
rm -f lib/arm/asm-offsets.h lib/arm/asm-offsets.s \
       lib/generated/asm-offsets.h
rm -f arm/*.{o,flat,elf} lib/arm/libeabi.a lib/arm/eabi_compat.o \
       arm/.*.d lib/arm/.*.d
   CLEAN (libfdt)
rm -f lib/libfdt/*.o lib/libfdt/.*.d
rm -f lib/libfdt/libfdt.so.1
rm -f lib/libfdt/libfdt.a
rm -f lib/.*.d lib/libcflat.a lib/argv.o lib/printf.o lib/string.o lib/abort.o
lib/report.o lib/stack.o lib/arm/spinlock.o lib/arm/processor.o lib/arm/stack.o
lib/ldiv32.o lib/util.o lib/getchar.o lib/alloc_phys.o lib/alloc_page.o
lib/vmalloc.o lib/alloc.o lib/devicetree.o lib/pci.o lib/pci-host-generic.o
lib/pci-testdev.o lib/virtio.o lib/virtio-mmio.o lib/chr-testdev.o lib/arm/io.o
lib/arm/setup.o lib/arm/mmu.o lib/arm/bitops.o lib/arm/psci.o lib/arm/smp.o
lib/arm/delay.o lib/arm/gic.o lib/arm/gic-v2.o lib/arm/gic-v3.o
[..]
arm-linux-gnu-gcc -marm -mfpu=vfp -mcpu=cortex-a15 -mno-unaligned-access
-std=gnu99 -ffreestanding -O2 -I /home/alex/data/repos/kvm-unit-tests/lib -I
/home/alex/data/repos/kvm-unit-tests/lib/libfdt -I lib -g -MMD -MF lib/.ldiv32.d
(quoted diff) +0 -5
-fno-strict-aliasing -fno-common -Wall -Wwrite-strings -Wempty-body
-Wuninitialized -Wignored-qualifiers -Werror  -fno-omit-frame-pointer
-fno-stack-protector    -Wno-frame-address   -fno-pic  -no-pie  -Wclobbered
-Wunused-but-set-parameter  -Wmissing-parameter-type  -Wold-style-declaration
-Woverride-init -Wmissing-prototypes -Wstrict-prototypes   -c -o lib/ldiv32.o

lib/ldiv32.c
lib/ldiv32.c:1:10: fatal error: inttypes.h: No such file or directory 1 | #include <inttypes.h>
       |          ^~~~~~~~~~~~
compilation terminated.
make: *** [<builtin>: lib/ldiv32.o] Error 1

$ arm-linux-gnu-gcc --version
arm-linux-gnu-gcc (GCC) 10.2.1 20200826 (Red Hat Cross 10.2.1-3)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Reverting the commit makes arm build again. I am not familiar with toolchains, and unfortunately I can't propose a fix.

Thanks,

Alex

maintainer
#3 lore raw
Quoted 21 lines · Alexandru Elisei
Quoted 2 lines

The Fedora one is fixed in the commit immediately after, which replaces inttypes.h with stdint.h.

$ git remote -v show new
* remote new
   Fetch URL:https://gitlab.com/kvm-unit-tests/kvm-unit-tests.git/
   Push  URL:https://gitlab.com/kvm-unit-tests/kvm-unit-tests.git/
   HEAD branch: master
   Remote branches:
     master  tracked
     staging tracked
   Local branch configured for 'git pull':
     master merges with remote master
   Local ref configured for 'git push':
     master pushes to master (up to date)
$ git pull new
Already up to date.
$ git show
commit 0b2d3dafc0d31025636201df923fa0dc8d2e380e (HEAD -> master, new/master)
Author: Paolo Bonzini<[email protected]>
Date:   Wed May 5 08:33:38 2021 -0400
Quoted 5 lines

    libcflat: provide long division routines
[..]

I guess the patch has not been merged yet, right?

Oops, it was only in my own tree. Pushed now.

Paolo

maintainer
#4 lore raw
In reply to Alexandru Elisei
Quoted 5 lines · Alexandru Elisei

I think it's because I'm using the*arm-none-eabi* toolchain for compilation instead of arm-linux-gnu, that's the toolchain for cross compiling arm code that is present in the official Arch Linux repositories. Is that unsupported? I don't remember any mention of it not being supported, but it's entirely possible that I just forgot.

No, it's just that there was no difference until now. If you can add it to CI we can make sure it doesn't break.

Quoted 11 lines

With rem initialized to 0 I get this:

rm-none-eabi-ld -nostdlib -Ttext=40010000 -o arm/selftest.elf -T /home/alex/data/repos/kvm-unit-tests/arm/flat.lds \
    arm/selftest.o arm/cstart.o lib/libcflat.a lib/libfdt/libfdt.a
lib/arm/libeabi.a arm/selftest.aux.o
arm-none-eabi-ld: lib/libcflat.a(printf.o): in function `print_int':
/home/alex/data/repos/kvm-unit-tests/lib/printf.c:72: undefined reference to `__aeabi_ldivmod'
arm-none-eabi-ld: /home/alex/data/repos/kvm-unit-tests/lib/printf.c:73: undefined reference to `__aeabi_ldivmod'

Quoted 8 lines

arm-none-eabi-ld: lib/libcflat.a(printf.o): in function `print_unsigned':
/home/alex/data/repos/kvm-unit-tests/lib/printf.c:102: undefined reference to `__aeabi_uldivmod'
arm-none-eabi-ld: lib/libcflat.a(alloc_page.o): in function `_page_alloc_init_area':
/home/alex/data/repos/kvm-unit-tests/lib/alloc_page.c:482: undefined reference to `__aeabi_uldivmod'
make: *** [/home/alex/data/repos/kvm-unit-tests/arm/Makefile.common:65:
arm/selftest.elf] Error 1

So for this we need to include the uldivmod and ldivmod functions similar to those in https://android.googlesource.com/toolchain/compiler-rt/+/release_32/lib/arm.

The uninitialized warning is because of the division by zero case. I've sent a couple patches to fix everything, please review!

Paolo