1 // SPDX-License-Identifier: GPL-2.0
2 #include "symbol/kallsyms.h"
8 u8
kallsyms2elf_type(char type
)
11 return (type
== 't' || type
== 'w') ? STT_FUNC
: STT_OBJECT
;
14 bool kallsyms__is_function(char symbol_type
)
16 symbol_type
= toupper(symbol_type
);
17 return symbol_type
== 'T' || symbol_type
== 'W';
20 static void read_to_eol(struct io
*io
)
25 ch
= io__get_char(io
);
26 if (ch
< 0 || ch
== '\n')
31 int kallsyms__parse(const char *filename
, void *arg
,
32 int (*process_symbol
)(void *arg
, const char *name
,
33 char type
, u64 start
))
39 io
.fd
= open(filename
, O_RDONLY
, 0);
44 io__init(&io
, io
.fd
, bf
, sizeof(bf
));
52 char symbol_name
[KSYM_NAME_LEN
+ 1];
54 if (io__get_hex(&io
, &start
) != ' ') {
58 symbol_type
= io__get_char(&io
);
59 if (io__get_char(&io
) != ' ') {
63 for (i
= 0; i
< sizeof(symbol_name
); i
++) {
64 ch
= io__get_char(&io
);
65 if (ch
< 0 || ch
== '\n')
69 symbol_name
[i
] = '\0';
71 err
= process_symbol(arg
, symbol_name
, symbol_type
, start
);