--- zzzz-none-000/linux-4.4.271/scripts/kallsyms.c 2021-06-03 06:22:09.000000000 +0000 +++ hawkeye-5590-750/linux-4.4.271/scripts/kallsyms.c 2023-04-19 10:22:30.000000000 +0000 @@ -22,6 +22,35 @@ #include #include #include +#ifdef __APPLE__ +/* Darwin has no memmem implementation, this one is ripped of the uClibc-0.9.28 source */ +void *memmem (const void *haystack, size_t haystack_len, + const void *needle, size_t needle_len) +{ + const char *begin; + const char *const last_possible + = (const char *) haystack + haystack_len - needle_len; + + if (needle_len == 0) + /* The first occurrence of the empty string is deemed to occur at + the beginning of the string. */ + return (void *) haystack; + + /* Sanity check, otherwise the loop might search through the whole + memory. */ + if (__builtin_expect (haystack_len < needle_len, 0)) + return NULL; + + for (begin = (const char *) haystack; begin <= last_possible; ++begin) + if (begin[0] == ((const char *) needle)[0] && + !memcmp ((const void *) &begin[1], + (const void *) ((const char *) needle + 1), + needle_len - 1)) + return (void *) begin; + + return NULL; +} +#endif #ifndef ARRAY_SIZE #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) @@ -58,6 +87,7 @@ static struct sym_entry *table; static unsigned int table_size, table_cnt; static int all_symbols = 0; +static int uncompressed = 0; static int absolute_percpu = 0; static char symbol_prefix_char = '\0'; static unsigned long long kernel_start_addr = 0; @@ -406,6 +436,9 @@ free(markers); + if (uncompressed) + return; + output_label("kallsyms_token_table"); off = 0; for (i = 0; i < 256; i++) { @@ -466,6 +499,9 @@ { int i; + if (uncompressed) + return NULL; + for (i = 0; i < len - 1; i++) { if (str[i] == token[0] && str[i+1] == token[1]) return &str[i]; @@ -538,6 +574,9 @@ { int i, best; + if (uncompressed) + return; + /* using the '\0' symbol last allows compress_symbols to use standard * fast string functions */ for (i = 255; i >= 0; i--) { @@ -708,7 +747,9 @@ } else if (strncmp(argv[i], "--page-offset=", 14) == 0) { const char *p = &argv[i][14]; kernel_start_addr = strtoull(p, NULL, 16); - } else + } else if (strcmp(argv[i], "--uncompressed") == 0) + uncompressed = 1; + else usage(); } } else if (argc != 1)