/src/libbpf/elfutils/libelf/elf32_getshdr.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* Return section header. |
2 | | Copyright (C) 1998-2002, 2005, 2007, 2009, 2012, 2014, 2015 Red Hat, Inc. |
3 | | This file is part of elfutils. |
4 | | Written by Ulrich Drepper <drepper@redhat.com>, 1998. |
5 | | |
6 | | This file is free software; you can redistribute it and/or modify |
7 | | it under the terms of either |
8 | | |
9 | | * the GNU Lesser General Public License as published by the Free |
10 | | Software Foundation; either version 3 of the License, or (at |
11 | | your option) any later version |
12 | | |
13 | | or |
14 | | |
15 | | * the GNU General Public License as published by the Free |
16 | | Software Foundation; either version 2 of the License, or (at |
17 | | your option) any later version |
18 | | |
19 | | or both in parallel, as here. |
20 | | |
21 | | elfutils is distributed in the hope that it will be useful, but |
22 | | WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
24 | | General Public License for more details. |
25 | | |
26 | | You should have received copies of the GNU General Public License and |
27 | | the GNU Lesser General Public License along with this program. If |
28 | | not, see <http://www.gnu.org/licenses/>. */ |
29 | | |
30 | | #ifdef HAVE_CONFIG_H |
31 | | # include <config.h> |
32 | | #endif |
33 | | |
34 | | #include <assert.h> |
35 | | #include <errno.h> |
36 | | #include <stdbool.h> |
37 | | |
38 | | #include "libelfP.h" |
39 | | #include "common.h" |
40 | | |
41 | | #ifndef LIBELFBITS |
42 | | # define LIBELFBITS 32 |
43 | | #endif |
44 | | |
45 | | |
46 | | static ElfW2(LIBELFBITS,Shdr) * |
47 | | load_shdr_wrlock (Elf_Scn *scn) |
48 | 736 | { |
49 | 736 | ElfW2(LIBELFBITS,Shdr) *result; |
50 | | |
51 | | /* Read the section header table. */ |
52 | 736 | Elf *elf = scn->elf; |
53 | 736 | ElfW2(LIBELFBITS,Ehdr) *ehdr = elf->state.ELFW(elf,LIBELFBITS).ehdr; |
54 | | |
55 | | /* Try again, maybe the data is there now. */ |
56 | 736 | result = scn->shdr.ELFW(e,LIBELFBITS); |
57 | 736 | if (result != NULL) |
58 | 0 | goto out; |
59 | | |
60 | 736 | size_t shnum; |
61 | 736 | if (__elf_getshdrnum_rdlock (elf, &shnum) != 0 |
62 | 736 | || shnum > SIZE_MAX / sizeof (ElfW2(LIBELFBITS,Shdr))) |
63 | 0 | goto out; |
64 | 736 | size_t size = shnum * sizeof (ElfW2(LIBELFBITS,Shdr)); |
65 | | |
66 | | /* Allocate memory for the section headers. We know the number |
67 | | of entries from the ELF header. */ |
68 | 736 | ElfW2(LIBELFBITS,Shdr) *shdr = elf->state.ELFW(elf,LIBELFBITS).shdr = |
69 | 736 | (ElfW2(LIBELFBITS,Shdr) *) malloc (size); |
70 | 736 | if (elf->state.ELFW(elf,LIBELFBITS).shdr == NULL) |
71 | 0 | { |
72 | 0 | __libelf_seterrno (ELF_E_NOMEM); |
73 | 0 | goto out; |
74 | 0 | } |
75 | 736 | elf->state.ELFW(elf,LIBELFBITS).shdr_malloced = 1; |
76 | | |
77 | 736 | if (elf->map_address != NULL) |
78 | 736 | { |
79 | | /* First see whether the information in the ELF header is |
80 | | valid and it does not ask for too much. */ |
81 | 736 | if (unlikely (ehdr->e_shoff >= elf->maximum_size) |
82 | 736 | || unlikely (elf->maximum_size - ehdr->e_shoff < size)) |
83 | 0 | { |
84 | | /* Something is wrong. */ |
85 | 0 | __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER); |
86 | 0 | goto free_and_out; |
87 | 0 | } |
88 | | |
89 | 736 | ElfW2(LIBELFBITS,Shdr) *notcvt; |
90 | | |
91 | | /* All the data is already mapped. If we could use it |
92 | | directly this would already have happened. Unless |
93 | | we allocated the memory ourselves and the ELF_F_MALLOCED |
94 | | flag is set. */ |
95 | 736 | void *file_shdr = ((char *) elf->map_address |
96 | 736 | + elf->start_offset + ehdr->e_shoff); |
97 | | |
98 | 736 | assert ((elf->flags & ELF_F_MALLOCED) |
99 | 736 | || ehdr->e_ident[EI_DATA] != MY_ELFDATA |
100 | 736 | || elf->cmd == ELF_C_READ_MMAP |
101 | 736 | || (! ALLOW_UNALIGNED |
102 | 736 | && ((uintptr_t) file_shdr |
103 | 736 | & (__alignof__ (ElfW2(LIBELFBITS,Shdr)) - 1)) != 0)); |
104 | | |
105 | | /* Now copy the data and at the same time convert the byte order. */ |
106 | 736 | if (ehdr->e_ident[EI_DATA] == MY_ELFDATA) |
107 | 0 | { |
108 | 0 | assert ((elf->flags & ELF_F_MALLOCED) |
109 | 0 | || elf->cmd == ELF_C_READ_MMAP |
110 | 0 | || ! ALLOW_UNALIGNED); |
111 | 0 | memcpy (shdr, file_shdr, size); |
112 | 0 | } |
113 | 736 | else |
114 | 736 | { |
115 | 736 | bool copy = ! (ALLOW_UNALIGNED |
116 | 736 | || ((uintptr_t) file_shdr |
117 | 0 | & (__alignof__ (ElfW2(LIBELFBITS,Shdr)) - 1)) |
118 | 0 | == 0); |
119 | 736 | if (! copy) |
120 | 736 | notcvt = (ElfW2(LIBELFBITS,Shdr) *) |
121 | 736 | ((char *) elf->map_address |
122 | 736 | + elf->start_offset + ehdr->e_shoff); |
123 | 0 | else |
124 | 0 | { |
125 | 0 | notcvt = (ElfW2(LIBELFBITS,Shdr) *) malloc (size); |
126 | 0 | if (unlikely (notcvt == NULL)) |
127 | 0 | { |
128 | 0 | __libelf_seterrno (ELF_E_NOMEM); |
129 | 0 | goto out; |
130 | 0 | } |
131 | 0 | memcpy (notcvt, ((char *) elf->map_address |
132 | 0 | + elf->start_offset + ehdr->e_shoff), |
133 | 0 | size); |
134 | 0 | } |
135 | | |
136 | 88.0k | for (size_t cnt = 0; cnt < shnum; ++cnt) |
137 | 87.3k | { |
138 | 87.3k | CONVERT_TO (shdr[cnt].sh_name, notcvt[cnt].sh_name); |
139 | 87.3k | CONVERT_TO (shdr[cnt].sh_type, notcvt[cnt].sh_type); |
140 | 87.3k | CONVERT_TO (shdr[cnt].sh_flags, notcvt[cnt].sh_flags); |
141 | 87.3k | CONVERT_TO (shdr[cnt].sh_addr, notcvt[cnt].sh_addr); |
142 | 87.3k | CONVERT_TO (shdr[cnt].sh_offset, notcvt[cnt].sh_offset); |
143 | 87.3k | CONVERT_TO (shdr[cnt].sh_size, notcvt[cnt].sh_size); |
144 | 87.3k | CONVERT_TO (shdr[cnt].sh_link, notcvt[cnt].sh_link); |
145 | 87.3k | CONVERT_TO (shdr[cnt].sh_info, notcvt[cnt].sh_info); |
146 | 87.3k | CONVERT_TO (shdr[cnt].sh_addralign, |
147 | 87.3k | notcvt[cnt].sh_addralign); |
148 | 87.3k | CONVERT_TO (shdr[cnt].sh_entsize, notcvt[cnt].sh_entsize); |
149 | | |
150 | | /* If this is a section with an extended index add a |
151 | | reference in the section which uses the extended |
152 | | index. */ |
153 | 87.3k | if (shdr[cnt].sh_type == SHT_SYMTAB_SHNDX |
154 | 87.3k | && shdr[cnt].sh_link < shnum) |
155 | 3.61k | elf->state.ELFW(elf,LIBELFBITS).scns.data[shdr[cnt].sh_link].shndx_index |
156 | 3.61k | = cnt; |
157 | | |
158 | | /* Set the own shndx_index field in case it has not yet |
159 | | been set. */ |
160 | 87.3k | if (elf->state.ELFW(elf,LIBELFBITS).scns.data[cnt].shndx_index == 0) |
161 | 87.2k | elf->state.ELFW(elf,LIBELFBITS).scns.data[cnt].shndx_index |
162 | 87.2k | = -1; |
163 | 87.3k | } |
164 | | |
165 | 736 | if (copy) |
166 | 0 | free (notcvt); |
167 | 736 | } |
168 | 736 | } |
169 | 0 | else if (likely (elf->fildes != -1)) |
170 | 0 | { |
171 | | /* Read the header. */ |
172 | 0 | ssize_t n = pread_retry (elf->fildes, |
173 | 0 | elf->state.ELFW(elf,LIBELFBITS).shdr, size, |
174 | 0 | elf->start_offset + ehdr->e_shoff); |
175 | 0 | if (unlikely ((size_t) n != size)) |
176 | 0 | { |
177 | | /* Severe problems. We cannot read the data. */ |
178 | 0 | __libelf_seterrno (ELF_E_READ_ERROR); |
179 | 0 | goto free_and_out; |
180 | 0 | } |
181 | | |
182 | | /* If the byte order of the file is not the same as the one |
183 | | of the host convert the data now. */ |
184 | 0 | if (ehdr->e_ident[EI_DATA] != MY_ELFDATA) |
185 | 0 | for (size_t cnt = 0; cnt < shnum; ++cnt) |
186 | 0 | { |
187 | 0 | CONVERT (shdr[cnt].sh_name); |
188 | 0 | CONVERT (shdr[cnt].sh_type); |
189 | 0 | CONVERT (shdr[cnt].sh_flags); |
190 | 0 | CONVERT (shdr[cnt].sh_addr); |
191 | 0 | CONVERT (shdr[cnt].sh_offset); |
192 | 0 | CONVERT (shdr[cnt].sh_size); |
193 | 0 | CONVERT (shdr[cnt].sh_link); |
194 | 0 | CONVERT (shdr[cnt].sh_info); |
195 | 0 | CONVERT (shdr[cnt].sh_addralign); |
196 | 0 | CONVERT (shdr[cnt].sh_entsize); |
197 | 0 | } |
198 | 0 | } |
199 | 0 | else |
200 | 0 | { |
201 | | /* The file descriptor was already enabled and not all data was |
202 | | read. Undo the allocation. */ |
203 | 0 | __libelf_seterrno (ELF_E_FD_DISABLED); |
204 | |
|
205 | 0 | free_and_out: |
206 | 0 | free (shdr); |
207 | 0 | elf->state.ELFW(elf,LIBELFBITS).shdr = NULL; |
208 | 0 | elf->state.ELFW(elf,LIBELFBITS).shdr_malloced = 0; |
209 | |
|
210 | 0 | goto out; |
211 | 0 | } |
212 | | |
213 | | /* Set the pointers in the `scn's. */ |
214 | 88.0k | for (size_t cnt = 0; cnt < shnum; ++cnt) |
215 | 87.3k | elf->state.ELFW(elf,LIBELFBITS).scns.data[cnt].shdr.ELFW(e,LIBELFBITS) |
216 | 87.3k | = &elf->state.ELFW(elf,LIBELFBITS).shdr[cnt]; |
217 | | |
218 | 736 | result = scn->shdr.ELFW(e,LIBELFBITS); |
219 | 736 | assert (result != NULL); |
220 | | |
221 | 736 | out: |
222 | 736 | return result; |
223 | 736 | } elf64_getshdr.c:load_shdr_wrlock Line | Count | Source | 48 | 736 | { | 49 | 736 | ElfW2(LIBELFBITS,Shdr) *result; | 50 | | | 51 | | /* Read the section header table. */ | 52 | 736 | Elf *elf = scn->elf; | 53 | 736 | ElfW2(LIBELFBITS,Ehdr) *ehdr = elf->state.ELFW(elf,LIBELFBITS).ehdr; | 54 | | | 55 | | /* Try again, maybe the data is there now. */ | 56 | 736 | result = scn->shdr.ELFW(e,LIBELFBITS); | 57 | 736 | if (result != NULL) | 58 | 0 | goto out; | 59 | | | 60 | 736 | size_t shnum; | 61 | 736 | if (__elf_getshdrnum_rdlock (elf, &shnum) != 0 | 62 | 736 | || shnum > SIZE_MAX / sizeof (ElfW2(LIBELFBITS,Shdr))) | 63 | 0 | goto out; | 64 | 736 | size_t size = shnum * sizeof (ElfW2(LIBELFBITS,Shdr)); | 65 | | | 66 | | /* Allocate memory for the section headers. We know the number | 67 | | of entries from the ELF header. */ | 68 | 736 | ElfW2(LIBELFBITS,Shdr) *shdr = elf->state.ELFW(elf,LIBELFBITS).shdr = | 69 | 736 | (ElfW2(LIBELFBITS,Shdr) *) malloc (size); | 70 | 736 | if (elf->state.ELFW(elf,LIBELFBITS).shdr == NULL) | 71 | 0 | { | 72 | 0 | __libelf_seterrno (ELF_E_NOMEM); | 73 | 0 | goto out; | 74 | 0 | } | 75 | 736 | elf->state.ELFW(elf,LIBELFBITS).shdr_malloced = 1; | 76 | | | 77 | 736 | if (elf->map_address != NULL) | 78 | 736 | { | 79 | | /* First see whether the information in the ELF header is | 80 | | valid and it does not ask for too much. */ | 81 | 736 | if (unlikely (ehdr->e_shoff >= elf->maximum_size) | 82 | 736 | || unlikely (elf->maximum_size - ehdr->e_shoff < size)) | 83 | 0 | { | 84 | | /* Something is wrong. */ | 85 | 0 | __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER); | 86 | 0 | goto free_and_out; | 87 | 0 | } | 88 | | | 89 | 736 | ElfW2(LIBELFBITS,Shdr) *notcvt; | 90 | | | 91 | | /* All the data is already mapped. If we could use it | 92 | | directly this would already have happened. Unless | 93 | | we allocated the memory ourselves and the ELF_F_MALLOCED | 94 | | flag is set. */ | 95 | 736 | void *file_shdr = ((char *) elf->map_address | 96 | 736 | + elf->start_offset + ehdr->e_shoff); | 97 | | | 98 | 736 | assert ((elf->flags & ELF_F_MALLOCED) | 99 | 736 | || ehdr->e_ident[EI_DATA] != MY_ELFDATA | 100 | 736 | || elf->cmd == ELF_C_READ_MMAP | 101 | 736 | || (! ALLOW_UNALIGNED | 102 | 736 | && ((uintptr_t) file_shdr | 103 | 736 | & (__alignof__ (ElfW2(LIBELFBITS,Shdr)) - 1)) != 0)); | 104 | | | 105 | | /* Now copy the data and at the same time convert the byte order. */ | 106 | 736 | if (ehdr->e_ident[EI_DATA] == MY_ELFDATA) | 107 | 0 | { | 108 | 0 | assert ((elf->flags & ELF_F_MALLOCED) | 109 | 0 | || elf->cmd == ELF_C_READ_MMAP | 110 | 0 | || ! ALLOW_UNALIGNED); | 111 | 0 | memcpy (shdr, file_shdr, size); | 112 | 0 | } | 113 | 736 | else | 114 | 736 | { | 115 | 736 | bool copy = ! (ALLOW_UNALIGNED | 116 | 736 | || ((uintptr_t) file_shdr | 117 | 0 | & (__alignof__ (ElfW2(LIBELFBITS,Shdr)) - 1)) | 118 | 0 | == 0); | 119 | 736 | if (! copy) | 120 | 736 | notcvt = (ElfW2(LIBELFBITS,Shdr) *) | 121 | 736 | ((char *) elf->map_address | 122 | 736 | + elf->start_offset + ehdr->e_shoff); | 123 | 0 | else | 124 | 0 | { | 125 | 0 | notcvt = (ElfW2(LIBELFBITS,Shdr) *) malloc (size); | 126 | 0 | if (unlikely (notcvt == NULL)) | 127 | 0 | { | 128 | 0 | __libelf_seterrno (ELF_E_NOMEM); | 129 | 0 | goto out; | 130 | 0 | } | 131 | 0 | memcpy (notcvt, ((char *) elf->map_address | 132 | 0 | + elf->start_offset + ehdr->e_shoff), | 133 | 0 | size); | 134 | 0 | } | 135 | | | 136 | 88.0k | for (size_t cnt = 0; cnt < shnum; ++cnt) | 137 | 87.3k | { | 138 | 87.3k | CONVERT_TO (shdr[cnt].sh_name, notcvt[cnt].sh_name); | 139 | 87.3k | CONVERT_TO (shdr[cnt].sh_type, notcvt[cnt].sh_type); | 140 | 87.3k | CONVERT_TO (shdr[cnt].sh_flags, notcvt[cnt].sh_flags); | 141 | 87.3k | CONVERT_TO (shdr[cnt].sh_addr, notcvt[cnt].sh_addr); | 142 | 87.3k | CONVERT_TO (shdr[cnt].sh_offset, notcvt[cnt].sh_offset); | 143 | 87.3k | CONVERT_TO (shdr[cnt].sh_size, notcvt[cnt].sh_size); | 144 | 87.3k | CONVERT_TO (shdr[cnt].sh_link, notcvt[cnt].sh_link); | 145 | 87.3k | CONVERT_TO (shdr[cnt].sh_info, notcvt[cnt].sh_info); | 146 | 87.3k | CONVERT_TO (shdr[cnt].sh_addralign, | 147 | 87.3k | notcvt[cnt].sh_addralign); | 148 | 87.3k | CONVERT_TO (shdr[cnt].sh_entsize, notcvt[cnt].sh_entsize); | 149 | | | 150 | | /* If this is a section with an extended index add a | 151 | | reference in the section which uses the extended | 152 | | index. */ | 153 | 87.3k | if (shdr[cnt].sh_type == SHT_SYMTAB_SHNDX | 154 | 87.3k | && shdr[cnt].sh_link < shnum) | 155 | 3.61k | elf->state.ELFW(elf,LIBELFBITS).scns.data[shdr[cnt].sh_link].shndx_index | 156 | 3.61k | = cnt; | 157 | | | 158 | | /* Set the own shndx_index field in case it has not yet | 159 | | been set. */ | 160 | 87.3k | if (elf->state.ELFW(elf,LIBELFBITS).scns.data[cnt].shndx_index == 0) | 161 | 87.2k | elf->state.ELFW(elf,LIBELFBITS).scns.data[cnt].shndx_index | 162 | 87.2k | = -1; | 163 | 87.3k | } | 164 | | | 165 | 736 | if (copy) | 166 | 0 | free (notcvt); | 167 | 736 | } | 168 | 736 | } | 169 | 0 | else if (likely (elf->fildes != -1)) | 170 | 0 | { | 171 | | /* Read the header. */ | 172 | 0 | ssize_t n = pread_retry (elf->fildes, | 173 | 0 | elf->state.ELFW(elf,LIBELFBITS).shdr, size, | 174 | 0 | elf->start_offset + ehdr->e_shoff); | 175 | 0 | if (unlikely ((size_t) n != size)) | 176 | 0 | { | 177 | | /* Severe problems. We cannot read the data. */ | 178 | 0 | __libelf_seterrno (ELF_E_READ_ERROR); | 179 | 0 | goto free_and_out; | 180 | 0 | } | 181 | | | 182 | | /* If the byte order of the file is not the same as the one | 183 | | of the host convert the data now. */ | 184 | 0 | if (ehdr->e_ident[EI_DATA] != MY_ELFDATA) | 185 | 0 | for (size_t cnt = 0; cnt < shnum; ++cnt) | 186 | 0 | { | 187 | 0 | CONVERT (shdr[cnt].sh_name); | 188 | 0 | CONVERT (shdr[cnt].sh_type); | 189 | 0 | CONVERT (shdr[cnt].sh_flags); | 190 | 0 | CONVERT (shdr[cnt].sh_addr); | 191 | 0 | CONVERT (shdr[cnt].sh_offset); | 192 | 0 | CONVERT (shdr[cnt].sh_size); | 193 | 0 | CONVERT (shdr[cnt].sh_link); | 194 | 0 | CONVERT (shdr[cnt].sh_info); | 195 | 0 | CONVERT (shdr[cnt].sh_addralign); | 196 | 0 | CONVERT (shdr[cnt].sh_entsize); | 197 | 0 | } | 198 | 0 | } | 199 | 0 | else | 200 | 0 | { | 201 | | /* The file descriptor was already enabled and not all data was | 202 | | read. Undo the allocation. */ | 203 | 0 | __libelf_seterrno (ELF_E_FD_DISABLED); | 204 | |
| 205 | 0 | free_and_out: | 206 | 0 | free (shdr); | 207 | 0 | elf->state.ELFW(elf,LIBELFBITS).shdr = NULL; | 208 | 0 | elf->state.ELFW(elf,LIBELFBITS).shdr_malloced = 0; | 209 | |
| 210 | 0 | goto out; | 211 | 0 | } | 212 | | | 213 | | /* Set the pointers in the `scn's. */ | 214 | 88.0k | for (size_t cnt = 0; cnt < shnum; ++cnt) | 215 | 87.3k | elf->state.ELFW(elf,LIBELFBITS).scns.data[cnt].shdr.ELFW(e,LIBELFBITS) | 216 | 87.3k | = &elf->state.ELFW(elf,LIBELFBITS).shdr[cnt]; | 217 | | | 218 | 736 | result = scn->shdr.ELFW(e,LIBELFBITS); | 219 | 736 | assert (result != NULL); | 220 | | | 221 | 736 | out: | 222 | 736 | return result; | 223 | 736 | } |
Unexecuted instantiation: elf32_getshdr.c:load_shdr_wrlock |
224 | | |
225 | | static bool |
226 | | scn_valid (Elf_Scn *scn) |
227 | 208k | { |
228 | 208k | if (scn == NULL) |
229 | 0 | return false; |
230 | | |
231 | 208k | if (unlikely (scn->elf->state.elf.ehdr == NULL)) |
232 | 0 | { |
233 | 0 | __libelf_seterrno (ELF_E_WRONG_ORDER_EHDR); |
234 | 0 | return false; |
235 | 0 | } |
236 | | |
237 | 208k | if (unlikely (scn->elf->class != ELFW(ELFCLASS,LIBELFBITS))) |
238 | 0 | { |
239 | 0 | __libelf_seterrno (ELF_E_INVALID_CLASS); |
240 | 0 | return false; |
241 | 0 | } |
242 | | |
243 | 208k | return true; |
244 | 208k | } elf64_getshdr.c:scn_valid Line | Count | Source | 227 | 208k | { | 228 | 208k | if (scn == NULL) | 229 | 0 | return false; | 230 | | | 231 | 208k | if (unlikely (scn->elf->state.elf.ehdr == NULL)) | 232 | 0 | { | 233 | 0 | __libelf_seterrno (ELF_E_WRONG_ORDER_EHDR); | 234 | 0 | return false; | 235 | 0 | } | 236 | | | 237 | 208k | if (unlikely (scn->elf->class != ELFW(ELFCLASS,LIBELFBITS))) | 238 | 0 | { | 239 | 0 | __libelf_seterrno (ELF_E_INVALID_CLASS); | 240 | 0 | return false; | 241 | 0 | } | 242 | | | 243 | 208k | return true; | 244 | 208k | } |
Unexecuted instantiation: elf32_getshdr.c:scn_valid |
245 | | |
246 | | ElfW2(LIBELFBITS,Shdr) * |
247 | | internal_function |
248 | | __elfw2(LIBELFBITS,getshdr_rdlock) (Elf_Scn *scn) |
249 | 103k | { |
250 | 103k | ElfW2(LIBELFBITS,Shdr) *result; |
251 | | |
252 | 103k | if (!scn_valid (scn)) |
253 | 0 | return NULL; |
254 | | |
255 | 103k | result = scn->shdr.ELFW(e,LIBELFBITS); |
256 | 103k | if (result == NULL) |
257 | 0 | { |
258 | 0 | rwlock_unlock (scn->elf->lock); |
259 | 0 | rwlock_wrlock (scn->elf->lock); |
260 | 0 | result = scn->shdr.ELFW(e,LIBELFBITS); |
261 | 0 | if (result == NULL) |
262 | 0 | result = load_shdr_wrlock (scn); |
263 | 0 | } |
264 | | |
265 | 103k | return result; |
266 | 103k | } Line | Count | Source | 249 | 103k | { | 250 | 103k | ElfW2(LIBELFBITS,Shdr) *result; | 251 | | | 252 | 103k | if (!scn_valid (scn)) | 253 | 0 | return NULL; | 254 | | | 255 | 103k | result = scn->shdr.ELFW(e,LIBELFBITS); | 256 | 103k | if (result == NULL) | 257 | 0 | { | 258 | 0 | rwlock_unlock (scn->elf->lock); | 259 | 0 | rwlock_wrlock (scn->elf->lock); | 260 | 0 | result = scn->shdr.ELFW(e,LIBELFBITS); | 261 | 0 | if (result == NULL) | 262 | 0 | result = load_shdr_wrlock (scn); | 263 | 0 | } | 264 | | | 265 | 103k | return result; | 266 | 103k | } |
Unexecuted instantiation: __elf32_getshdr_rdlock |
267 | | |
268 | | ElfW2(LIBELFBITS,Shdr) * |
269 | | internal_function |
270 | | __elfw2(LIBELFBITS,getshdr_wrlock) (Elf_Scn *scn) |
271 | 736 | { |
272 | 736 | ElfW2(LIBELFBITS,Shdr) *result; |
273 | | |
274 | 736 | if (!scn_valid (scn)) |
275 | 0 | return NULL; |
276 | | |
277 | 736 | result = scn->shdr.ELFW(e,LIBELFBITS); |
278 | 736 | if (result == NULL) |
279 | 736 | result = load_shdr_wrlock (scn); |
280 | | |
281 | 736 | return result; |
282 | 736 | } Line | Count | Source | 271 | 736 | { | 272 | 736 | ElfW2(LIBELFBITS,Shdr) *result; | 273 | | | 274 | 736 | if (!scn_valid (scn)) | 275 | 0 | return NULL; | 276 | | | 277 | 736 | result = scn->shdr.ELFW(e,LIBELFBITS); | 278 | 736 | if (result == NULL) | 279 | 736 | result = load_shdr_wrlock (scn); | 280 | | | 281 | 736 | return result; | 282 | 736 | } |
Unexecuted instantiation: __elf32_getshdr_wrlock |
283 | | |
284 | | ElfW2(LIBELFBITS,Shdr) * |
285 | | elfw2(LIBELFBITS,getshdr) (Elf_Scn *scn) |
286 | 103k | { |
287 | 103k | ElfW2(LIBELFBITS,Shdr) *result; |
288 | | |
289 | 103k | if (!scn_valid (scn)) |
290 | 0 | return NULL; |
291 | | |
292 | 103k | rwlock_rdlock (scn->elf->lock); |
293 | 103k | result = __elfw2(LIBELFBITS,getshdr_rdlock) (scn); |
294 | 103k | rwlock_unlock (scn->elf->lock); |
295 | | |
296 | 103k | return result; |
297 | 103k | } Line | Count | Source | 286 | 103k | { | 287 | 103k | ElfW2(LIBELFBITS,Shdr) *result; | 288 | | | 289 | 103k | if (!scn_valid (scn)) | 290 | 0 | return NULL; | 291 | | | 292 | 103k | rwlock_rdlock (scn->elf->lock); | 293 | 103k | result = __elfw2(LIBELFBITS,getshdr_rdlock) (scn); | 294 | 103k | rwlock_unlock (scn->elf->lock); | 295 | | | 296 | 103k | return result; | 297 | 103k | } |
Unexecuted instantiation: elf32_getshdr |