I asked yesterday in the IRC channel how to add debugging symbols to a binary from a package I build. Jow offered two possibilities. He said that it can be done on the command line by adding something, and that it doesn't always work. If it doesn't work, it is possible to add
TARGET_CFLAGS+=-ggdb3 -O0to the Makefile.
Since the second method sounded like a sure bet, I tried it first and sadly I didn't keep the first method command line parameter.
I tried adding the line to the Makefile at the global scope and in the define Package section but I think that both of them did not add debugging symbols. I ran objdump and readelf on the resulting binaries (extracted with "tar zxvf serval-dna.ipk") and these are the outputs:
% readelf -aw servald
ELF Header:
Magic: 7f 45 4c 46 01 02 01 00 01 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, big endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 1
Type: EXEC (Executable file)
Machine: MIPS R3000
Version: 0x1
Entry point address: 0x40a910
Start of program headers: 52 (bytes into file)
Start of section headers: 0 (bytes into file)
Flags: 0x70001005, noreorder, cpic, o32, mips32r2
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 8
Size of section headers: 0 (bytes)
Number of section headers: 0
Section header string table index: 0
There are no sections in this file.
There are no sections to group in this file.
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
PHDR 0x000034 0x00400034 0x00400034 0x00100 0x00100 R E 0x4
INTERP 0x000134 0x00400134 0x00400134 0x00014 0x00014 R 0x1
[Requesting program interpreter: /lib/ld-uClibc.so.0]
REGINFO 0x000148 0x00400148 0x00400148 0x00018 0x00018 R 0x4
LOAD 0x000000 0x00400000 0x00400000 0x206754 0x206754 R E 0x10000
LOAD 0x206754 0x00616754 0x00616754 0x0fc44 0x145414 RW 0x10000
DYNAMIC 0x000160 0x00400160 0x00400160 0x00138 0x00138 RWE 0x4
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RWE 0x4
NULL 0x000000 0x00000000 0x00000000 0x00000 0x00000 0x4
Dynamic section at offset 0x160 contains 34 entries:
Tag Type Name/Value
0x00000001 (NEEDED) Shared library: [libm.so.0]
0x00000001 (NEEDED) Shared library: [libdl.so.0]
0x00000001 (NEEDED) Shared library: [librt.so.0]
0x00000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x00000001 (NEEDED) Shared library: [libpthread.so.0]
0x00000001 (NEEDED) Shared library: [libc.so.0]
0x0000000c (INIT) 0x40a894
0x0000000d (FINI) 0x5cf200
0x00000004 (HASH) 0x400298
0x00000005 (STRTAB) 0x4058d0
0x00000006 (SYMTAB) 0x401a60
0x0000000a (STRSZ) 18260 (bytes)
0x0000000b (SYMENT) 16 (bytes)
0x70000016 (MIPS_RLD_MAP) 0x625350
0x00000015 (DEBUG) 0x0
0x00000003 (PLTGOT) 0x625360
0x00000011 (REL) 0x40a834
0x00000012 (RELSZ) 88 (bytes)
0x00000013 (RELENT) 8 (bytes)
0x70000001 (MIPS_RLD_VERSION) 1
0x70000005 (MIPS_FLAGS) NOTPOT
0x70000006 (MIPS_BASE_ADDRESS) 0x400000
0x7000000a (MIPS_LOCAL_GOTNO) 858
0x70000011 (MIPS_SYMTABNO) 999
0x70000012 (MIPS_UNREFEXTNO) 42
0x70000013 (MIPS_GOTSYM) 0x32e
0x00000014 (PLTREL) REL
0x00000017 (JMPREL) 0x40a88c
0x00000002 (PLTRELSZ) 8 (bytes)
0x70000032 (MIPS_PLTGOT) 0x625354
0x6ffffffe (VERNEED) 0x40a7f4
0x6fffffff (VERNEEDNUM) 1
0x6ffffff0 (VERSYM) 0x40a024
0x00000000 (NULL) 0x0
There are no relocations in this file.
There are no unwind sections in this file.
Histogram for bucket list length (total of 521 buckets):
Length Number % of total Coverage
0 75 ( 14.4%)
1 156 ( 29.9%) 15.6%
2 131 ( 25.1%) 41.9%
3 93 ( 17.9%) 69.8%
4 43 ( 8.3%) 87.1%
5 12 ( 2.3%) 93.1%
6 9 ( 1.7%) 98.5%
7 1 ( 0.2%) 99.2%
8 1 ( 0.2%) 100.0%
No version information found in this file.
readelf: Warning: Virtual address 0x625360 not located in any PT_LOAD segment.
readelf: Error: Unable to read in 0x104c bytes of GOT% objdump -g ./servald
./servald: file format elf32-bigHere is the complete makefile (It's a bit different than what you wrote Jow, after the developers of serval saw your makefile and patch they changed it to work without the patch).
include $(TOPDIR)/rules.mk
PKG_NAME:=serval-dna
PKG_VERSION:=2012-10-25
PKG_RELEASE=$(PKG_SOURCE_VERSION)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/servalproject/serval-dna.git
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=be3b529504450680065008aab95e2ed3f1a5a3d5
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_FIXUP:=autoreconf
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_BUILD_DEPENDS:=
include $(INCLUDE_DIR)/package.mk
define Package/serval-dna
SECTION:=utils
CATEGORY:=Utilities
TITLE:=serval-dna
DEPENDS:=+libpthread +librt
endef
define Package/serval-dna/description
Serval Daemon
endef
define Package/serval-dna/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/servald $(1)/usr/bin
endef
$(eval $(call BuildPackage,serval-dna))So the questions are:
1. What are the command line arguments of make that I lost and can add debugging symbols?
2. Where in the makefile should I add the line suggested in order for the debugging symbols to be added?
3. How to check if debugging symbols were actually added?
Thank you!
