Messages in this thread Patch in this message | | | From | Matt Helsley <> | Subject | [RFC][PATCH 21/36] objtool: mcount: Restrict using ehdr in append_func() | Date | Fri, 10 Apr 2020 12:35:44 -0700 |
| |
To use as a pointer to an ehdr to modify. Extract the read-only bits from objtool's GElf_Ehdr.
Signed-off-by: Matt Helsley <mhelsley@vmware.com> --- tools/objtool/recordmcount.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/objtool/recordmcount.h b/tools/objtool/recordmcount.h index 3c7afb9a2eac..3c98c379f472 100644 --- a/tools/objtool/recordmcount.h +++ b/tools/objtool/recordmcount.h @@ -99,8 +99,8 @@ static int append_func(Elf_Ehdr *const ehdr, char const *mc_name = (sizeof(Elf_Rela) == rel_entsize) ? ".rela__mcount_loc" : ".rel__mcount_loc"; - unsigned const old_shnum = w2(ehdr->e_shnum); - uint_t const old_shoff = _w(ehdr->e_shoff); + unsigned const old_shnum = lf->ehdr.e_shnum; + uint_t const old_shoff = lf->ehdr.e_shoff; uint_t const old_shstr_sh_size = _w(shstr->sh_size); uint_t const old_shstr_sh_offset = _w(shstr->sh_offset); uint_t t = 1 + strlen(mc_name) + _w(shstr->sh_size); @@ -167,7 +167,7 @@ static int append_func(Elf_Ehdr *const ehdr, return -1; ehdr->e_shoff = _w(new_e_shoff); - ehdr->e_shnum = w2(2 + w2(ehdr->e_shnum)); /* {.rel,}__mcount_loc */ + ehdr->e_shnum = w2(2 + lf->ehdr.e_shnum); /* {.rel,}__mcount_loc */ if (ulseek(0, SEEK_SET) < 0) return -1; if (uwrite(ehdr, sizeof(*ehdr)) < 0) -- 2.20.1
| |