View | Details | Raw Unified | Return to bug 218861
Collapse All | Expand All

(-)b/contrib/elftoolchain/libelf/_libelf.h (+4 lines)
Lines 29-34 Link Here
29
#ifndef	__LIBELF_H_
29
#ifndef	__LIBELF_H_
30
#define	__LIBELF_H_
30
#define	__LIBELF_H_
31
31
32
#include <stdbool.h>
33
32
#include <sys/queue.h>
34
#include <sys/queue.h>
33
35
34
#include "_libelf_config.h"
36
#include "_libelf_config.h"
Lines 229-234 int _libelf_setphnum(Elf *_e, void *_eh, int _elfclass, size_t _phnum); Link Here
229
int	_libelf_setshnum(Elf *_e, void *_eh, int _elfclass, size_t _shnum);
231
int	_libelf_setshnum(Elf *_e, void *_eh, int _elfclass, size_t _shnum);
230
int	_libelf_setshstrndx(Elf *_e, void *_eh, int _elfclass,
232
int	_libelf_setshstrndx(Elf *_e, void *_eh, int _elfclass,
231
    size_t _shstrndx);
233
    size_t _shstrndx);
234
Elf_Data * _libelf_getdata(Elf_Scn *s, Elf_Data *ed, bool updating);
235
Elf_Data * _libelf_rawdata(Elf_Scn *s, Elf_Data *ed, bool updating);
232
Elf_Data *_libelf_xlate(Elf_Data *_d, const Elf_Data *_s,
236
Elf_Data *_libelf_xlate(Elf_Data *_d, const Elf_Data *_s,
233
    unsigned int _encoding, int _elfclass, int _direction);
237
    unsigned int _encoding, int _elfclass, int _direction);
234
int	_libelf_xlate_shtype(uint32_t _sht);
238
int	_libelf_xlate_shtype(uint32_t _sht);
(-)b/contrib/elftoolchain/libelf/elf_data.c (-4 / +21 lines)
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
}
(-)b/contrib/elftoolchain/libelf/elf_update.c (-1 / +2 lines)
Lines 182-188 _libelf_compute_section_extents(Elf *e, Elf_Scn *s, off_t rc) Link Here
182
		 * Otherwise, we need to bring in the section's data
182
		 * Otherwise, we need to bring in the section's data
183
		 * from the underlying ELF object.
183
		 * from the underlying ELF object.
184
		 */
184
		 */
185
		if (e->e_cmd != ELF_C_WRITE && elf_getdata(s, NULL) == NULL)
185
		if (e->e_cmd != ELF_C_WRITE &&
186
                    _libelf_getdata(s, NULL, true) == NULL)
186
			return (0);
187
			return (0);
187
	}
188
	}
188
189

Return to bug 218861