Dump memory
The ‘arm-none-eabi-objdump’ command displays information from an object file.
At least one switch must be given.
Let’s try the following command, with -f (file header):
$ arm-none-eabi-objdump -f fhc.o
fhc.o: file format elf32-littlearm
architecture: armv7e-m, flags 0x00000011:
HAS_RELOC, HAS_SYMS
start address 0x00000000
- elf32: the ELF file is designed for 32-bit systems
ELF means Executable and Linkable Format and is a standard file format used mainly on Unix/Linux systems.
- littlearm:
short for “little-endian” and means that the LSB (least significant byte or “little end”) is stored first in memory. ARM architecture can operate in both little-endian and big-endian modes.
- architecture:
armv7e-m: “armv7e-m” refers to the ARMv7-M architecture, where “M” stands for Microcontroller
- flags 0x00000010 (HAS_SYMS):
the flag “0x00000011” indicates that the object file contains relocation information (bit 0 HAS_RELOC) and symbol information (bit 1 HAS_SYMbolS). Symbols are names associated with addresses in the code and data sections of the executable.
- start address 0x00000000:
represents the entry point of the executable when it is loaded into memory.
Now, let’s try the command with -h (file header):
$ arm-none-eabi-objdump -h fhc.o
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000108 00000000 00000000 00000034 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000022 00000000 00000000 0000013c 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 0000015e 2**0
ALLOC
3 .debug_line 00000035 00000000 00000000 0000015e 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
4 .debug_info 00000026 00000000 00000000 00000193 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
5 .debug_abbrev 00000014 00000000 00000000 000001b9 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
6 .debug_aranges 00000020 00000000 00000000 000001d0 2**3
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
7 .debug_str 0000002a 00000000 00000000 000001f0 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
8 .ARM.attributes 00000021 00000000 00000000 0000021a 2**0
CONTENTS, READONLY
Idx: The index or number of the section.
Name: The name of the section.
Size: The size of the section in hexadecimal (in bytes).
VMA (Virtual Memory Address): The virtual address where the section will be loaded into memory during program execution.
LMA (Load Memory Address): The load address of the section in memory. This might be different from the VMA in certain situations.
File off (File Offset): The offset of the section in the file.
Algn (Alignment): The alignment of the section. The value is in the form of 2 to the power of the specified number.
.data has a size of 34 elements (0X22)
which accounts for the word 0xdeadbeef (32 bits or 4 bytes)
- and
the short variable ‘tic’ (2 bytes)
- and
hello: .ascii “Aabcdefghijklmnopqrstuvwxyzn” (28 bytes).
.text has a size of 264 bytes (0x108).
These informations can also be retrieved with
$ arm-none-eabi-size fhc.o
text data bss dec hex filename
264 34 0 298 12a fhc.o
text is the size of all code in your application.
data is the size of initialized global variables.
bss is the size of uninitialized global variables or initialized to zero.
dec and hex are the sum of text, data and bss in decimal and hexadecimal.
SYMBOL TABLE
Let’s look at the symbol table (use the t switch). It displays the static symbols (non-shared):
$ arm-none-eabi-objdump -t fhc.o
SYMBOL TABLE:
00000000 l d .text 00000000 .text
00000000 l d .data 00000000 .data
00000000 l d .bss 00000000 .bss
00000006 l .data 00000000 hello
00000100 l .text 00000000 Reset_Handler
00000102 l .text 00000000 loop
00000000 l d .debug_info 00000000 .debug_info
00000000 l d .debug_abbrev 00000000 .debug_abbrev
00000000 l d .debug_line 00000000 .debug_line
00000000 l d .debug_str 0 00000000 .debug_str
00000000 l d .debug_aranges 00000000 .debug_aranges
00000000 l d .ARM.attributes 00000000 .ARM.attributes
00000004 g .data 00000000 tic
You can also use ‘readelf’:
$arm-none-eabi-readelf -s fhc.o
Symbol table '.symtab' contains 16 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00000000 0 SECTION LOCAL DEFAULT 1 .text
2: 00000000 0 SECTION LOCAL DEFAULT 2 .data
3: 00000000 0 SECTION LOCAL DEFAULT 3 .bss
4: 00000008 0 NOTYPE LOCAL DEFAULT 1 $d
5: 00000006 0 NOTYPE LOCAL DEFAULT 2 hello
6: 00000100 0 NOTYPE LOCAL DEFAULT 1 Reset_Handler
7: 00000100 0 NOTYPE LOCAL DEFAULT 1 $t
8: 00000102 0 NOTYPE LOCAL DEFAULT 1 loop
9: 00000000 0 SECTION LOCAL DEFAULT 6 .debug_info
10: 00000000 0 SECTION LOCAL DEFAULT 8 .debug_abbrev
11: 00000000 0 SECTION LOCAL DEFAULT 4 .debug_line
12: 00000000 0 SECTION LOCAL DEFAULT 11 .debug_str
13: 00000000 0 SECTION LOCAL DEFAULT 9 .debug_aranges
14: 00000000 0 SECTION LOCAL DEFAULT 12 .ARM.attributes
15: 00000004 0 NOTYPE GLOBAL DEFAULT 2 tic
with objdump
Column 1 (address): symbol's address
When it is all zeros, it might account for placeholder values to be filled by the linker.
Column 2 (binding): indicates the binding of symbol.
"l" signifies a local symbol, "g" a global symbol.
"F", "f", "O" symbol is the name of a function, a file, an object.
Column 3 (type): represents the type of the symbol
"d" is a SECTION
" " is NOTYPE
Column 4 (name): name of the symbol.
Column 5 (size): size of the symbol.
Column 6 (section): indicates the section to which the symbol belongs.
Note
relocation at Relocation.
Note
relocation at Disassembling.
$ arm-none-eabi-objdump -T fhc.o
arm-none-eabi-objdump: fhc.o: not a dynamic object
DYNAMIC SYMBOL TABLE:
no symbols