1elf32_getphdr(3ELF) ELF Library Functions elf32_getphdr(3ELF)
2
3
4
6 elf32_getphdr, elf32_newphdr, elf64_getphdr, elf64_newphdr - retrieve
7 class-dependent program header table
8
10 cc [ flag ... ] file... -lelf [ library ... ]
11 #include <libelf.h>
12
13 Elf32_Phdr *elf32_getphdr(Elf *elf);
14
15
16 Elf32_Phdr *elf32_newphdr(Elf *elf, size_t count);
17
18
19 Elf64_Phdr *elf64_getphdr(Elf *elf);
20
21
22 Elf64_Phdr *elf64_newphdr(Elf *elf, size_t count);
23
24
26 For a 32-bit class file, elf32_getphdr() returns a pointer to the pro‐
27 gram execution header table, if one is available for the ELF descriptor
28 elf.
29
30
31 elf32_newphdr() allocates a new table with count entries, regardless of
32 whether one existed previously, and sets the ELF_F_DIRTY bit for the
33 table. See elf_flagdata(3ELF). Specifying a zero count deletes an
34 existing table. Note this behavior differs from that of elf32_newehdr()
35 allowing a program to replace or delete the program header table,
36 changing its size if necessary. See elf32_getehdr(3ELF).
37
38
39 If no program header table exists, the file is not a 32-bit class file,
40 an error occurs, or elf is NULL, both functions return a null pointer.
41 Additionally, elf32_newphdr() returns a null pointer if count is 0.
42
43
44 The table is an array of Elf32_Phdr structures, each of which includes
45 the following members:
46
47 Elf32_Word p_type;
48 Elf32_Off p_offset;
49 Elf32_Addr p_vaddr;
50 Elf32_Addr p_paddr;
51 Elf32_Word p_filesz;
52 Elf32_Word p_memsz;
53 Elf32_Word p_flags;
54 Elf32_Word p_align;
55
56
57
58 The Elf64_Phdr structures include the following members:
59
60 Elf64_Word p_type;
61 Elf64_Word p_flags;
62 Elf64_Off p_offset;
63 Elf64_Addr p_vaddr;
64 Elf64_Addr p_paddr;
65 Elf64_Xword p_filesz;
66 Elf64_Xword p_memsz;
67 Elf64_Xword p_align;
68
69
70
71 For the 64−bit class, replace 32 with 64 as appropriate.
72
73
74 The ELF header's e_phnum member tells how many entries the program
75 header table has. See elf32_getehdr(3ELF). A program may inspect this
76 value to determine the size of an existing table; elf32_newphdr() auto‐
77 matically sets the member's value to count. If the program is building
78 a new file, it is responsible for creating the file's ELF header before
79 creating the program header table.
80
82 See attributes(5) for descriptions of the following attributes:
83
84
85
86
87 ┌─────────────────────────────┬─────────────────────────────┐
88 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
89 ├─────────────────────────────┼─────────────────────────────┤
90 │Interface Stability │Stable │
91 ├─────────────────────────────┼─────────────────────────────┤
92 │MT-Level │MT-Safe │
93 └─────────────────────────────┴─────────────────────────────┘
94
96 elf(3ELF), elf32_getehdr(3ELF), elf_begin(3ELF), elf_flagdata(3ELF),
97 libelf(3LIB), attributes(5)
98
99
100
101SunOS 5.11 11 Jul 2001 elf32_getphdr(3ELF)