Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile error with cmd "make target=ARM" #128

Open
atuxli opened this issue Jan 17, 2023 · 0 comments
Open

compile error with cmd "make target=ARM" #128

atuxli opened this issue Jan 17, 2023 · 0 comments

Comments

@atuxli
Copy link

atuxli commented Jan 17, 2023

make target=ARM
TARGET: ARM
CRASH: 8.0.2++
GDB: 10.2

  • tar xvzmf gdb-10.2.tar.gz gdb-10.2/gdb/symtab.c gdb-10.2/gdb/printcmd.c gdb-10.2/gdb/symfile.c gdb-10.2/gdb/Makefile.in
    gdb-10.2/gdb/symtab.c
    gdb-10.2/gdb/symfile.c
    gdb-10.2/gdb/printcmd.c
    gdb-10.2/gdb/Makefile.in
  • exit 0
    patching file gdb-10.2/Makefile.in
    Reversed (or previously applied) patch detected! Skipping patch.
    2 out of 2 hunks ignored
    patching file gdb-10.2/gdb/Makefile.in
    patching file gdb-10.2/gdb/cli/cli-cmds.c
    Reversed (or previously applied) patch detected! Skipping patch.
    4 out of 4 hunks ignored
    patching file gdb-10.2/gdb/defs.h
    Reversed (or previously applied) patch detected! Skipping patch.
    1 out of 1 hunk ignored
    patching file gdb-10.2/gdb/dwarf2/read.c
    Reversed (or previously applied) patch detected! Skipping patch.
    2 out of 2 hunks ignored
    patching file gdb-10.2/gdb/main.c
    Reversed (or previously applied) patch detected! Skipping patch.
    11 out of 11 hunks ignored
    patching file gdb-10.2/gdb/objfiles.h
    Reversed (or previously applied) patch detected! Skipping patch.
    1 out of 1 hunk ignored
    patching file gdb-10.2/gdb/printcmd.c
    patching file gdb-10.2/gdb/psymtab.c
    Reversed (or previously applied) patch detected! Skipping patch.
    2 out of 2 hunks ignored
    patching file gdb-10.2/gdb/symfile.c
    patching file gdb-10.2/gdb/symtab.c
    patching file gdb-10.2/gdb/ui-file.h
    Reversed (or previously applied) patch detected! Skipping patch.
    1 out of 1 hunk ignored
    patching file gdb-10.2/gdb/xml-syscall.c
    Reversed (or previously applied) patch detected! Skipping patch.
    1 out of 1 hunk ignored
    patching file gdb-10.2/libiberty/Makefile.in
    Reversed (or previously applied) patch detected! Skipping patch.
    2 out of 2 hunks ignored
    patching file gdb-10.2/opcodes/i386-dis.c
    Reversed (or previously applied) patch detected! Skipping patch.
    1 out of 1 hunk ignored
    patching file gdb-10.2/readline/readline/misc.c
    Reversed (or previously applied) patch detected! Skipping patch.
    1 out of 1 hunk ignored
    patching file gdb-10.2/readline/readline/readline.h
    Reversed (or previously applied) patch detected! Skipping patch.
    1 out of 1 hunk ignored
    patching file gdb-10.2/readline/readline/rltypedefs.h
    Reversed (or previously applied) patch detected! Skipping patch.
    1 out of 1 hunk ignored
    patching file gdb-10.2/readline/readline/util.c
    Reversed (or previously applied) patch detected! Skipping patch.
    2 out of 2 hunks ignored
    patching file gdb-10.2/gdb/completer.c
    Reversed (or previously applied) patch detected! Skipping patch.
    1 out of 1 hunk ignored
    patching file gdb-10.2/gdb/ada-lang.c
    Reversed (or previously applied) patch detected! Skipping patch.
    3 out of 3 hunks ignored
    patching file gdb-10.2/gdb/Makefile.in
    patching file gdb-10.2/gdb/c-typeprint.c
    patching file gdb-10.2/gdb/symfile.c
    patching file gdb-10.2/gdb/printcmd.c
    patching file gdb-10.2/gdb/symtab.c
    patching file gdb-10.2/gdb/symtab.c
    patching file gdb-10.2/gdb/gdbtypes.c
    if [ x"" != x ]; then
    gcc -c -DHAVE_CONFIG_H -m32 -I. -I./../include -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -Wshadow=local -pedantic -D_GNU_SOURCE ./regex.c -o pic/regex.o;
    else true; fi
    if [ x"" != x ]; then
    gcc -c -DHAVE_CONFIG_H -m32 -I. -I./../include -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -Wshadow=local -pedantic -D_GNU_SOURCE ./regex.c -o noasan/regex.o;
    else true; fi
    gcc -c -DHAVE_CONFIG_H -m32 -I. -I./../include -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -Wshadow=local -pedantic -D_GNU_SOURCE ./regex.c -o regex.o
    In file included from ./regex.c:38:
    ./config.h:568:15: error: two or more data types in declaration specifiers
    568 | #define pid_t int
    | ^~~
    make[5]: *** [Makefile:1195: regex.o] Error 1
    make[4]: *** [Makefile:7122: all-libiberty] Error 2
    make[3]: *** [Makefile:860: all] Error 2
    make[2]: *** [Makefile:274: rebuild] Error 2
    make[1]: *** [Makefile:262: gdb_merge] Error 2
    make: *** [Makefile:254: all] Error 2
feijie1113 pushed a commit to feijie1113/crash that referenced this issue Apr 14, 2023
We met "bt" command on KASAN kernel vmcore display truncated backtraces
like this:

  crash> bt
  PID: 4131   TASK: ffff8001521df000  CPU: 3   COMMAND: "bash"
   #0 [ffff2000224b0cb0] machine_kexec_prepare at ffff2000200bff4c

After digging the root cause, it turns out that arm64_in_kdump_text()
found wrong bt->bptr at "machine_kexec" branch.

Disassemble machine_kexec() of KASAN vmlinux (gcc 7.3.0):

  crash> dis -x machine_kexec
  0xffff2000200bff50 <machine_kexec>:     stp     x29, x30, [sp,#-208]!
  0xffff2000200bff54 <machine_kexec+0x4>: mov     x29, sp
  0xffff2000200bff58 <machine_kexec+0x8>: stp     x19, x20, [sp,crash-utility#16]
  0xffff2000200bff5c <machine_kexec+0xc>: str     x24, [sp,crash-utility#56]
  0xffff2000200bff60 <machine_kexec+0x10>:        str     x26, [sp,crash-utility#72]
  0xffff2000200bff64 <machine_kexec+0x14>:        mov     x2, #0x8ab3
  0xffff2000200bff68 <machine_kexec+0x18>:        add     x1, x29, #0x70
  0xffff2000200bff6c <machine_kexec+0x1c>:        lsr     x1, x1, crash-utility#3
  0xffff2000200bff70 <machine_kexec+0x20>:        movk    x2, #0x41b5, lsl crash-utility#16
  0xffff2000200bff74 <machine_kexec+0x24>:        mov     x19, #0x200000000000
  0xffff2000200bff78 <machine_kexec+0x28>:        adrp    x3, 0xffff2000224b0000
  0xffff2000200bff7c <machine_kexec+0x2c>:        movk    x19, #0xdfff, lsl crash-utility#48
  0xffff2000200bff80 <machine_kexec+0x30>:        add     x3, x3, #0xcb0
  0xffff2000200bff84 <machine_kexec+0x34>:        add     x4, x1, x19
  0xffff2000200bff88 <machine_kexec+0x38>:        stp     x2, x3, [x29,crash-utility#112]
  0xffff2000200bff8c <machine_kexec+0x3c>:        adrp    x2, 0xffff2000200bf000 <swsusp_arch_resume+0x1e8>
  0xffff2000200bff90 <machine_kexec+0x40>:        add     x2, x2, #0xf50
  0xffff2000200bff94 <machine_kexec+0x44>:        str     x2, [x29,crash-utility#128]
  0xffff2000200bff98 <machine_kexec+0x48>:        mov     w2, #0xf1f1f1f1
  0xffff2000200bff9c <machine_kexec+0x4c>:        str     w2, [x1,x19]
  0xffff2000200bffa0 <machine_kexec+0x50>:        mov     w2, #0xf200
  0xffff2000200bffa4 <machine_kexec+0x54>:        mov     w1, #0xf3f3f3f3
  0xffff2000200bffa8 <machine_kexec+0x58>:        movk    w2, #0xf2f2, lsl crash-utility#16
  0xffff2000200bffac <machine_kexec+0x5c>:        stp     w2, w1, [x4,crash-utility#4]

We notice that:
1. machine_kexec() start address is 0xffff2000200bff50
2. the instruction at machine_kexec+0x44 stores the same value
   0xffff2000200bff50 (comes from 0xffff2000200bf000 + 0xf50)
   into stack postion [x29,crash-utility#128].

When arm64_in_kdump_text() searches for LR from stack, it met
0xffff2000200bff50 firstly, so got wrong bt->bptr.

We know that the real LR is always greater than the start address
of a function, so let's fix it by changing the search conditon to
(*ptr > xxx_start) && (*ptr < xxx_end).

Signed-off-by: Ding Hui <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant