[PATCH v3 9/9] objtool/klp: Fix line numbers in Module.symvers parse errors

From: Josh Poimboeuf

Date: Fri Aug 07 2026 - 17:42:19 EST


read_exports() reports the offending line number when it fails to parse
Module.symvers. The counter is initialized to 1 but never incremented,
so every error blames line 1 regardless of where the bad line is.

Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
---
tools/objtool/klp-diff.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/objtool/klp-diff.c b/tools/objtool/klp-diff.c
index 0f135b74a5b0c..b6b72ed71bf02 100644
--- a/tools/objtool/klp-diff.c
+++ b/tools/objtool/klp-diff.c
@@ -118,7 +118,7 @@ static int read_exports(void)
{
const char *symvers = "Module.symvers";
char line[1024], *path = NULL;
- unsigned int line_num = 1;
+ unsigned int line_num = 0;
FILE *file;

file = fopen(symvers, "r");
@@ -140,6 +140,8 @@ static int read_exports(void)
char *sym, *mod, *type, *namespace;
struct export *export;

+ line_num++;
+
sym = strchr(line, '\t');
if (!sym) {
ERROR("malformed Module.symvers (sym) at line %d", line_num);
--
2.54.0