Elf32_Addr sh_addr;

 Elf32_Off sh_offset;

 Elf32_Word sh_size;

 Elf32_Word sh_link;

 Elf32_Word sh_info;

 Elf32_Word sh_addralign;

 Elf32_Word sh_entsize;

} Elf32_Shdr;

Program header

typedef struct {

 Elf32_Word p_type;

 Elf32_Off p_offset;

 Elf32_Addr p_vaddr;

 Elf32_Addr p_paddr;

 Elf32_Word p_filesz;

 Elf32_Word p_memsz;

 Elf32_Word p_flags;

 Elf32_Word p_align;

} Elf32_Phdr;

A section header table is an array of section header structures describing the sections of an object file. A program header table is an array of program header structures describing a loadable segment of an image that allows the loader to prepare the image for execution. Program headers are applied only to executable images and shared object files.

One of the fields in the section header structure is sh_type, which specifies the type of a section. Table 2.1 lists some section types.

Table 2.1: Section types.

NULL Inactive header without a section.
PROGBITS Code or initialized data.
SYMTAB Symbol table for static linking.
STRTAB String table.
RELA/REL Relocation entries.
HASH Run-time symbol hash table.
DYNAMIC Information used for dynamic linking.
NOBITS Uninitialized data.
DYNSYM Symbol table for dynamic linking. 

The sh_flags field in the section header specifies the attribute of a section. Table 2.2 lists some of these attributes.

Table 2.2: Section attributes.

WRITE Section contains writeable data.
ALLOC Section contains allocated data.
EXECINSTR Section contains executable instructions. 

Some common system-created default sections with predefined names for the PROGBITS are.text,.sdata,.data,.sbss, and.bss. Program code and constant data are contained in the.text section. This section is read-only because code and constant data are not expected to change during the lifetime of the program execution. The.sbss and.bss sections contain uninitialized data. The.sbss section stores small data, which is the data such as variables with sizes that fit into a specific size. This size limit is architecture-dependent. The result is that the compiler and the assembler can generate smaller and more efficient code to access these data items. The.sdata and.data sections contain initialized data items. The small data concept described for.sbss applies to.sdata. A.text section with executable code has the EXECINSTR attribute. The.sdata and.data sections have the WRITE attribute. The.sbss and.bss sections have both the WRITE and the ALLOC attributes.

Other common system-defined sections are.symtab containing the symbol table,.strtab containing the string table for the program symbols,.shstrtab containing the string table for the section names, and.relaname containing the relocation information for the section named name. We have discussed the role of the symbol table (SYMTAB) previously. In Figure 2.3, the symbol name is shown as part of the symbol table. In practice, each entry in the symbol table contains a reference to the string table (STRTAB) where the character

Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату