Search code examples
linuxgdbcoredumpdebug-symbolsobjcopy

I have generated a linux core dump with debug symbols in target system. But I am unable to debug the dump using GDB in host system


I am building a debugging system to debug a exe(e.g. coredump) which is crashed in remote system. The debug symbols along with the core dump (e.g. coredump.dbg, coredump_core.dump) is sent to host system. In host system when I use GDB to analyze a dump I am getting all these errors mentioned below. Some body please help how the shared libraries has to be sent to host. If yes, then how?

How should I link the shared libraries in debug symbols in host system

following are the errors

1.readelf -a coredump.dbg

  ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x400720
  Start of program headers:          64 (bytes into file)
  Start of section headers:          14864 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         9
  Size of section headers:           64 (bytes)
  Number of section headers:         36
  Section header string table index: 35

  readelf: Error: Unable to read in 0x900 bytes of section headers

  readelf: Error: Section headers are not available!

2.gdb coredump.dbg coredump_core.dump

GNU gdb (GDB) Red Hat Enterprise Linux (7.2-92.el6)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later      <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
**"/root/coredump.dbg": not in executable format: File format not recognized
"/root/coredump_core.dump" is not a core dump: File format not recognized
(gdb)**

3.file coredump.dbg

coredump.dbg: ERROR: ELF 64-bit LSB executable, x86-64, version 1 (SYSV),             statically linked (uses shared libs)error reading (Invalid argument)

Solution

  • How should I link the shared libraries in debug symbols in host system

    Your problem has nothing to do with any shared libraries (you may have a problem with them as well, but you should solve the immediate problem first).

    Your immediate problem is that your binary: coredump.dbg has been corrupted in some way. This is the key message from readelf: Error: Unable to read in 0x900 bytes of section headers.

    This could happen in a few different ways:

    1. You have a buggy linker (that is very unlikely).
    2. You are using some combination of objcopy and/or strip, and are not doing it correctly.
    3. You transfer the file between target and host in a way that corrupts it (using e.g. ASCII-mode FTP transfer).