|
|
Relocation is the process of connecting symbolic references with symbolic definitions. For example, when a program calls a function, the associated call instruction must transfer control to the proper destination address at execution. Relocatable files must have relocation entries which are necessary because they contain information that describes how to modify their section contents, thus allowing executable and shared object files to hold the right information for a process's program image.
typedef struct {
Elf32_Addr r_offset;
Elf32_Word r_info;
} Elf32_Rel;
typedef struct {
Elf32_Addr r_offset;
Elf32_Word r_info;
Elf32_Sword r_addend;
} Elf32_Rela;
Relocation Entries
r_offsetr_infor_info member.
#define ELF32_R_SYM(i) ((i)>>8) #define ELF32_R_TYPE(i) ((unsigned char)(i)) #define ELF32_R_INFO(s,t) (((s)<<8)+(unsigned char)(t))
r_addend
A relocation section references two other sections:
a symbol table and a section to modify.
The section header's sh_info and sh_link
members specify these relationships.
Relocation entries for different object files have
slightly different interpretations for the
r_offset member.
r_offset holds a section
offset. The relocation section itself describes how to
modify another section in the file; relocation offsets
designate a storage unit within the second section.
r_offset
holds a virtual address. To make these files' relocation
entries more useful for the dynamic linker, the section
offset (file interpretation) gives way to a virtual address
(memory interpretation).
r_offset changes for
different object files to allow efficient access by the
relevant programs, the relocation types' meanings stay the
same.