How to compile u-boot with debug option?
Chan Kim
ckim at etri.re.kr
Tue Oct 19 07:01:23 CEST 2021
Hello, Jaehoon and all,
I tried setting in menuconfig TOOLS_DEBUG but no change. It's strainge, when I add "V=1" in the make command, I can see the commands run during the make. The cc command has -g options, a typical command being like this :
aarch64-none-elf-gcc -Wp,-MD,lib/.asm-offsets.s.d -nostdinc -isystem /home/ckim/prj/abdsn/ab21cv/tools/cc_zeus/gcc-arm-9.2-2019.12-x86_64-aarch64-none-elf/bin/../lib/gcc/aarch64-none-elf/9.2.1/include -Iinclude -I./arch/arm/include -include ./include/linux/kconfig.h -D__KERNEL__ -D__UBOOT__ -Wall -Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -std=gnu11 -fshort-wchar -fno-strict-aliasing -fno-PIE -Os -fno-stack-protector -fno-delete-null-pointer-checks -Wno-pointer-sign -Wno-stringop-truncation -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 -D__ARM__ -fno-pic -mstrict-align -ffunction-sections -fdata-sections -fno-common -ffixed-r9 -mgeneral-regs-only -fno-common -ffixed-x18 -pipe -march=armv8-a+crc -D__LINUX_ARM_ARCH__=8 -DDO_DEPS_ONLY -DKBUILD_BASENAME='"asm_offsets"' -DKBUILD_MODNAME='"asm_offsets"' -fverbose-asm -S -o lib/asm-offsets.s lib/asm-offsets.c
(you can see -g option near the middle place)
I don't know why the final .elf file doesn't contain debuginfo.
ckim at ckim-ubuntu:~/U-BOOT/u-boot$ readelf -S u-boot.elf
There are 5 section headers, starting at offset 0xc8950:
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .data PROGBITS 0000000000000000 00010000
00000000000b8850 0000000000000000 WA 0 0 1
[ 2] .symtab SYMTAB 0000000000000000 000c8850
0000000000000090 0000000000000018 3 2 8
[ 3] .strtab STRTAB 0000000000000000 000c88e0
0000000000000049 0000000000000000 0 0 1
[ 4] .shstrtab STRTAB 0000000000000000 000c8929
0000000000000021 0000000000000000 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
L (link order), O (extra OS processing required), G (group), T (TLS),
C (compressed), x (unknown), o (OS specific), E (exclude),
p (processor specific)
And there are many configs including pattern "DEBUG" like CONFIG_DEBUG_UART_SANDBOX but it seems they are adding special debug features in the program behavior. What I want is to run the u-boot program itself in debug mode so that I can attach gdb and follow the program steps. (continue, step-in, step-out things..)
Any comment will be very much appreciated.
Thank you, and best regards,
Chan Kim
> -----Original Message-----
> From: Jaehoon Chung <jh80.chung at samsung.com>
> Sent: Tuesday, October 19, 2021 12:26 PM
> To: Chan Kim <ckim at etri.re.kr>; U-Boot Mailing List <u-boot at lists.denx.de>
> Subject: Re: How to compile u-boot with debug option?
>
> On 10/19/21 11:21 AM, Chan Kim wrote:
> > Hello,
> >
> >
> >
> > With these commands,
> >
> > make ARCH=arm CROSS_COMPILE=aarch64-none-elf- qemu_arm64_defconfig
> >
> > make ARCH=arm CROSS_COMPILE=aarch64-none-elf-
> >
> > I see only u-boot.bin. How can I make u-boot.elf with debug info?
> >
> > I found
> > https://protect2.fireeye.com/v1/url?k=126d5a6e-4df662a4-126cd121-0cc47
> > a31bee8-8e6c8ef0c2793943&q=1&e=4928b69d-166a-4647-b6c5-88bc2f73a780&u=
> > https%3A%2F%2Flists.denx.de%2Fpipermail%2Fu-boot%2F2005-May%2F010240.h
> > tml and tried adding
>
> It's too old patch. It's not proper to current u-boot.
>
> make ARCH=arm menucofig and check config relevant to DEBUG option.
>
> Best Regards,
> Jaehoon Chung
>
> >
> > -DDEBUG to CFLAGS_NON_EFI in arch/arm/config.mk and adding CFLAGS +=
> > -DDEBUG in arch/arm/cpu/armv8/config.mk
> >
> > But after doing "make ARCH=arm CROSS_COMPILE=aarch64-none-elf-
> > u-boot.elf", when I give file command for the u-boot.elf, it says
> >
> >
> >
> > u-boot.elf: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV),
> > statically linked, not stripped
> >
> >
> >
> > I think I should see "with debug_info, not stripped". With connecting
> > gdb, I can't see the source file. The run responds to 'continue' command
> though.
> >
> > Could any tell me what I can do?
> >
> >
> >
> > Thank you,
> >
> > Chan Kim
> >
> >
> >
> >
>
More information about the U-Boot
mailing list