Lines 29-41
Link Here
|
29 |
#include <libelf.h> |
29 |
#include <libelf.h> |
30 |
#include <stdint.h> |
30 |
#include <stdint.h> |
31 |
#include <stdlib.h> |
31 |
#include <stdlib.h> |
|
|
32 |
#include <stdbool.h> |
32 |
|
33 |
|
33 |
#include "_libelf.h" |
34 |
#include "_libelf.h" |
34 |
|
35 |
|
35 |
ELFTC_VCSID("$Id: elf_data.c 3466 2016-05-11 18:35:44Z emaste $"); |
36 |
ELFTC_VCSID("$Id: elf_data.c 3466 2016-05-11 18:35:44Z emaste $"); |
36 |
|
37 |
|
37 |
Elf_Data * |
38 |
Elf_Data * |
38 |
elf_getdata(Elf_Scn *s, Elf_Data *ed) |
39 |
_libelf_getdata(Elf_Scn *s, Elf_Data *ed, bool updating) |
39 |
{ |
40 |
{ |
40 |
Elf *e; |
41 |
Elf *e; |
41 |
unsigned int sh_type; |
42 |
unsigned int sh_type; |
Lines 94-100
elf_getdata(Elf_Scn *s, Elf_Data *ed)
Link Here
|
94 |
|
95 |
|
95 |
if ((elftype = _libelf_xlate_shtype(sh_type)) < ELF_T_FIRST || |
96 |
if ((elftype = _libelf_xlate_shtype(sh_type)) < ELF_T_FIRST || |
96 |
elftype > ELF_T_LAST || (sh_type != SHT_NOBITS && |
97 |
elftype > ELF_T_LAST || (sh_type != SHT_NOBITS && |
97 |
(sh_offset > e->e_rawsize || sh_size > e->e_rawsize - sh_offset))) { |
98 |
(!updating && |
|
|
99 |
(sh_offset > e->e_rawsize || |
100 |
sh_size > e->e_rawsize - sh_offset)))) { |
98 |
LIBELF_SET_ERROR(SECTION, 0); |
101 |
LIBELF_SET_ERROR(SECTION, 0); |
99 |
return (NULL); |
102 |
return (NULL); |
100 |
} |
103 |
} |
Lines 166-171
elf_getdata(Elf_Scn *s, Elf_Data *ed)
Link Here
|
166 |
} |
169 |
} |
167 |
|
170 |
|
168 |
Elf_Data * |
171 |
Elf_Data * |
|
|
172 |
elf_getdata(Elf_Scn *s, Elf_Data *ed) |
173 |
{ |
174 |
return (_libelf_getdata(s, ed, false)); |
175 |
} |
176 |
|
177 |
Elf_Data * |
169 |
elf_newdata(Elf_Scn *s) |
178 |
elf_newdata(Elf_Scn *s) |
170 |
{ |
179 |
{ |
171 |
Elf *e; |
180 |
Elf *e; |
Lines 209-215
elf_newdata(Elf_Scn *s)
Link Here
|
209 |
*/ |
218 |
*/ |
210 |
|
219 |
|
211 |
Elf_Data * |
220 |
Elf_Data * |
212 |
elf_rawdata(Elf_Scn *s, Elf_Data *ed) |
221 |
_libelf_rawdata(Elf_Scn *s, Elf_Data *ed, bool updating) |
213 |
{ |
222 |
{ |
214 |
Elf *e; |
223 |
Elf *e; |
215 |
int elf_class; |
224 |
int elf_class; |
Lines 254-260
elf_rawdata(Elf_Scn *s, Elf_Data *ed)
Link Here
|
254 |
} |
263 |
} |
255 |
|
264 |
|
256 |
if (sh_type != SHT_NOBITS && |
265 |
if (sh_type != SHT_NOBITS && |
257 |
(sh_offset > e->e_rawsize || sh_size > e->e_rawsize - sh_offset)) { |
266 |
(!updating && |
|
|
267 |
(sh_offset > e->e_rawsize || |
268 |
sh_size > e->e_rawsize - sh_offset))) { |
258 |
LIBELF_SET_ERROR(SECTION, 0); |
269 |
LIBELF_SET_ERROR(SECTION, 0); |
259 |
return (NULL); |
270 |
return (NULL); |
260 |
} |
271 |
} |
Lines 274-276
elf_rawdata(Elf_Scn *s, Elf_Data *ed)
Link Here
|
274 |
|
285 |
|
275 |
return (&d->d_data); |
286 |
return (&d->d_data); |
276 |
} |
287 |
} |
|
|
288 |
|
289 |
Elf_Data * |
290 |
elf_rawdata(Elf_Scn *s, Elf_Data *ed) |
291 |
{ |
292 |
return (_libelf_rawdata(s, ed, false)); |
293 |
} |