Messages in this thread Patch in this message | | | Date | Fri, 01 May 2020 22:29:07 +0200 | From | Peter Zijlstra <> | Subject | [PATCH v4 18/18] objtool: Clean up elf_write() condition |
| |
With there being multiple ways to change the ELF data, let's more concisely track modification.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> --- tools/objtool/check.c | 2 +- tools/objtool/elf.c | 8 +++++++- tools/objtool/elf.h | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-)
--- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -2904,7 +2904,7 @@ int check(const char *_objname, bool orc goto out; } - if (orc || !list_empty(&file.static_call_list)) { + if (file.elf->changed) { ret = elf_write(file.elf); if (ret < 0) goto out; --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -703,6 +703,8 @@ struct section *elf_create_section(struc elf_hash_add(elf->section_hash, &sec->hash, sec->idx); elf_hash_add(elf->section_name_hash, &sec->name_hash, str_hash(sec->name)); + elf->changed = true; + return sec; } @@ -769,7 +771,7 @@ int elf_rebuild_rela_section(struct sect return 0; } -int elf_write(const struct elf *elf) +int elf_write(struct elf *elf) { struct section *sec; Elf_Scn *s; @@ -786,6 +788,8 @@ int elf_write(const struct elf *elf) WARN_ELF("gelf_update_shdr"); return -1; } + + sec->changed = false; } } @@ -798,6 +802,8 @@ int elf_write(const struct elf *elf) return -1; } + elf->changed = false; + return 0; } --- a/tools/objtool/elf.h +++ b/tools/objtool/elf.h @@ -77,6 +77,7 @@ struct elf { Elf *elf; GElf_Ehdr ehdr; int fd; + bool changed; char *name; struct list_head sections; DECLARE_HASHTABLE(symbol_hash, ELF_HASH_BITS); @@ -118,7 +119,7 @@ struct elf *elf_open_read(const char *na struct section *elf_create_section(struct elf *elf, const char *name, unsigned int sh_flags, size_t entsize, int nr); struct section *elf_create_rela_section(struct elf *elf, struct section *base); void elf_add_rela(struct elf *elf, struct rela *rela); -int elf_write(const struct elf *elf); +int elf_write(struct elf *elf); void elf_close(struct elf *elf); struct section *find_section_by_name(const struct elf *elf, const char *name);
| |