1 // SPDX-License-Identifier: GPL-2.0
3 #include "symbol/kallsyms.h"
7 u8 kallsyms2elf_type(char type)
10 return (type == 't' || type == 'w') ? STT_FUNC : STT_OBJECT;
13 bool kallsyms__is_function(char symbol_type)
15 symbol_type = toupper(symbol_type);
16 return symbol_type == 'T' || symbol_type == 'W';
19 int kallsyms__parse(const char *filename, void *arg,
20 int (*process_symbol)(void *arg, const char *name,
21 char type, u64 start))
26 FILE *file = fopen(filename, "r");
39 line_len = getline(&line, &n, file);
40 if (line_len < 0 || !line)
43 line[--line_len] = '\0'; /* \n */
45 len = hex2u64(line, &start);
47 /* Skip the line if we failed to parse the address. */
52 if (len + 2 >= line_len)
55 symbol_type = line[len];
57 symbol_name = line + len;
60 if (len >= KSYM_NAME_LEN) {
65 err = process_symbol(arg, symbol_name, symbol_type, start);