My Training Period: xx hours
| The nm - Listing Symbols From Object File
Examples Using nm
[bodo@bakawali testbed5]$ ls -l total 20 -rwxrwxr-x 1 bodo bodo 6403 Feb 19 11:35 testbuff -rw-rw-r-- 1 bodo bodo 179 Feb 19 11:35 testbuff.c [bodo@bakawali testbed5]$ cat testbuff.c
|
[bodo@bakawali testbed5]$ nm -t d -l -S -v testbuff
U gets@@GLIBC_2.0
w __gmon_start__
w _Jv_RegisterClasses
U __libc_start_main@@GLIBC_2.0
U printf@@GLIBC_2.0
U puts@@GLIBC_2.0
134513344 T _init
134513448 T _start
134513484 t call_gmon_start
134513520 t __do_global_dtors_aux
134513572 t frame_dummy
134513616 00000054 T Test /home/bodo/testbed5/testbuff.c:5
134513670 00000040 T main /home/bodo/testbed5/testbuff.c:13
134513712 00000082 T __libc_csu_init
134513796 00000066 T __libc_csu_fini
134513864 t __do_global_ctors_aux
134513900 T _fini
134513928 00000004 R _fp_hw
134513932 00000004 R _IO_stdin_used
134513952 r __FRAME_END__
134518052 d __CTOR_LIST__
134518052 A __fini_array_end
134518052 A __fini_array_start
134518052 A __init_array_end
134518052 A __init_array_start
134518052 A __preinit_array_end
134518052 A __preinit_array_start
134518056 d __CTOR_END__
134518060 d __DTOR_LIST__
134518064 d __DTOR_END__
134518068 d __JCR_END__
134518068 d __JCR_LIST__
134518072 D _DYNAMIC
134518276 D _GLOBAL_OFFSET_TABLE_
134518304 D __data_start
134518304 W data_start
134518308 D __dso_handle
134518312 d p.0
134518316 A __bss_start
134518316 00000001 b completed.1
134518316 A _edata
134518320 A _end
[bodo@bakawali testbed5]$
objdump | ||
objdump will display information from object files. objdump displays information about one or more object files. The options control what particular information to display. This information is mostly useful to programmers who are working on the compilation tools, as opposed to programmers who just want their program to compile and work. objfile are the object files to be examined. When you specify archives, objdump shows information on each of the member object files. | ||
Display information from object <file(s)>. | ||
At least one of the following switches must be given: | ||
-a, --archive-headers | Display archive header information | |
-f, --file-headers | Display the contents of the overall file header | |
-p, --private-headers | Display object format specific file header contents | |
-h, --[section-]headers | Display the contents of the section headers | |
-x, --all-headers | Display the contents of all headers | |
-d, --disassemble | Display assembler contents of executable sections | |
-D, --disassemble-all | Display assembler contents of all sections | |
-S, --source | Intermix source code with disassembly | |
-s, --full-contents | Display the full contents of all sections requested | |
-g, --debugging | Display debug information in object file | |
-e, --debugging-tags | Display debug information using ctags style | |
-G, --stabs | Display (in raw form) any STABS info in the file | |
-t, --syms | Display the contents of the symbol table(s) | |
-T, --dynamic-syms | Display the contents of the dynamic symbol table | |
-r, --reloc | Display the relocation entries in the file | |
-R, --dynamic-reloc | Display the dynamic relocation entries in the file | |
-v, --version | Display this program's version number | |
-i, --info | List object formats and architectures supported | |
-H, --help | Display this information | |
The following switches are optional: | ||
-b, --target=BFDNAME | Specify the target object format as BFDNAME | |
-m, --architecture=MACHINE | Specify the target architecture as MACHINE | |
-j, --section=NAME | Only display information for section NAME | |
-M, --disassembler-options=OPT | Pass text OPT on to the disassembler | |
-EB --endian=big | Assume big endian format when disassembling | |
-EL --endian=little | Assume little endian format when disassembling | |
--file-start-context | Include context from start of file (with -S) | |
-I, --include=DIR | Add DIR to search list for source files | |
-l, --line-numbers | Include line numbers and filenames in output | |
-C, --demangle[={none,auto, gnu,lucid,arm,hp,edg,gnu-v3,java,gnat,compaq}] | Decode mangled/processed symbol names | |
--demangler=<dso:function> | Set dso and demangler function | |
-w, --wide | Format output for more than 80 columns | |
-z, --disassemble-zeroes | Do not skip blocks of zeroes when disassembling | |
--start-address=ADDR | Only process data whose address is >= ADDR | |
--stop-address=ADDR | Only process data whose address is <= ADDR | |
--prefix-addresses | Print complete address alongside disassembly | |
--[no-]show-raw-insn | Display hex alongside symbolic disassembly | |
--adjust-vma=OFFSET | Add OFFSET to all displayed section addresses | |
[bodo@bakawali testbed5]$ objdump -d testbuff.o
testbuff.o: file format elf32-i386
Disassembly of section .text:
00000000 <Test>:
0: 55 push %ebp
1: 89 e5 mov %esp, %ebp
3: 83 ec 08 sub $0x8, %esp
6: 83 ec 0c sub $0xc, %esp
9: 68 00 00 00 00 push $0x0
e: e8 fc ff ff ff call f <Test+0xf>
13: 83 c4 10 add $0x10, %esp
16: 83 ec 0c sub $0xc, %esp
19: 8d 45 fc lea 0xfffffffc(%ebp), %eax
1c: 50 push %eax
1d: e8 fc ff ff ff call 1e <Test+0x1e>
22: 83 c4 10 add $0x10, %esp
25: 83 ec 0c sub $0xc, %esp
28: 8d 45 fc lea 0xfffffffc(%ebp), %eax
2b: 50 push %eax
2c: e8 fc ff ff ff call 2d <Test+0x2d>
31: 83 c4 10 add $0x10, %esp
34: c9 leave
35: c3 ret
00000036 <main>:
36: 55 push %ebp
37: 89 e5 mov %esp, %ebp
39: 83 ec 08 sub $0x8, %esp
3c: 83 e4 f0 and $0xfffffff0, %esp
3f: b8 00 00 00 00 mov $0x0, %eax
44: 83 c0 0f add $0xf, %eax
47: 83 c0 0f add $0xf, %eax
4a: c1 e8 04 shr $0x4, %eax
4d: c1 e0 04 shl $0x4, %eax
50: 29 c4 sub %eax, %esp
52: e8 fc ff ff ff call 53 <main+0x1d>
57: b8 00 00 00 00 mov $0x0, %eax
5c: c9 leave
5d: c3 ret
[bodo@bakawali testbed5]$
[bodo@bakawali testbed5]$ objdump -t testbuff.o
testbuff.o: file format elf32-i386
SYMBOL TABLE:
00000000 l df *ABS* 00000000 testbuff.c
00000000 l d .text 00000000
00000000 l d .data 00000000
00000000 l d .bss 00000000
00000000 l d .rodata 00000000
00000000 l d .note.GNU-stack 00000000
00000000 l d .comment 00000000
00000000 g F .text 00000036 Test
00000000 *UND* 00000000 printf
00000000 *UND* 00000000 gets
00000000 *UND* 00000000 puts
00000036 g F .text 00000028 main
[bodo@bakawali testbed5]$ objdump -r testbuff.o
testbuff.o: file format elf32-i386
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
0000000a R_386_32 .rodata
0000000f R_386_PC32 printf
0000001e R_386_PC32 gets
0000002d R_386_PC32 puts
00000053 R_386_PC32 Test
[bodo@bakawali testbed5]$ objdump -T testbuff
testbuff: file format elf32-i386
DYNAMIC SYMBOL TABLE:
00000000 DF *UND* 00000165 GLIBC_2.0 gets
00000000 DF *UND* 000001ab GLIBC_2.0 puts
00000000 DF *UND* 000000ef GLIBC_2.0 __libc_start_main
00000000 DF *UND* 00000036 GLIBC_2.0 printf
0804850c g DO .rodata 00000004 Base _IO_stdin_used
00000000 w D *UND* 00000000 _Jv_RegisterClasses
00000000 w D *UND* 00000000 __gmon_start__
bodo@bakawali testbed5]$ objdump -R testbuff
testbuff: file format elf32-i386
DYNAMIC RELOCATION RECORDS
OFFSET TYPE VALUE
08049600 R_386_GLOB_DAT __gmon_start__
08049610 R_386_JUMP_SLOT gets
08049614 R_386_JUMP_SLOT puts
08049618 R_386_JUMP_SLOT __libc_start_main
0804961c R_386_JUMP_SLOT printf
[bodo@bakawali testbed5]$ objdump -h testbuff
testbuff: file format elf32-i386
Sections:
Idx Name Size VMA LMA File off Algn
0 .interp 00000013 08048114 08048114 00000114 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
1 .note.ABI-tag 00000020 08048128 08048128 00000128 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .hash 00000034 08048148 08048148 00000148 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .dynsym 00000080 0804817c 0804817c 0000017c 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .dynstr 0000006a 080481fc 080481fc 000001fc 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .gnu.version 00000010 08048266 08048266 00000266 2**1
CONTENTS, ALLOC, LOAD, READONLY, DATA
6 .gnu.version_r 00000020 08048278 08048278 00000278 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
7 .rel.dyn 00000008 08048298 08048298 00000298 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
8 .rel.plt 00000020 080482a0 080482a0 000002a0 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
9 .init 00000017 080482c0 080482c0 000002c0 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
10 .plt 00000050 080482d8 080482d8 000002d8 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
11 .text 000001c4 08048328 08048328 00000328 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
12 .fini 0000001a 080484ec 080484ec 000004ec 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
13 .rodata 00000015 08048508 08048508 00000508 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
14 .eh_frame 00000004 08048520 08048520 00000520 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
15 .ctors 00000008 08049524 08049524 00000524 2**2
CONTENTS, ALLOC, LOAD, DATA
16 .dtors 00000008 0804952c 0804952c 0000052c 2**2
CONTENTS, ALLOC, LOAD, DATA
17 .jcr 00000004 08049534 08049534 00000534 2**2
CONTENTS, ALLOC, LOAD, DATA
18 .dynamic 000000c8 08049538 08049538 00000538 2**2
CONTENTS, ALLOC, LOAD, DATA
19 .got 00000004 08049600 08049600 00000600 2**2
CONTENTS, ALLOC, LOAD, DATA
20 .got.plt 0000001c 08049604 08049604 00000604 2**2
CONTENTS, ALLOC, LOAD, DATA
21 .data 0000000c 08049620 08049620 00000620 2**2
CONTENTS, ALLOC, LOAD, DATA
22 .bss 00000004 0804962c 0804962c 0000062c 2**2
ALLOC
23 .comment 00000126 00000000 00000000 0000062c 2**0
CONTENTS, READONLY
24 .debug_aranges 00000020 00000000 00000000 00000752 2**0
CONTENTS, READONLY, DEBUGGING
25 .debug_pubnames 00000024 00000000 00000000 00000772 2**0
CONTENTS, READONLY, DEBUGGING
26 .debug_info 000001de 00000000 00000000 00000796 2**0
CONTENTS, READONLY, DEBUGGING
27 .debug_abbrev 000000df 00000000 00000000 00000974 2**0
CONTENTS, READONLY, DEBUGGING
28 .debug_line 0000004c 00000000 00000000 00000a53 2**0
CONTENTS, READONLY, DEBUGGING
29 .debug_frame 00000048 00000000 00000000 00000aa0 2**2
CONTENTS, READONLY, DEBUGGING
30 .debug_str 0000000d 00000000 00000000 00000ae8 2**0
CONTENTS, READONLY, DEBUGGING
Check the best selling C / C++, Networking, Linux and Open Source books at Amazon.com.
Linux Socket programming tutorial.
C, Buffer overflow and stack frame (construction and destruction).