Skip to content

Commit 09f30d8

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
objtool: Handle function aliases
Function aliases result in different symbols for the same set of instructions; track a canonical symbol so there is a unique point of access. This again prepares the way for function attributes. And in particular the need for aliases comes from how KASAN uses them. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent a4d09dd commit 09f30d8

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

tools/objtool/elf.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ static int read_sections(struct elf *elf)
219219
static int read_symbols(struct elf *elf)
220220
{
221221
struct section *symtab, *sec;
222-
struct symbol *sym, *pfunc;
222+
struct symbol *sym, *pfunc, *alias;
223223
struct list_head *entry, *tmp;
224224
int symbols_nr, i;
225225
char *coldstr;
@@ -239,6 +239,7 @@ static int read_symbols(struct elf *elf)
239239
return -1;
240240
}
241241
memset(sym, 0, sizeof(*sym));
242+
alias = sym;
242243

243244
sym->idx = i;
244245

@@ -288,11 +289,17 @@ static int read_symbols(struct elf *elf)
288289
break;
289290
}
290291

291-
if (sym->offset == s->offset && sym->len >= s->len) {
292-
entry = tmp;
293-
break;
292+
if (sym->offset == s->offset) {
293+
if (sym->len == s->len && alias == sym)
294+
alias = s;
295+
296+
if (sym->len >= s->len) {
297+
entry = tmp;
298+
break;
299+
}
294300
}
295301
}
302+
sym->alias = alias;
296303
list_add(&sym->list, entry);
297304
hash_add(sym->sec->symbol_hash, &sym->hash, sym->idx);
298305
}

tools/objtool/elf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ struct symbol {
6161
unsigned char bind, type;
6262
unsigned long offset;
6363
unsigned int len;
64-
struct symbol *pfunc, *cfunc;
64+
struct symbol *pfunc, *cfunc, *alias;
6565
};
6666

6767
struct rela {

0 commit comments

Comments
 (0)