Commit cd063c8b authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'objtool-core-2023-10-28' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull objtool updates from Ingo Molnar:
 "Misc fixes and cleanups:

   - Fix potential MAX_NAME_LEN limit related build failures

   - Fix scripts/faddr2line symbol filtering bug

   - Fix scripts/faddr2line on LLVM=1

   - Fix scripts/faddr2line to accept readelf output with mapping
     symbols

   - Minor cleanups"

* tag 'objtool-core-2023-10-28' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  scripts/faddr2line: Skip over mapping symbols in output from readelf
  scripts/faddr2line: Use LLVM addr2line and readelf if LLVM=1
  scripts/faddr2line: Don't filter out non-function symbols from readelf
  objtool: Remove max symbol name length limitation
  objtool: Propagate early errors
  objtool: Use 'the fallthrough' pseudo-keyword
  x86/speculation, objtool: Use absolute relocations for annotations
  x86/unwind/orc: Remove redundant initialization of 'mid' pointer in __orc_find()
parents 63ce50ff 60fd39af
......@@ -58,7 +58,7 @@
#define ANNOTATE_IGNORE_ALTERNATIVE \
"999:\n\t" \
".pushsection .discard.ignore_alts\n\t" \
".long 999b - .\n\t" \
".long 999b\n\t" \
".popsection\n\t"
/*
......@@ -352,7 +352,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
.macro ANNOTATE_IGNORE_ALTERNATIVE
.Lannotate_\@:
.pushsection .discard.ignore_alts
.long .Lannotate_\@ - .
.long .Lannotate_\@
.popsection
.endm
......
......@@ -196,7 +196,7 @@
.macro ANNOTATE_RETPOLINE_SAFE
.Lhere_\@:
.pushsection .discard.retpoline_safe
.long .Lhere_\@ - .
.long .Lhere_\@
.popsection
.endm
......@@ -320,7 +320,7 @@
#define ANNOTATE_RETPOLINE_SAFE \
"999:\n\t" \
".pushsection .discard.retpoline_safe\n\t" \
".long 999b - .\n\t" \
".long 999b\n\t" \
".popsection\n\t"
typedef u8 retpoline_thunk_t[RETPOLINE_THUNK_SIZE];
......
......@@ -85,7 +85,7 @@ static struct orc_entry *__orc_find(int *ip_table, struct orc_entry *u_table,
{
int *first = ip_table;
int *last = ip_table + num_entries - 1;
int *mid = first, *found = first;
int *mid, *found = first;
if (!num_entries)
return NULL;
......
......@@ -48,13 +48,13 @@
#define ANNOTATE_NOENDBR \
"986: \n\t" \
".pushsection .discard.noendbr\n\t" \
".long 986b - .\n\t" \
".long 986b\n\t" \
".popsection\n\t"
#define ASM_REACHABLE \
"998:\n\t" \
".pushsection .discard.reachable\n\t" \
".long 998b - .\n\t" \
".long 998b\n\t" \
".popsection\n\t"
#else /* __ASSEMBLY__ */
......@@ -66,7 +66,7 @@
#define ANNOTATE_INTRA_FUNCTION_CALL \
999: \
.pushsection .discard.intra_function_calls; \
.long 999b - .; \
.long 999b; \
.popsection;
/*
......@@ -118,7 +118,7 @@
.macro ANNOTATE_NOENDBR
.Lhere_\@:
.pushsection .discard.noendbr
.long .Lhere_\@ - .
.long .Lhere_\@
.popsection
.endm
......@@ -142,7 +142,7 @@
.macro REACHABLE
.Lhere_\@:
.pushsection .discard.reachable
.long .Lhere_\@ - .
.long .Lhere_\@
.popsection
.endm
......
......@@ -58,8 +58,21 @@ die() {
exit 1
}
READELF="${CROSS_COMPILE:-}readelf"
ADDR2LINE="${CROSS_COMPILE:-}addr2line"
UTIL_SUFFIX=""
if [[ "${LLVM:-}" == "" ]]; then
UTIL_PREFIX=${CROSS_COMPILE:-}
else
UTIL_PREFIX=llvm-
if [[ "${LLVM}" == *"/" ]]; then
UTIL_PREFIX=${LLVM}${UTIL_PREFIX}
elif [[ "${LLVM}" == "-"* ]]; then
UTIL_SUFFIX=${LLVM}
fi
fi
READELF="${UTIL_PREFIX}readelf${UTIL_SUFFIX}"
ADDR2LINE="${UTIL_PREFIX}addr2line${UTIL_SUFFIX}"
AWK="awk"
GREP="grep"
......@@ -166,6 +179,11 @@ __faddr2line() {
local cur_sym_elf_size=${fields[2]}
local cur_sym_name=${fields[7]:-}
# is_mapping_symbol(cur_sym_name)
if [[ ${cur_sym_name} =~ ^(\.L|L0|\$) ]]; then
continue
fi
if [[ $cur_sym_addr = $sym_addr ]] &&
[[ $cur_sym_elf_size = $sym_elf_size ]] &&
[[ $cur_sym_name = $sym_name ]]; then
......@@ -260,7 +278,7 @@ __faddr2line() {
DONE=1
done < <(${READELF} --symbols --wide $objfile | sed 's/\[.*\]//' | ${AWK} -v fn=$sym_name '$4 == "FUNC" && $8 == fn')
done < <(${READELF} --symbols --wide $objfile | sed 's/\[.*\]//' | ${AWK} -v fn=$sym_name '$8 == fn')
}
[[ $# -lt 2 ]] && usage
......
......@@ -291,7 +291,7 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
switch (modrm_reg & 7) {
case 5:
imm = -imm;
/* fallthrough */
fallthrough;
case 0:
/* add/sub imm, %rsp */
ADD_OP(op) {
......@@ -375,7 +375,7 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
break;
}
/* fallthrough */
fallthrough;
case 0x88:
if (!rex_w)
break;
......@@ -656,7 +656,7 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
break;
}
/* fallthrough */
fallthrough;
case 0xca: /* retf */
case 0xcb: /* retf */
......
......@@ -22,8 +22,6 @@
#include <objtool/elf.h>
#include <objtool/warn.h>
#define MAX_NAME_LEN 128
static inline u32 str_hash(const char *str)
{
return jhash(str, strlen(str), 0);
......@@ -515,7 +513,7 @@ static int read_symbols(struct elf *elf)
/* Create parent/child links for any cold subfunctions */
list_for_each_entry(sec, &elf->sections, list) {
sec_for_each_sym(sec, sym) {
char pname[MAX_NAME_LEN + 1];
char *pname;
size_t pnamelen;
if (sym->type != STT_FUNC)
continue;
......@@ -531,15 +529,15 @@ static int read_symbols(struct elf *elf)
continue;
pnamelen = coldstr - sym->name;
if (pnamelen > MAX_NAME_LEN) {
WARN("%s(): parent function name exceeds maximum length of %d characters",
sym->name, MAX_NAME_LEN);
pname = strndup(sym->name, pnamelen);
if (!pname) {
WARN("%s(): failed to allocate memory",
sym->name);
return -1;
}
strncpy(pname, sym->name, pnamelen);
pname[pnamelen] = '\0';
pfunc = find_symbol_by_name(elf, pname);
free(pname);
if (!pfunc) {
WARN("%s(): can't find parent function",
......
......@@ -146,7 +146,5 @@ int main(int argc, const char **argv)
exec_cmd_init("objtool", UNUSED, UNUSED, UNUSED);
pager_init(UNUSED);
objtool_run(argc, argv);
return 0;
return objtool_run(argc, argv);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment