[RFC][PATCH v5 47/51] objtool: mcount: Merge section mcount flags

From: Matt Helsley
Date: Thu Jun 18 2020 - 16:40:49 EST


One flag is only for relocation sections and the other only
for text (not relocation) sections so we can share the same
flag and test the section type when we need to.

Signed-off-by: Matt Helsley <mhelsley@xxxxxxxxxx>
---
tools/objtool/elf.c | 5 ++---
tools/objtool/elf.h | 2 +-
tools/objtool/mcount.c | 9 ++++++---
3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index 3708f85fe36d..12bd889a62ba 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -384,8 +384,7 @@ static int read_sections(struct elf *elf)
}
sec->len = sec->sh.sh_size;

- sec->mcounted = is_mcounted_section_name(sec->name);
- sec->relocs_mcountable = false;
+ sec->mcountable = is_mcounted_section_name(sec->name);

list_add_tail(&sec->list, &elf->sections);
elf_hash_add(elf->section_hash, &sec->hash, sec->idx);
@@ -642,7 +641,7 @@ static int read_relocs(struct elf *elf)
}

sec->base->reloc = sec;
- sec->relocs_mcountable = relocs_mcountable(sec);
+ sec->mcountable = relocs_mcountable(sec);

nr_reloc = 0;
for (i = 0; i < sec->sh.sh_size / sec->sh.sh_entsize; i++) {
diff --git a/tools/objtool/elf.h b/tools/objtool/elf.h
index 92d3e68abf59..fb10f470d1a4 100644
--- a/tools/objtool/elf.h
+++ b/tools/objtool/elf.h
@@ -39,7 +39,7 @@ struct section {
char *name;
int idx;
unsigned int len;
- bool changed, text, rodata, noinstr, mcounted, relocs_mcountable;
+ bool changed, text, rodata, noinstr, mcountable;
};

enum symbol_class {
diff --git a/tools/objtool/mcount.c b/tools/objtool/mcount.c
index 9cd52beed871..80daf0e17eab 100644
--- a/tools/objtool/mcount.c
+++ b/tools/objtool/mcount.c
@@ -279,7 +279,10 @@ static void tot_relsize(unsigned int *rel_entsize)
const struct section *sec;

list_for_each_entry(sec, &lf->sections, list) {
- if (sec->relocs_mcountable)
+ if (sec->sh.sh_type != SHT_REL &&
+ sec->sh.sh_type != SHT_RELA)
+ continue;
+ if (sec->mcountable)
*rel_entsize = sec->sh.sh_entsize;
}
}
@@ -419,13 +422,13 @@ static int do_mcount(unsigned const reltype, size_t rela_size)
sec->sh.sh_type != SHT_RELA)
continue;
/* Which may relocate mcount calls.. */
- if (!sec->relocs_mcountable)
+ if (!sec->mcountable)
continue;
txts = sec->base;
if (!txts)
continue;

- if (txts->mcounted) {
+ if (txts->mcountable) {
/* In mcountable text sections */
unsigned long recval = 0;
unsigned int recsym;
--
2.20.1