Every loadable or allocatable output section has two addresses. The first is the VMA, or virtual memory address. This is the address the section will have when the output file is run. The second is the LMA, or load memory address. This is the address at which the section will be loaded. In most cases the two addresses will be the same. An example of when they might be different is when a data section is loaded into ROM, and then copied into RAM when the program starts up (this technique is often used to initialize global variables in a ROM based system). In this case the ROM address would be the LMA, and the RAM address would be the VMA.
a.o: file format elf64-littleaarch64
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
000000000000002c R_AARCH64_ADR_PREL_PG_HI21 .data
0000000000000030 R_AARCH64_ADD_ABS_LO12_NC .data
000000000000003c R_AARCH64_ADR_PREL_PG_HI21 .data
0000000000000040 R_AARCH64_ADD_ABS_LO12_NC .data
0000000000000048 R_AARCH64_ADR_PREL_PG_HI21 .bss
000000000000004c R_AARCH64_ADD_ABS_LO12_NC .bss
0000000000000058 R_AARCH64_ADR_PREL_PG_HI21 .bss+0x0000000000000004
000000000000005c R_AARCH64_ADD_ABS_LO12_NC .bss+0x0000000000000004
0000000000000068 R_AARCH64_ADR_PREL_PG_HI21 b_share
000000000000006c R_AARCH64_ADD_ABS_LO12_NC b_share
000000000000007c R_AARCH64_CALL26 b_func
0000000000000084 R_AARCH64_ADR_PREL_PG_HI21 b_share
0000000000000088 R_AARCH64_ADD_ABS_LO12_NC b_share
RELOCATION RECORDS FOR [.data]:
OFFSET TYPE VALUE
0000000000000008 R_AARCH64_ABS64 .rodata
Symbol table '.symtab' contains 20 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000000 0 FILE LOCAL DEFAULT ABS a.c
2: 0000000000000000 0 SECTION LOCAL DEFAULT 1
3: 0000000000000000 0 SECTION LOCAL DEFAULT 3
4: 0000000000000000 0 SECTION LOCAL DEFAULT 5
5: 0000000000000000 0 NOTYPE LOCAL DEFAULT 3 $d
6: 0000000000000000 4 OBJECT LOCAL DEFAULT 3 a_0
7: 0000000000000000 0 SECTION LOCAL DEFAULT 6
8: 0000000000000000 0 NOTYPE LOCAL DEFAULT 6 $d
9: 0000000000000008 8 OBJECT LOCAL DEFAULT 3 a_1
10: 0000000000000000 4 OBJECT LOCAL DEFAULT 5 a_3
11: 0000000000000000 0 NOTYPE LOCAL DEFAULT 5 $d
12: 0000000000000004 4 OBJECT LOCAL DEFAULT 5 a_4
13: 0000000000000000 0 NOTYPE LOCAL DEFAULT 1 $x
14: 0000000000000000 32 FUNC LOCAL DEFAULT 1 a_func
15: 0000000000000000 0 SECTION LOCAL DEFAULT 8
16: 0000000000000000 0 SECTION LOCAL DEFAULT 7
17: 0000000000000020 140 FUNC GLOBAL DEFAULT 1 main
18: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND b_share
19: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND b_func
int c_share = 0xFF;
static int c_0 = 0x7f;
static const char *c_1 = "ccccccccccc";
static int c_3;
static int c_4 = 0;
int b_func(int c, int d)
{
static int c_5 = 0xAA;
int a = 0;
c_0 ++;
c_1[5];
c_3 = 1;
c_4 = 5;
a = c_3 + c_4 + c_0;
return a;
}
flowchart LR
A[d.c]-->|gcc -c|B[d.o]-->|ar -crv|C[de.a]
E[e.c]-->|gcc -c|F[e.o]-->|ar -crv|C
#include "d.h"
extern int e_abs(int a);
int sum(int a, int b)
{
return a + b;
}
int sub(int a, int b)
{
return a - b;
}
int abs(int a)
{
return e_abs(a);
}
#include "e.h"
int e_abs(int a)
{
if (a >= 0) {
return a;
} else {
return -a;
}
}
flowchart LR
C[de.a]-->|ar -t|B[d.o]
C[de.a]-->|ar -t|F[e.o]