Skip to content

Commit a196e17

Browse files
jpoimboeIngo Molnar
authored andcommitted
objtool: Rename some variables and functions
Rename some list heads to distinguish them from hash node heads, which are added later in the patch series. Also rename the get_*() functions to add_*(), which is more descriptive: they "add" data to the objtool_file struct. Also rename rodata_rela and text_rela to be clearer: - text_rela refers to a rela entry in .rela.text. - rodata_rela refers to a rela entry in .rela.rodata. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Andy Lutomirski <luto@kernel.org> Cc: Arnaldo Carvalho de Melo <acme@infradead.org> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Bernd Petrovitsch <bernd@petrovitsch.priv.at> Cc: Borislav Petkov <bp@alien8.de> Cc: Chris J Arges <chris.j.arges@canonical.com> Cc: Jiri Slaby <jslaby@suse.cz> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Michal Marek <mmarek@suse.cz> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Pedro Alves <palves@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: live-patching@vger.kernel.org Link: http://lkml.kernel.org/r/ee0eca2bba8482aa45758958c5586c00a7b71e62.1457502970.git.jpoimboe@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent e2a5f18 commit a196e17

File tree

3 files changed

+54
-52
lines changed

3 files changed

+54
-52
lines changed

tools/objtool/builtin-check.c

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct alternative {
6060

6161
struct objtool_file {
6262
struct elf *elf;
63-
struct list_head insns;
63+
struct list_head insn_list;
6464
};
6565

6666
const char *objname;
@@ -71,7 +71,7 @@ static struct instruction *find_insn(struct objtool_file *file,
7171
{
7272
struct instruction *insn;
7373

74-
list_for_each_entry(insn, &file->insns, list)
74+
list_for_each_entry(insn, &file->insn_list, list)
7575
if (insn->sec == sec && insn->offset == offset)
7676
return insn;
7777

@@ -83,18 +83,18 @@ static struct instruction *next_insn_same_sec(struct objtool_file *file,
8383
{
8484
struct instruction *next = list_next_entry(insn, list);
8585

86-
if (&next->list == &file->insns || next->sec != insn->sec)
86+
if (&next->list == &file->insn_list || next->sec != insn->sec)
8787
return NULL;
8888

8989
return next;
9090
}
9191

9292
#define for_each_insn(file, insn) \
93-
list_for_each_entry(insn, &file->insns, list)
93+
list_for_each_entry(insn, &file->insn_list, list)
9494

9595
#define func_for_each_insn(file, func, insn) \
9696
for (insn = find_insn(file, func->sec, func->offset); \
97-
insn && &insn->list != &file->insns && \
97+
insn && &insn->list != &file->insn_list && \
9898
insn->sec == func->sec && \
9999
insn->offset < func->offset + func->len; \
100100
insn = list_next_entry(insn, list))
@@ -117,7 +117,7 @@ static bool ignore_func(struct objtool_file *file, struct symbol *func)
117117
/* check for STACK_FRAME_NON_STANDARD */
118118
macro_sec = find_section_by_name(file->elf, "__func_stack_frame_non_standard");
119119
if (macro_sec && macro_sec->rela)
120-
list_for_each_entry(rela, &macro_sec->rela->relas, list)
120+
list_for_each_entry(rela, &macro_sec->rela->rela_list, list)
121121
if (rela->sym->sec == func->sec &&
122122
rela->addend == func->offset)
123123
return true;
@@ -240,7 +240,7 @@ static int dead_end_function(struct objtool_file *file, struct symbol *func)
240240

241241
/*
242242
* Call the arch-specific instruction decoder for all the instructions and add
243-
* them to the global insns list.
243+
* them to the global instruction list.
244244
*/
245245
static int decode_instructions(struct objtool_file *file)
246246
{
@@ -275,7 +275,7 @@ static int decode_instructions(struct objtool_file *file)
275275
return -1;
276276
}
277277

278-
list_add_tail(&insn->list, &file->insns);
278+
list_add_tail(&insn->list, &file->insn_list);
279279
}
280280
}
281281

@@ -285,14 +285,14 @@ static int decode_instructions(struct objtool_file *file)
285285
/*
286286
* Warnings shouldn't be reported for ignored functions.
287287
*/
288-
static void get_ignores(struct objtool_file *file)
288+
static void add_ignores(struct objtool_file *file)
289289
{
290290
struct instruction *insn;
291291
struct section *sec;
292292
struct symbol *func;
293293

294294
list_for_each_entry(sec, &file->elf->sections, list) {
295-
list_for_each_entry(func, &sec->symbols, list) {
295+
list_for_each_entry(func, &sec->symbol_list, list) {
296296
if (func->type != STT_FUNC)
297297
continue;
298298

@@ -308,7 +308,7 @@ static void get_ignores(struct objtool_file *file)
308308
/*
309309
* Find the destination instructions for all jumps.
310310
*/
311-
static int get_jump_destinations(struct objtool_file *file)
311+
static int add_jump_destinations(struct objtool_file *file)
312312
{
313313
struct instruction *insn;
314314
struct rela *rela;
@@ -365,7 +365,7 @@ static int get_jump_destinations(struct objtool_file *file)
365365
/*
366366
* Find the destination instructions for all calls.
367367
*/
368-
static int get_call_destinations(struct objtool_file *file)
368+
static int add_call_destinations(struct objtool_file *file)
369369
{
370370
struct instruction *insn;
371371
unsigned long dest_off;
@@ -534,7 +534,7 @@ static int handle_jump_alt(struct objtool_file *file,
534534
* instruction(s) has them added to its insn->alts list, which will be
535535
* traversed in validate_branch().
536536
*/
537-
static int get_special_section_alts(struct objtool_file *file)
537+
static int add_special_section_alts(struct objtool_file *file)
538538
{
539539
struct list_head special_alts;
540540
struct instruction *orig_insn, *new_insn;
@@ -604,10 +604,10 @@ static int get_special_section_alts(struct objtool_file *file)
604604
* section which contains a list of addresses within the function to jump to.
605605
* This finds these jump tables and adds them to the insn->alts lists.
606606
*/
607-
static int get_switch_alts(struct objtool_file *file)
607+
static int add_switch_table_alts(struct objtool_file *file)
608608
{
609609
struct instruction *insn, *alt_insn;
610-
struct rela *rodata_rela, *rela;
610+
struct rela *rodata_rela, *text_rela;
611611
struct section *rodata;
612612
struct symbol *func;
613613
struct alternative *alt;
@@ -616,23 +616,23 @@ static int get_switch_alts(struct objtool_file *file)
616616
if (insn->type != INSN_JUMP_DYNAMIC)
617617
continue;
618618

619-
rodata_rela = find_rela_by_dest_range(insn->sec, insn->offset,
620-
insn->len);
621-
if (!rodata_rela || strcmp(rodata_rela->sym->name, ".rodata"))
619+
text_rela = find_rela_by_dest_range(insn->sec, insn->offset,
620+
insn->len);
621+
if (!text_rela || strcmp(text_rela->sym->name, ".rodata"))
622622
continue;
623623

624624
rodata = find_section_by_name(file->elf, ".rodata");
625625
if (!rodata || !rodata->rela)
626626
continue;
627627

628628
/* common case: jmpq *[addr](,%rax,8) */
629-
rela = find_rela_by_dest(rodata, rodata_rela->addend);
629+
rodata_rela = find_rela_by_dest(rodata, text_rela->addend);
630630

631631
/* rare case: jmpq *[addr](%rip) */
632-
if (!rela)
633-
rela = find_rela_by_dest(rodata,
634-
rodata_rela->addend + 4);
635-
if (!rela)
632+
if (!rodata_rela)
633+
rodata_rela = find_rela_by_dest(rodata,
634+
text_rela->addend + 4);
635+
if (!rodata_rela)
636636
continue;
637637

638638
func = find_containing_func(insn->sec, insn->offset);
@@ -642,17 +642,19 @@ static int get_switch_alts(struct objtool_file *file)
642642
return -1;
643643
}
644644

645-
list_for_each_entry_from(rela, &rodata->rela->relas, list) {
646-
if (rela->sym->sec != insn->sec ||
647-
rela->addend <= func->offset ||
648-
rela->addend >= func->offset + func->len)
645+
list_for_each_entry_from(rodata_rela, &rodata->rela->rela_list,
646+
list) {
647+
if (rodata_rela->sym->sec != insn->sec ||
648+
rodata_rela->addend <= func->offset ||
649+
rodata_rela->addend >= func->offset + func->len)
649650
break;
650651

651-
alt_insn = find_insn(file, insn->sec, rela->addend);
652+
alt_insn = find_insn(file, insn->sec,
653+
rodata_rela->addend);
652654
if (!alt_insn) {
653655
WARN("%s: can't find instruction at %s+0x%x",
654656
rodata->rela->name, insn->sec->name,
655-
rela->addend);
657+
rodata_rela->addend);
656658
return -1;
657659
}
658660

@@ -678,21 +680,21 @@ static int decode_sections(struct objtool_file *file)
678680
if (ret)
679681
return ret;
680682

681-
get_ignores(file);
683+
add_ignores(file);
682684

683-
ret = get_jump_destinations(file);
685+
ret = add_jump_destinations(file);
684686
if (ret)
685687
return ret;
686688

687-
ret = get_call_destinations(file);
689+
ret = add_call_destinations(file);
688690
if (ret)
689691
return ret;
690692

691-
ret = get_special_section_alts(file);
693+
ret = add_special_section_alts(file);
692694
if (ret)
693695
return ret;
694696

695-
ret = get_switch_alts(file);
697+
ret = add_switch_table_alts(file);
696698
if (ret)
697699
return ret;
698700

@@ -901,7 +903,7 @@ static bool is_gcov_insn(struct instruction *insn)
901903
sec = rela->sym->sec;
902904
offset = rela->addend + insn->offset + insn->len - rela->offset;
903905

904-
list_for_each_entry(sym, &sec->symbols, list) {
906+
list_for_each_entry(sym, &sec->symbol_list, list) {
905907
if (sym->type != STT_OBJECT)
906908
continue;
907909

@@ -968,7 +970,7 @@ static int validate_functions(struct objtool_file *file)
968970
int ret, warnings = 0;
969971

970972
list_for_each_entry(sec, &file->elf->sections, list) {
971-
list_for_each_entry(func, &sec->symbols, list) {
973+
list_for_each_entry(func, &sec->symbol_list, list) {
972974
if (func->type != STT_FUNC)
973975
continue;
974976

@@ -986,7 +988,7 @@ static int validate_functions(struct objtool_file *file)
986988
}
987989

988990
list_for_each_entry(sec, &file->elf->sections, list) {
989-
list_for_each_entry(func, &sec->symbols, list) {
991+
list_for_each_entry(func, &sec->symbol_list, list) {
990992
if (func->type != STT_FUNC)
991993
continue;
992994

@@ -1028,7 +1030,7 @@ static void cleanup(struct objtool_file *file)
10281030
struct instruction *insn, *tmpinsn;
10291031
struct alternative *alt, *tmpalt;
10301032

1031-
list_for_each_entry_safe(insn, tmpinsn, &file->insns, list) {
1033+
list_for_each_entry_safe(insn, tmpinsn, &file->insn_list, list) {
10321034
list_for_each_entry_safe(alt, tmpalt, &insn->alts, list) {
10331035
list_del(&alt->list);
10341036
free(alt);
@@ -1067,7 +1069,7 @@ int cmd_check(int argc, const char **argv)
10671069
return 1;
10681070
}
10691071

1070-
INIT_LIST_HEAD(&file.insns);
1072+
INIT_LIST_HEAD(&file.insn_list);
10711073

10721074
ret = decode_sections(&file);
10731075
if (ret < 0)

tools/objtool/elf.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static struct symbol *find_symbol_by_index(struct elf *elf, unsigned int idx)
5959
struct symbol *sym;
6060

6161
list_for_each_entry(sec, &elf->sections, list)
62-
list_for_each_entry(sym, &sec->symbols, list)
62+
list_for_each_entry(sym, &sec->symbol_list, list)
6363
if (sym->idx == idx)
6464
return sym;
6565

@@ -70,7 +70,7 @@ struct symbol *find_symbol_by_offset(struct section *sec, unsigned long offset)
7070
{
7171
struct symbol *sym;
7272

73-
list_for_each_entry(sym, &sec->symbols, list)
73+
list_for_each_entry(sym, &sec->symbol_list, list)
7474
if (sym->type != STT_SECTION &&
7575
sym->offset == offset)
7676
return sym;
@@ -86,7 +86,7 @@ struct rela *find_rela_by_dest_range(struct section *sec, unsigned long offset,
8686
if (!sec->rela)
8787
return NULL;
8888

89-
list_for_each_entry(rela, &sec->rela->relas, list)
89+
list_for_each_entry(rela, &sec->rela->rela_list, list)
9090
if (rela->offset >= offset && rela->offset < offset + len)
9191
return rela;
9292

@@ -102,7 +102,7 @@ struct symbol *find_containing_func(struct section *sec, unsigned long offset)
102102
{
103103
struct symbol *func;
104104

105-
list_for_each_entry(func, &sec->symbols, list)
105+
list_for_each_entry(func, &sec->symbol_list, list)
106106
if (func->type == STT_FUNC && offset >= func->offset &&
107107
offset < func->offset + func->len)
108108
return func;
@@ -135,8 +135,8 @@ static int read_sections(struct elf *elf)
135135
}
136136
memset(sec, 0, sizeof(*sec));
137137

138-
INIT_LIST_HEAD(&sec->symbols);
139-
INIT_LIST_HEAD(&sec->relas);
138+
INIT_LIST_HEAD(&sec->symbol_list);
139+
INIT_LIST_HEAD(&sec->rela_list);
140140

141141
list_add_tail(&sec->list, &elf->sections);
142142

@@ -244,8 +244,8 @@ static int read_symbols(struct elf *elf)
244244
sym->len = sym->sym.st_size;
245245

246246
/* sorted insert into a per-section list */
247-
entry = &sym->sec->symbols;
248-
list_for_each_prev(tmp, &sym->sec->symbols) {
247+
entry = &sym->sec->symbol_list;
248+
list_for_each_prev(tmp, &sym->sec->symbol_list) {
249249
struct symbol *s;
250250

251251
s = list_entry(tmp, struct symbol, list);
@@ -298,7 +298,7 @@ static int read_relas(struct elf *elf)
298298
}
299299
memset(rela, 0, sizeof(*rela));
300300

301-
list_add_tail(&rela->list, &sec->relas);
301+
list_add_tail(&rela->list, &sec->rela_list);
302302

303303
if (!gelf_getrela(sec->elf_data, i, &rela->rela)) {
304304
perror("gelf_getrela");
@@ -382,11 +382,11 @@ void elf_close(struct elf *elf)
382382
struct rela *rela, *tmprela;
383383

384384
list_for_each_entry_safe(sec, tmpsec, &elf->sections, list) {
385-
list_for_each_entry_safe(sym, tmpsym, &sec->symbols, list) {
385+
list_for_each_entry_safe(sym, tmpsym, &sec->symbol_list, list) {
386386
list_del(&sym->list);
387387
free(sym);
388388
}
389-
list_for_each_entry_safe(rela, tmprela, &sec->relas, list) {
389+
list_for_each_entry_safe(rela, tmprela, &sec->rela_list, list) {
390390
list_del(&rela->list);
391391
free(rela);
392392
}

tools/objtool/elf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
struct section {
2626
struct list_head list;
2727
GElf_Shdr sh;
28-
struct list_head symbols;
29-
struct list_head relas;
28+
struct list_head symbol_list;
29+
struct list_head rela_list;
3030
struct section *base, *rela;
3131
struct symbol *sym;
3232
Elf_Data *elf_data;

0 commit comments

Comments
 (0)