Skip to contentSkip to conversation

link error while u-boot-spl build : undefined ref to `printf` or `strcmp` etc.

DISCUSSION Chan Kim 2 participants 3 messages Nov 21, 2021 – Nov 22, 2021

lore
Share & tools
lore

Chan Kim

author
#0 lore raw

Hello,

When I build u-boot, I get this error at the end. (during u-boot-spl build).

I've been fixing some link errors by adding config values but I can't figure out what is wrong with this.

Below is the final command for u-boot-spl build and the error messages.

Can any expert tell me what can be wrong here?

( cd spl && aarch64-none-elf-gcc -nostdlib -nostartfiles -fuse-linker-plugin -flto=28 -Wall -Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -std=gnu11 -fshort-wchar -fno-strict-aliasing -fno-PIE -Os -flto=28 -fno-stack-protector -fno-delete-null-pointer-checks -Wno-pointer-sign -Wno-stringop-truncation -Wno-zero-length-bounds -Wno-array-bounds -Wno-stringop-overflow -Wno-maybe-uninitialized -fmacro-prefix-map=./= -g -fstack-usage -Wno-format-nonliteral -Wno-address-of-packed-member -Wno-unused-but-set-variable -Werror=date-time -Wno-packed-not-aligned -ffunction-sections -fdata-sections -fno-stack-protector -D__KERNEL__ -D__UBOOT__ -DCONFIG_SPL_BUILD -D__ARM__
-mstrict-align -fno-common -ffixed-r9 -mgeneral-regs-only -fno-common
-ffixed-x18 -pipe -march=armv8-a+crc -D__LINUX_ARM_ARCH__=8 -Ispl/include
-Iinclude -I./arch/arm/include -include ./include/linux/kconfig.h
-nostdinc -isystem /opt/arm-toolchains/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/../lib/ gcc/aarch64-none-elf/10.2.1/include -Wl,-T -Wl,u-boot-spl.lds -Wl,--gc-sections -Wl,-Bstatic -Wl,--gc-sections -Wl,--no-dynamic-linker -Wl,--build-id=none -Wl,-Ttext -Wl,0x4000000 arch/arm/cpu/armv8/start.o -Wl,--whole-archive arch/arm/cpu/armv8/built-in.o arch/arm/cpu/built-in.o arch/arm/lib/built-in.o board/etri/ab21m/built-in.o common/spl/built-in.o common/init/built-in.o common/built-in.o cmd/built-in.o env/built-in.o disk/built-in.o drivers/built-in.o dts/built-in.o fs/built-in.o keep-syms-lto.o -L /opt/arm-toolchains/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/../lib/ gcc/aarch64-none-elf/10.2.1 -lgcc -Wl,--no-whole-archive -Wl,-Map,u-boot-spl.map -o u-boot-spl )

/opt/arm-toolchains/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/../lib/ gcc/aarch64-none-elf/10.2.1/../../../../aarch64-none-elf/bin/ld:
/tmp/u-boot-spl.GeKfJh.ltrans0.ltrans.o: in function `alloc_simple':

/home/ckim/U-BOOT/u-boot/spl/../common/malloc_simple.c:29: undefined reference to `printf'

/opt/arm-toolchains/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/../lib/ gcc/aarch64-none-elf/10.2.1/../../../../aarch64-none-elf/bin/ld:
/tmp/u-boot-spl.GeKfJh.ltrans0.ltrans.o: in function `device_bind_by_name':

/home/ckim/U-BOOT/u-boot/spl/../drivers/core/lists.c:31: undefined reference to `strcmp'

/opt/arm-toolchains/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/../lib/ gcc/aarch64-none-elf/10.2.1/../../../../aarch64-none-elf/bin/ld:
/tmp/u-boot-spl.GeKfJh.ltrans0.ltrans.o: in function `board_init_r':

/home/ckim/U-BOOT/u-boot/spl/../common/spl/spl.c:697: undefined reference to `timer_init'

/opt/arm-toolchains/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/../lib/ gcc/aarch64-none-elf/10.2.1/../../../../aarch64-none-elf/bin/ld:
/home/ckim/U-BOOT/u-boot/spl/../common/spl/spl.c:690: undefined reference to `hang'

/opt/arm-toolchains/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/../lib/ gcc/aarch64-none-elf/10.2.1/../../../../aarch64-none-elf/bin/ld:
/home/ckim/U-BOOT/u-boot/spl/../common/spl/spl.c:633: undefined reference to `printf'

collect2: error: ld returned 1 exit status

make[1]: *** [scripts/Makefile.spl:509: spl/u-boot-spl] Error 1

make: *** [Makefile:1984: spl/u-boot-spl] Error 2

Thank you.

Chan Kim

#1 lore raw

Hi Chan,

Quoted 73 lines · Chan Kim

[Please note: This e-mail is from an EXTERNAL e-mail address]

Hello,

When I build u-boot, I get this error at the end. (during u-boot-spl build).

I've been fixing some link errors by adding config values but I can't figure out what is wrong with this.

Below is the final command for u-boot-spl build and the error messages.

Can any expert tell me what can be wrong here?

( cd spl && aarch64-none-elf-gcc -nostdlib -nostartfiles

(quoted diff) +0 -13
-fuse-linker-plugin -flto=28 -Wall -Wstrict-prototypes -Wno-format-security
-fno-builtin -ffreestanding -std=gnu11 -fshort-wchar -fno-strict-aliasing
-fno-PIE -Os  -flto=28 -fno-stack-protector -fno-delete-null-pointer-checks
-Wno-pointer-sign -Wno-stringop-truncation -Wno-zero-length-bounds
-Wno-array-bounds -Wno-stringop-overflow -Wno-maybe-uninitialized
-fmacro-prefix-map=./= -g -fstack-usage -Wno-format-nonliteral
-Wno-address-of-packed-member -Wno-unused-but-set-variable -Werror=date-time
-Wno-packed-not-aligned  -ffunction-sections -fdata-sections
-fno-stack-protector -D__KERNEL__ -D__UBOOT__  -DCONFIG_SPL_BUILD  -D__ARM__
-mstrict-align  -fno-common -ffixed-r9  -mgeneral-regs-only    -fno-common
-ffixed-x18 -pipe -march=armv8-a+crc -D__LINUX_ARM_ARCH__=8   -Ispl/include
-Iinclude   -I./arch/arm/include -include ./include/linux/kconfig.h
-nostdinc -isystem

/opt/arm-toolchains/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/../lib/ gcc/aarch64-none-elf/10.2.1/include -Wl,-T -Wl,u-boot-spl.lds

(quoted diff) +0 -3
-Wl,--gc-sections -Wl,-Bstatic -Wl,--gc-sections -Wl,--no-dynamic-linker
-Wl,--build-id=none -Wl,-Ttext -Wl,0x4000000 arch/arm/cpu/armv8/start.o
-Wl,--whole-archive arch/arm/cpu/armv8/built-in.o arch/arm/cpu/built-in.o

arch/arm/lib/built-in.o board/etri/ab21m/built-in.o common/spl/built-in.o common/init/built-in.o common/built-in.o cmd/built-in.o env/built-in.o disk/built-in.o drivers/built-in.o dts/built-in.o fs/built-in.o keep-syms-lto.o -L /opt/arm-toolchains/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/../lib/ gcc/aarch64-none-elf/10.2.1 -lgcc -Wl,--no-whole-archive -Wl,-Map,u-boot-spl.map -o u-boot-spl )

/opt/arm-toolchains/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/../lib/ gcc/aarch64-none-elf/10.2.1/../../../../aarch64-none-elf/bin/ld:
/tmp/u-boot-spl.GeKfJh.ltrans0.ltrans.o: in function `alloc_simple':

/home/ckim/U-BOOT/u-boot/spl/../common/malloc_simple.c:29: undefined reference to `printf'

/opt/arm-toolchains/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/../lib/ gcc/aarch64-none-elf/10.2.1/../../../../aarch64-none-elf/bin/ld:
/tmp/u-boot-spl.GeKfJh.ltrans0.ltrans.o: in function `device_bind_by_name':

/home/ckim/U-BOOT/u-boot/spl/../drivers/core/lists.c:31: undefined reference to `strcmp'

/opt/arm-toolchains/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/../lib/ gcc/aarch64-none-elf/10.2.1/../../../../aarch64-none-elf/bin/ld:
/tmp/u-boot-spl.GeKfJh.ltrans0.ltrans.o: in function `board_init_r':

/home/ckim/U-BOOT/u-boot/spl/../common/spl/spl.c:697: undefined reference to `timer_init'

/opt/arm-toolchains/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/../lib/ gcc/aarch64-none-elf/10.2.1/../../../../aarch64-none-elf/bin/ld:
/home/ckim/U-BOOT/u-boot/spl/../common/spl/spl.c:690: undefined reference to `hang'

/opt/arm-toolchains/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/../lib/ gcc/aarch64-none-elf/10.2.1/../../../../aarch64-none-elf/bin/ld:
/home/ckim/U-BOOT/u-boot/spl/../common/spl/spl.c:633: undefined reference to `printf'

Quoted 5 lines

collect2: error: ld returned 1 exit status

make[1]: *** [scripts/Makefile.spl:509: spl/u-boot-spl] Error 1

make: *** [Makefile:1984: spl/u-boot-spl] Error 2

Could you try to enable CONFIG_SPL_LIBCOMMON_SUPPORT and CONFIG_SPL_LIBGENERIC_SUPPORT Kconfig options?

Ovidiu

Quoted 6 lines

Thank you.

Chan Kim

author
#2 lore raw

Hi Ovidiu,

Thank you so much, with those two configs added, u-boot-spl was finally built ok (The remaining 3 or 4 link errors are all gone together)
Thank you,

Best regards,
Chan Kim

Quoted 113 lines

-----Original Message-----
From: Ovidiu Panait <[email protected]>
Sent: Monday, November 22, 2021 12:30 AM
To: Chan Kim <[email protected]>; U-Boot Mailing List <[email protected]>
Subject: Re: link error while u-boot-spl build : undefined ref to printf or strcmp etc.

Hi Chan,

Quoted 5 lines · Chan Kim

[Please note: This e-mail is from an EXTERNAL e-mail address]

Hello,

When I build u-boot, I get this error at the end. (during u-boot-spl

build).

Quoted 11 lines

I've been fixing some link errors by adding config values but I can't figure out what is wrong with this.

Below is the final command for u-boot-spl build and the error messages.

Can any expert tell me what can be wrong here?

( cd spl && aarch64-none-elf-gcc -nostdlib -nostartfiles

Review

Quoted 9 lines
(quoted diff) +0 -9
-fuse-linker-plugin -flto=28 -Wall -Wstrict-prototypes
-Wno-format-security -fno-builtin -ffreestanding -std=gnu11
-fshort-wchar -fno-strict-aliasing -fno-PIE -Os  -flto=28
-fno-stack-protector -fno-delete-null-pointer-checks -Wno-pointer-sign
-Wno-stringop-truncation -Wno-zero-length-bounds -Wno-array-bounds
-Wno-stringop-overflow -Wno-maybe-uninitialized -fmacro-prefix-map=./=
-g -fstack-usage -Wno-format-nonliteral -Wno-address-of-packed-member
-Wno-unused-but-set-variable -Werror=date-time -Wno-packed-not-aligned
-ffunction-sections -fdata-sections -fno-stack-protector -D__KERNEL__ -

D__UBOOT__ -DCONFIG_SPL_BUILD -D__ARM__

Quoted 1 line

-mstrict-align -fno-common -ffixed-r9 -mgeneral-regs-only -fno-

common

Quoted 1 line

-ffixed-x18 -pipe -march=armv8-a+crc -D__LINUX_ARM_ARCH__=8 -

Ispl/include

Quoted 22 lines
(quoted diff) +0 -2
-Iinclude   -I./arch/arm/include -include ./include/linux/kconfig.h
-nostdinc -isystem

/opt/arm-toolchains/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/. ./lib/ gcc/aarch64-none-elf/10.2.1/include -Wl,-T -Wl,u-boot-spl.lds

(quoted diff) +0 -2
-Wl,--gc-sections -Wl,-Bstatic -Wl,--gc-sections
-Wl,--no-dynamic-linker -Wl,--build-id=none -Wl,-Ttext -Wl,0x4000000

arch/arm/cpu/armv8/start.o -Wl,--whole-archive arch/arm/cpu/armv8/built-in.o arch/arm/cpu/built-in.o arch/arm/lib/built-in.o board/etri/ab21m/built-in.o common/spl/built-in.o common/init/built-in.o common/built-in.o cmd/built-in.o env/built-in.o disk/built-in.o drivers/built-in.o dts/built-in.o fs/built-in.o keep-syms-lto.o -L /opt/arm-toolchains/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/. ./lib/
gcc/aarch64-none-elf/10.2.1 -lgcc -Wl,--no-whole-archive -Wl,-Map,u-boot-spl.map -o u-boot-spl )

/opt/arm-toolchains/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/. ./lib/ gcc/aarch64-none-elf/10.2.1/../../../../aarch64-none-elf/bin/ld:
/tmp/u-boot-spl.GeKfJh.ltrans0.ltrans.o: in function `alloc_simple':

Quoted 7 lines

/home/ckim/U-BOOT/u-boot/spl/../common/malloc_simple.c:29: undefined reference to `printf'

/opt/arm-toolchains/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/. ./lib/ gcc/aarch64-none-elf/10.2.1/../../../../aarch64-none-elf/bin/ld:
/tmp/u-boot-spl.GeKfJh.ltrans0.ltrans.o: in function

`device_bind_by_name':

Quoted 24 lines

/home/ckim/U-BOOT/u-boot/spl/../drivers/core/lists.c:31: undefined reference to `strcmp'

/opt/arm-toolchains/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/. ./lib/ gcc/aarch64-none-elf/10.2.1/../../../../aarch64-none-elf/bin/ld:
/tmp/u-boot-spl.GeKfJh.ltrans0.ltrans.o: in function `board_init_r':

/home/ckim/U-BOOT/u-boot/spl/../common/spl/spl.c:697: undefined reference to `timer_init'

/opt/arm-toolchains/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/. ./lib/ gcc/aarch64-none-elf/10.2.1/../../../../aarch64-none-elf/bin/ld:
/home/ckim/U-BOOT/u-boot/spl/../common/spl/spl.c:690: undefined reference to `hang'

/opt/arm-toolchains/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/. ./lib/ gcc/aarch64-none-elf/10.2.1/../../../../aarch64-none-elf/bin/ld:
/home/ckim/U-BOOT/u-boot/spl/../common/spl/spl.c:633: undefined reference to `printf'

Quoted 5 lines

collect2: error: ld returned 1 exit status

make[1]: *** [scripts/Makefile.spl:509: spl/u-boot-spl] Error 1

make: *** [Makefile:1984: spl/u-boot-spl] Error 2

Could you try to enable CONFIG_SPL_LIBCOMMON_SUPPORT and CONFIG_SPL_LIBGENERIC_SUPPORT Kconfig options?

Ovidiu

Quoted 6 lines

Thank you.

Chan Kim