Merge tag 'mm-stable-2024-05-17-19-19' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-block.git] / scripts / kallsyms.c
index 653b92f6d4c8f49f9824f8ddd943c36bf53ede23..47978efe4797c2e90ce179596108836ee0e9b4b7 100644 (file)
@@ -204,6 +204,11 @@ static int symbol_in_range(const struct sym_entry *s,
        return 0;
 }
 
+static bool string_starts_with(const char *s, const char *prefix)
+{
+       return strncmp(s, prefix, strlen(prefix)) == 0;
+}
+
 static int symbol_valid(const struct sym_entry *s)
 {
        const char *name = sym_name(s);
@@ -211,6 +216,14 @@ static int symbol_valid(const struct sym_entry *s)
        /* if --all-symbols is not specified, then symbols outside the text
         * and inittext sections are discarded */
        if (!all_symbols) {
+               /*
+                * Symbols starting with __start and __stop are used to denote
+                * section boundaries, and should always be included:
+                */
+               if (string_starts_with(name, "__start_") ||
+                   string_starts_with(name, "__stop_"))
+                       return 1;
+
                if (symbol_in_range(s, text_ranges,
                                    ARRAY_SIZE(text_ranges)) == 0)
                        return 0;