Skip to content

Commit cd063c8

Browse files
committed
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()
2 parents 63ce50f + 60fd39a commit cd063c8

File tree

8 files changed

+41
-27
lines changed

8 files changed

+41
-27
lines changed

arch/x86/include/asm/alternative.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
#define ANNOTATE_IGNORE_ALTERNATIVE \
5959
"999:\n\t" \
6060
".pushsection .discard.ignore_alts\n\t" \
61-
".long 999b - .\n\t" \
61+
".long 999b\n\t" \
6262
".popsection\n\t"
6363

6464
/*
@@ -352,7 +352,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
352352
.macro ANNOTATE_IGNORE_ALTERNATIVE
353353
.Lannotate_\@:
354354
.pushsection .discard.ignore_alts
355-
.long .Lannotate_\@ - .
355+
.long .Lannotate_\@
356356
.popsection
357357
.endm
358358

arch/x86/include/asm/nospec-branch.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@
196196
.macro ANNOTATE_RETPOLINE_SAFE
197197
.Lhere_\@:
198198
.pushsection .discard.retpoline_safe
199-
.long .Lhere_\@ - .
199+
.long .Lhere_\@
200200
.popsection
201201
.endm
202202

@@ -320,7 +320,7 @@
320320
#define ANNOTATE_RETPOLINE_SAFE \
321321
"999:\n\t" \
322322
".pushsection .discard.retpoline_safe\n\t" \
323-
".long 999b - .\n\t" \
323+
".long 999b\n\t" \
324324
".popsection\n\t"
325325

326326
typedef u8 retpoline_thunk_t[RETPOLINE_THUNK_SIZE];

arch/x86/kernel/unwind_orc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static struct orc_entry *__orc_find(int *ip_table, struct orc_entry *u_table,
8585
{
8686
int *first = ip_table;
8787
int *last = ip_table + num_entries - 1;
88-
int *mid = first, *found = first;
88+
int *mid, *found = first;
8989

9090
if (!num_entries)
9191
return NULL;

include/linux/objtool.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@
4848
#define ANNOTATE_NOENDBR \
4949
"986: \n\t" \
5050
".pushsection .discard.noendbr\n\t" \
51-
".long 986b - .\n\t" \
51+
".long 986b\n\t" \
5252
".popsection\n\t"
5353

5454
#define ASM_REACHABLE \
5555
"998:\n\t" \
5656
".pushsection .discard.reachable\n\t" \
57-
".long 998b - .\n\t" \
57+
".long 998b\n\t" \
5858
".popsection\n\t"
5959

6060
#else /* __ASSEMBLY__ */
@@ -66,7 +66,7 @@
6666
#define ANNOTATE_INTRA_FUNCTION_CALL \
6767
999: \
6868
.pushsection .discard.intra_function_calls; \
69-
.long 999b - .; \
69+
.long 999b; \
7070
.popsection;
7171

7272
/*
@@ -118,7 +118,7 @@
118118
.macro ANNOTATE_NOENDBR
119119
.Lhere_\@:
120120
.pushsection .discard.noendbr
121-
.long .Lhere_\@ - .
121+
.long .Lhere_\@
122122
.popsection
123123
.endm
124124

@@ -142,7 +142,7 @@
142142
.macro REACHABLE
143143
.Lhere_\@:
144144
.pushsection .discard.reachable
145-
.long .Lhere_\@ - .
145+
.long .Lhere_\@
146146
.popsection
147147
.endm
148148

scripts/faddr2line

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,21 @@ die() {
5858
exit 1
5959
}
6060

61-
READELF="${CROSS_COMPILE:-}readelf"
62-
ADDR2LINE="${CROSS_COMPILE:-}addr2line"
61+
UTIL_SUFFIX=""
62+
if [[ "${LLVM:-}" == "" ]]; then
63+
UTIL_PREFIX=${CROSS_COMPILE:-}
64+
else
65+
UTIL_PREFIX=llvm-
66+
67+
if [[ "${LLVM}" == *"/" ]]; then
68+
UTIL_PREFIX=${LLVM}${UTIL_PREFIX}
69+
elif [[ "${LLVM}" == "-"* ]]; then
70+
UTIL_SUFFIX=${LLVM}
71+
fi
72+
fi
73+
74+
READELF="${UTIL_PREFIX}readelf${UTIL_SUFFIX}"
75+
ADDR2LINE="${UTIL_PREFIX}addr2line${UTIL_SUFFIX}"
6376
AWK="awk"
6477
GREP="grep"
6578

@@ -166,6 +179,11 @@ __faddr2line() {
166179
local cur_sym_elf_size=${fields[2]}
167180
local cur_sym_name=${fields[7]:-}
168181

182+
# is_mapping_symbol(cur_sym_name)
183+
if [[ ${cur_sym_name} =~ ^(\.L|L0|\$) ]]; then
184+
continue
185+
fi
186+
169187
if [[ $cur_sym_addr = $sym_addr ]] &&
170188
[[ $cur_sym_elf_size = $sym_elf_size ]] &&
171189
[[ $cur_sym_name = $sym_name ]]; then
@@ -260,7 +278,7 @@ __faddr2line() {
260278

261279
DONE=1
262280

263-
done < <(${READELF} --symbols --wide $objfile | sed 's/\[.*\]//' | ${AWK} -v fn=$sym_name '$4 == "FUNC" && $8 == fn')
281+
done < <(${READELF} --symbols --wide $objfile | sed 's/\[.*\]//' | ${AWK} -v fn=$sym_name '$8 == fn')
264282
}
265283

266284
[[ $# -lt 2 ]] && usage

tools/objtool/arch/x86/decode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
291291
switch (modrm_reg & 7) {
292292
case 5:
293293
imm = -imm;
294-
/* fallthrough */
294+
fallthrough;
295295
case 0:
296296
/* add/sub imm, %rsp */
297297
ADD_OP(op) {
@@ -375,7 +375,7 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
375375
break;
376376
}
377377

378-
/* fallthrough */
378+
fallthrough;
379379
case 0x88:
380380
if (!rex_w)
381381
break;
@@ -656,7 +656,7 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
656656
break;
657657
}
658658

659-
/* fallthrough */
659+
fallthrough;
660660

661661
case 0xca: /* retf */
662662
case 0xcb: /* retf */

tools/objtool/elf.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#include <objtool/elf.h>
2323
#include <objtool/warn.h>
2424

25-
#define MAX_NAME_LEN 128
26-
2725
static inline u32 str_hash(const char *str)
2826
{
2927
return jhash(str, strlen(str), 0);
@@ -515,7 +513,7 @@ static int read_symbols(struct elf *elf)
515513
/* Create parent/child links for any cold subfunctions */
516514
list_for_each_entry(sec, &elf->sections, list) {
517515
sec_for_each_sym(sec, sym) {
518-
char pname[MAX_NAME_LEN + 1];
516+
char *pname;
519517
size_t pnamelen;
520518
if (sym->type != STT_FUNC)
521519
continue;
@@ -531,15 +529,15 @@ static int read_symbols(struct elf *elf)
531529
continue;
532530

533531
pnamelen = coldstr - sym->name;
534-
if (pnamelen > MAX_NAME_LEN) {
535-
WARN("%s(): parent function name exceeds maximum length of %d characters",
536-
sym->name, MAX_NAME_LEN);
532+
pname = strndup(sym->name, pnamelen);
533+
if (!pname) {
534+
WARN("%s(): failed to allocate memory",
535+
sym->name);
537536
return -1;
538537
}
539538

540-
strncpy(pname, sym->name, pnamelen);
541-
pname[pnamelen] = '\0';
542539
pfunc = find_symbol_by_name(elf, pname);
540+
free(pname);
543541

544542
if (!pfunc) {
545543
WARN("%s(): can't find parent function",

tools/objtool/objtool.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,5 @@ int main(int argc, const char **argv)
146146
exec_cmd_init("objtool", UNUSED, UNUSED, UNUSED);
147147
pager_init(UNUSED);
148148

149-
objtool_run(argc, argv);
150-
151-
return 0;
149+
return objtool_run(argc, argv);
152150
}

0 commit comments

Comments
 (0)