FreeBSD Bugzilla – Attachment 182066 Details for
Bug 218861
libelf elf_update fails when adding sections
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to fix the problem
libelf_getdata.diff (text/plain), 3.37 KB, created by
Eric McCorkle
on 2017-04-24 23:20:27 UTC
(
hide
)
Description:
Patch to fix the problem
Filename:
MIME Type:
Creator:
Eric McCorkle
Created:
2017-04-24 23:20:27 UTC
Size:
3.37 KB
patch
obsolete
>diff --git a/contrib/elftoolchain/libelf/_libelf.h b/contrib/elftoolchain/libelf/_libelf.h >index be45335907f..b9c110d0296 100644 >--- a/contrib/elftoolchain/libelf/_libelf.h >+++ b/contrib/elftoolchain/libelf/_libelf.h >@@ -29,6 +29,8 @@ > #ifndef __LIBELF_H_ > #define __LIBELF_H_ > >+#include <stdbool.h> >+ > #include <sys/queue.h> > > #include "_libelf_config.h" >@@ -229,6 +231,8 @@ int _libelf_setphnum(Elf *_e, void *_eh, int _elfclass, size_t _phnum); > int _libelf_setshnum(Elf *_e, void *_eh, int _elfclass, size_t _shnum); > int _libelf_setshstrndx(Elf *_e, void *_eh, int _elfclass, > size_t _shstrndx); >+Elf_Data * _libelf_getdata(Elf_Scn *s, Elf_Data *ed, bool updating); >+Elf_Data * _libelf_rawdata(Elf_Scn *s, Elf_Data *ed, bool updating); > Elf_Data *_libelf_xlate(Elf_Data *_d, const Elf_Data *_s, > unsigned int _encoding, int _elfclass, int _direction); > int _libelf_xlate_shtype(uint32_t _sht); >diff --git a/contrib/elftoolchain/libelf/elf_data.c b/contrib/elftoolchain/libelf/elf_data.c >index d494eda2de3..3428d8f3e48 100644 >--- a/contrib/elftoolchain/libelf/elf_data.c >+++ b/contrib/elftoolchain/libelf/elf_data.c >@@ -29,13 +29,14 @@ > #include <libelf.h> > #include <stdint.h> > #include <stdlib.h> >+#include <stdbool.h> > > #include "_libelf.h" > > ELFTC_VCSID("$Id: elf_data.c 3466 2016-05-11 18:35:44Z emaste $"); > > Elf_Data * >-elf_getdata(Elf_Scn *s, Elf_Data *ed) >+_libelf_getdata(Elf_Scn *s, Elf_Data *ed, bool updating) > { > Elf *e; > unsigned int sh_type; >@@ -94,7 +95,9 @@ elf_getdata(Elf_Scn *s, Elf_Data *ed) > > if ((elftype = _libelf_xlate_shtype(sh_type)) < ELF_T_FIRST || > elftype > ELF_T_LAST || (sh_type != SHT_NOBITS && >- (sh_offset > e->e_rawsize || sh_size > e->e_rawsize - sh_offset))) { >+ (!updating && >+ (sh_offset > e->e_rawsize || >+ sh_size > e->e_rawsize - sh_offset)))) { > LIBELF_SET_ERROR(SECTION, 0); > return (NULL); > } >@@ -166,6 +169,12 @@ elf_getdata(Elf_Scn *s, Elf_Data *ed) > } > > Elf_Data * >+elf_getdata(Elf_Scn *s, Elf_Data *ed) >+{ >+ return (_libelf_getdata(s, ed, false)); >+} >+ >+Elf_Data * > elf_newdata(Elf_Scn *s) > { > Elf *e; >@@ -209,7 +218,7 @@ elf_newdata(Elf_Scn *s) > */ > > Elf_Data * >-elf_rawdata(Elf_Scn *s, Elf_Data *ed) >+_libelf_rawdata(Elf_Scn *s, Elf_Data *ed, bool updating) > { > Elf *e; > int elf_class; >@@ -254,7 +263,9 @@ elf_rawdata(Elf_Scn *s, Elf_Data *ed) > } > > if (sh_type != SHT_NOBITS && >- (sh_offset > e->e_rawsize || sh_size > e->e_rawsize - sh_offset)) { >+ (!updating && >+ (sh_offset > e->e_rawsize || >+ sh_size > e->e_rawsize - sh_offset))) { > LIBELF_SET_ERROR(SECTION, 0); > return (NULL); > } >@@ -274,3 +285,9 @@ elf_rawdata(Elf_Scn *s, Elf_Data *ed) > > return (&d->d_data); > } >+ >+Elf_Data * >+elf_rawdata(Elf_Scn *s, Elf_Data *ed) >+{ >+ return (_libelf_rawdata(s, ed, false)); >+} >diff --git a/contrib/elftoolchain/libelf/elf_update.c b/contrib/elftoolchain/libelf/elf_update.c >index 6cc109daafc..1a0032bd8b0 100644 >--- a/contrib/elftoolchain/libelf/elf_update.c >+++ b/contrib/elftoolchain/libelf/elf_update.c >@@ -182,7 +182,8 @@ _libelf_compute_section_extents(Elf *e, Elf_Scn *s, off_t rc) > * Otherwise, we need to bring in the section's data > * from the underlying ELF object. > */ >- if (e->e_cmd != ELF_C_WRITE && elf_getdata(s, NULL) == NULL) >+ if (e->e_cmd != ELF_C_WRITE && >+ _libelf_getdata(s, NULL, true) == NULL) > return (0); > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 218861
: 182066