skip to Main Content

My environment:

  • Linux My-PC 5.15.90.1-microsoft-standard-WSL2 x86_64 x86_64 x86_64 GNU/Linux
  • Distributor ID: Ubuntu
  • Description: Ubuntu 22.04.1 LTS

GDB-multiarch version

$ gdb-multiarch -v
GNU gdb (Ubuntu 12.1-0ubuntu1~22.04) 12.1

Selected part of Makefile (Many things are ignored):

AS  =arm-linux-gnueabihf-as
LD  =arm-linux-gnueabihf-ld
NM  =arm-linux-gnueabihf-nm
LDFLAGS =-Timx6ul.lds 
CC  =arm-linux-gnueabihf-gcc  $(RAMDISK)
CFLAGS  =-Wall -fomit-frame-pointer -nostdlib -fno-stack-protector -g

CPP =arm-linux-gnueabihf-cpp -nostdinc -Iinclude -lgcc -L/usr/lib/gcc-cross/arm-linux-gnueabihf/11 -g

.c.s:
    $(CC) $(CFLAGS) 
    -nostdinc -Iinclude -S -o $*.s $<
.s.o:
    $(AS)  -o $*.o $<
.c.o:
    $(CC) $(CFLAGS) 
    -nostdinc -Iinclude -c -o $*.o $<

all:    Image

Image: boot/start tools/system
    arm-linux-gnueabihf-objcopy -O binary -R .note -R .comment tools/system Image
    sync

tools/system:    init/main.o boot/start.o 
    $(ARCHIVES) $(DRIVERS) $(MATH) $(LIBS) 
    mkdir -p tools
    $(LD) $(LDFLAGS) init/main.o boot/start.o 
    $(ARCHIVES) 
    $(DRIVERS) 
    $(MATH) 
    $(LIBS) 
    -o tools/system -lgcc -L /usr/lib/gcc-cross/arm-linux-gnueabihf/11 
    $(NM) -n tools/system > System.map

boot/start:boot/start.S
    $(AS) -o boot/start.o boot/start.S

qemu: all
    qemu-system-arm 
        -machine virt,gic-version=3 
        -m 4G 
        -cpu cortex-a7 
        -nographic 
        -device loader,file=Image,addr=0xC0008000,cpu-num=0 
        -s -S 
        # -serial null -serial mon:stdio 

init.gdb:

target remote localhost:1234
set architecture arm
symbol-file tools/system
x/i 0xc0010f68

The problem is, when I check value at some certain address in gdb terminal, this error occurs. For thousands of instructions, gdb works as what I expect, but I’m so confused that why a segmentation fault occurs when value of certain address is fetched. In this case, I try to fetch instructions at 0xc0010f64 and 0xc0010f6c, which turns out to be no problem.

Fatal signal: Segmentation fault
----- Backtrace -----
0x55e79b1e4197 ???
0x55e79b2e6599 ???
0x55e79b2e6762 ???
0x7f66f400951f ???
        ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x55e79b64560c ???
0x55e79b6452c5 ???
0x55e79b646831 ???
0x55e79b6469c9 ???
0x55e79b2761b1 ???
0x55e79b27718b ???
0x55e79b4437d7 ???
0x55e79b447f4b ???
0x55e79b448a0c ???
0x55e79b219774 ???
0x55e79b5a9d94 ???
0x55e79b2e76e4 ???
0x55e79b5ab99e ???
0x55e79b228443 ???
0x55e79b2163b7 ???
0x55e79b3b1da5 ???
0x55e79b3b1e39 ???
0x55e79b3b38d3 ???
0x55e79b3b43fe ???
0x55e79b10e0ef ???
0x7f66f3ff0d8f __libc_start_call_main
        ../sysdeps/nptl/libc_start_call_main.h:58
0x7f66f3ff0e3f __libc_start_main_impl
        ../csu/libc-start.c:392
0x55e79b113e24 ???
0xffffffffffffffff ???
---------------------
A fatal error internal to GDB has been detected, further
debugging is not possible.  GDB will now terminate.

I also found out that this happens only if symbol-file tools/system executes. If symbols are not loaded in gdb, gdb works well, so I wonder what’s happening?

Thanks!

2

Answers


  1. Chosen as BEST ANSWER

    I solved the problem by avoiding -fstrength-reduce. I guess some of the instructions compiled by this option can not be identified in gdb?


  2. so I wonder what’s happening?

    Obviously there is a bug in GDB.

    But for anything more definitive than that you’ll need to either make a reproducible test case, or at least use non-stripped version of gdb-multiarch, so the crashing function within it can be identified.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search