struct objtool_file {
struct elf *elf;
- struct list_head insns;
+ struct list_head insn_list;
};
const char *objname;
{
struct instruction *insn;
- list_for_each_entry(insn, &file->insns, list)
+ list_for_each_entry(insn, &file->insn_list, list)
if (insn->sec == sec && insn->offset == offset)
return insn;
{
struct instruction *next = list_next_entry(insn, list);
- if (&next->list == &file->insns || next->sec != insn->sec)
+ if (&next->list == &file->insn_list || next->sec != insn->sec)
return NULL;
return next;
}
#define for_each_insn(file, insn) \
- list_for_each_entry(insn, &file->insns, list)
+ list_for_each_entry(insn, &file->insn_list, list)
#define func_for_each_insn(file, func, insn) \
for (insn = find_insn(file, func->sec, func->offset); \
- insn && &insn->list != &file->insns && \
+ insn && &insn->list != &file->insn_list && \
insn->sec == func->sec && \
insn->offset < func->offset + func->len; \
insn = list_next_entry(insn, list))
/* check for STACK_FRAME_NON_STANDARD */
macro_sec = find_section_by_name(file->elf, "__func_stack_frame_non_standard");
if (macro_sec && macro_sec->rela)
- list_for_each_entry(rela, ¯o_sec->rela->relas, list)
+ list_for_each_entry(rela, ¯o_sec->rela->rela_list, list)
if (rela->sym->sec == func->sec &&
rela->addend == func->offset)
return true;
/*
* Call the arch-specific instruction decoder for all the instructions and add
- * them to the global insns list.
+ * them to the global instruction list.
*/
static int decode_instructions(struct objtool_file *file)
{
return -1;
}
- list_add_tail(&insn->list, &file->insns);
+ list_add_tail(&insn->list, &file->insn_list);
}
}
/*
* Warnings shouldn't be reported for ignored functions.
*/
-static void get_ignores(struct objtool_file *file)
+static void add_ignores(struct objtool_file *file)
{
struct instruction *insn;
struct section *sec;
struct symbol *func;
list_for_each_entry(sec, &file->elf->sections, list) {
- list_for_each_entry(func, &sec->symbols, list) {
+ list_for_each_entry(func, &sec->symbol_list, list) {
if (func->type != STT_FUNC)
continue;
/*
* Find the destination instructions for all jumps.
*/
-static int get_jump_destinations(struct objtool_file *file)
+static int add_jump_destinations(struct objtool_file *file)
{
struct instruction *insn;
struct rela *rela;
/*
* Find the destination instructions for all calls.
*/
-static int get_call_destinations(struct objtool_file *file)
+static int add_call_destinations(struct objtool_file *file)
{
struct instruction *insn;
unsigned long dest_off;
* instruction(s) has them added to its insn->alts list, which will be
* traversed in validate_branch().
*/
-static int get_special_section_alts(struct objtool_file *file)
+static int add_special_section_alts(struct objtool_file *file)
{
struct list_head special_alts;
struct instruction *orig_insn, *new_insn;
* section which contains a list of addresses within the function to jump to.
* This finds these jump tables and adds them to the insn->alts lists.
*/
-static int get_switch_alts(struct objtool_file *file)
+static int add_switch_table_alts(struct objtool_file *file)
{
struct instruction *insn, *alt_insn;
- struct rela *rodata_rela, *rela;
+ struct rela *rodata_rela, *text_rela;
struct section *rodata;
struct symbol *func;
struct alternative *alt;
if (insn->type != INSN_JUMP_DYNAMIC)
continue;
- rodata_rela = find_rela_by_dest_range(insn->sec, insn->offset,
- insn->len);
- if (!rodata_rela || strcmp(rodata_rela->sym->name, ".rodata"))
+ text_rela = find_rela_by_dest_range(insn->sec, insn->offset,
+ insn->len);
+ if (!text_rela || strcmp(text_rela->sym->name, ".rodata"))
continue;
rodata = find_section_by_name(file->elf, ".rodata");
continue;
/* common case: jmpq *[addr](,%rax,8) */
- rela = find_rela_by_dest(rodata, rodata_rela->addend);
+ rodata_rela = find_rela_by_dest(rodata, text_rela->addend);
/* rare case: jmpq *[addr](%rip) */
- if (!rela)
- rela = find_rela_by_dest(rodata,
- rodata_rela->addend + 4);
- if (!rela)
+ if (!rodata_rela)
+ rodata_rela = find_rela_by_dest(rodata,
+ text_rela->addend + 4);
+ if (!rodata_rela)
continue;
func = find_containing_func(insn->sec, insn->offset);
return -1;
}
- list_for_each_entry_from(rela, &rodata->rela->relas, list) {
- if (rela->sym->sec != insn->sec ||
- rela->addend <= func->offset ||
- rela->addend >= func->offset + func->len)
+ list_for_each_entry_from(rodata_rela, &rodata->rela->rela_list,
+ list) {
+ if (rodata_rela->sym->sec != insn->sec ||
+ rodata_rela->addend <= func->offset ||
+ rodata_rela->addend >= func->offset + func->len)
break;
- alt_insn = find_insn(file, insn->sec, rela->addend);
+ alt_insn = find_insn(file, insn->sec,
+ rodata_rela->addend);
if (!alt_insn) {
WARN("%s: can't find instruction at %s+0x%x",
rodata->rela->name, insn->sec->name,
- rela->addend);
+ rodata_rela->addend);
return -1;
}
if (ret)
return ret;
- get_ignores(file);
+ add_ignores(file);
- ret = get_jump_destinations(file);
+ ret = add_jump_destinations(file);
if (ret)
return ret;
- ret = get_call_destinations(file);
+ ret = add_call_destinations(file);
if (ret)
return ret;
- ret = get_special_section_alts(file);
+ ret = add_special_section_alts(file);
if (ret)
return ret;
- ret = get_switch_alts(file);
+ ret = add_switch_table_alts(file);
if (ret)
return ret;
sec = rela->sym->sec;
offset = rela->addend + insn->offset + insn->len - rela->offset;
- list_for_each_entry(sym, &sec->symbols, list) {
+ list_for_each_entry(sym, &sec->symbol_list, list) {
if (sym->type != STT_OBJECT)
continue;
int ret, warnings = 0;
list_for_each_entry(sec, &file->elf->sections, list) {
- list_for_each_entry(func, &sec->symbols, list) {
+ list_for_each_entry(func, &sec->symbol_list, list) {
if (func->type != STT_FUNC)
continue;
}
list_for_each_entry(sec, &file->elf->sections, list) {
- list_for_each_entry(func, &sec->symbols, list) {
+ list_for_each_entry(func, &sec->symbol_list, list) {
if (func->type != STT_FUNC)
continue;
struct instruction *insn, *tmpinsn;
struct alternative *alt, *tmpalt;
- list_for_each_entry_safe(insn, tmpinsn, &file->insns, list) {
+ list_for_each_entry_safe(insn, tmpinsn, &file->insn_list, list) {
list_for_each_entry_safe(alt, tmpalt, &insn->alts, list) {
list_del(&alt->list);
free(alt);
return 1;
}
- INIT_LIST_HEAD(&file.insns);
+ INIT_LIST_HEAD(&file.insn_list);
ret = decode_sections(&file);
if (ret < 0)
struct symbol *sym;
list_for_each_entry(sec, &elf->sections, list)
- list_for_each_entry(sym, &sec->symbols, list)
+ list_for_each_entry(sym, &sec->symbol_list, list)
if (sym->idx == idx)
return sym;
{
struct symbol *sym;
- list_for_each_entry(sym, &sec->symbols, list)
+ list_for_each_entry(sym, &sec->symbol_list, list)
if (sym->type != STT_SECTION &&
sym->offset == offset)
return sym;
if (!sec->rela)
return NULL;
- list_for_each_entry(rela, &sec->rela->relas, list)
+ list_for_each_entry(rela, &sec->rela->rela_list, list)
if (rela->offset >= offset && rela->offset < offset + len)
return rela;
{
struct symbol *func;
- list_for_each_entry(func, &sec->symbols, list)
+ list_for_each_entry(func, &sec->symbol_list, list)
if (func->type == STT_FUNC && offset >= func->offset &&
offset < func->offset + func->len)
return func;
}
memset(sec, 0, sizeof(*sec));
- INIT_LIST_HEAD(&sec->symbols);
- INIT_LIST_HEAD(&sec->relas);
+ INIT_LIST_HEAD(&sec->symbol_list);
+ INIT_LIST_HEAD(&sec->rela_list);
list_add_tail(&sec->list, &elf->sections);
sym->len = sym->sym.st_size;
/* sorted insert into a per-section list */
- entry = &sym->sec->symbols;
- list_for_each_prev(tmp, &sym->sec->symbols) {
+ entry = &sym->sec->symbol_list;
+ list_for_each_prev(tmp, &sym->sec->symbol_list) {
struct symbol *s;
s = list_entry(tmp, struct symbol, list);
}
memset(rela, 0, sizeof(*rela));
- list_add_tail(&rela->list, &sec->relas);
+ list_add_tail(&rela->list, &sec->rela_list);
if (!gelf_getrela(sec->elf_data, i, &rela->rela)) {
perror("gelf_getrela");
struct rela *rela, *tmprela;
list_for_each_entry_safe(sec, tmpsec, &elf->sections, list) {
- list_for_each_entry_safe(sym, tmpsym, &sec->symbols, list) {
+ list_for_each_entry_safe(sym, tmpsym, &sec->symbol_list, list) {
list_del(&sym->list);
free(sym);
}
- list_for_each_entry_safe(rela, tmprela, &sec->relas, list) {
+ list_for_each_entry_safe(rela, tmprela, &sec->rela_list, list) {
list_del(&rela->list);
free(rela);
}