Skip to contentSkip to conversation

kallsyms: also special-case symbols aliasing _sinittext

PATCH New Jan Beulich 1 participant 1 message Sep 7 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kallsyms: also special-case symbols aliasing _sinittext

In the Xen project, where we use a clone of kallsyms, we encountered the (rare) situation of trailing symbols immediately ahead of _sinittext moving between passes 1 and 2 in a way that in just one of the two passes they would actually alias _sinittext. The same can clearly happen to Linux.

To consistently discard such symbols on all passes, extend the existing "corner case" by also considering aliases with _sinittext (_stext really shouldn't have anything ahead of it). But discard only non-text symbols there, to avoid discarding true aliases, and assuming that what comes immediately ahead is (typically r/o) data.

---
I'm also a little puzzled by the verification done: The extra linking pass is engaged if the sizes of the two earlier objects aren't the same. The sizes, however, can be the same even if there are changes. Later System.map is also compared against the last pass'es .syms, yet both are first passed through mksysmap filtering, which removes far more symbols than kallsyms does. Hence no difference there again doesn't necessarily mean the symbol table hasn't changed.

scripts/kallsyms.c +5 -0
@@ -222,6 +222,11 @@ static int symbol_valid(const struct sym
 		    (s->addr == text_range_inittext->end &&
 		     strcmp(name, text_range_inittext->end_sym)))
 			return 0;
+		/* Same for non-text aliases of _sinittext. */
+		if (toupper(s->sym[0]) != 'T'
+		    && s->addr == text_range_inittext->start
+		    && strcmp(name, text_range_inittext->start_sym))
+			return 0;
 	}
 
 	return 1;