~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/lib/symbol/kallsyms.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 #include "symbol/kallsyms.h"
  3 #include "api/io.h"
  4 #include <stdio.h>
  5 #include <sys/stat.h>
  6 #include <fcntl.h>
  7 
  8 u8 kallsyms2elf_type(char type)
  9 {
 10         type = tolower(type);
 11         return (type == 't' || type == 'w') ? STT_FUNC : STT_OBJECT;
 12 }
 13 
 14 bool kallsyms__is_function(char symbol_type)
 15 {
 16         symbol_type = toupper(symbol_type);
 17         return symbol_type == 'T' || symbol_type == 'W';
 18 }
 19 
 20 static void read_to_eol(struct io *io)
 21 {
 22         int ch;
 23 
 24         for (;;) {
 25                 ch = io__get_char(io);
 26                 if (ch < 0 || ch == '\n')
 27                         return;
 28         }
 29 }
 30 
 31 int kallsyms__parse(const char *filename, void *arg,
 32                     int (*process_symbol)(void *arg, const char *name,
 33                                           char type, u64 start))
 34 {
 35         struct io io;
 36         char bf[BUFSIZ];
 37         int err;
 38 
 39         io.fd = open(filename, O_RDONLY, 0);
 40 
 41         if (io.fd < 0)
 42                 return -1;
 43 
 44         io__init(&io, io.fd, bf, sizeof(bf));
 45 
 46         err = 0;
 47         while (!io.eof) {
 48                 __u64 start;
 49                 int ch;
 50                 size_t i;
 51                 char symbol_type;
 52                 char symbol_name[KSYM_NAME_LEN + 1];
 53 
 54                 if (io__get_hex(&io, &start) != ' ') {
 55                         read_to_eol(&io);
 56                         continue;
 57                 }
 58                 symbol_type = io__get_char(&io);
 59                 if (io__get_char(&io) != ' ') {
 60                         read_to_eol(&io);
 61                         continue;
 62                 }
 63                 for (i = 0; i < sizeof(symbol_name); i++) {
 64                         ch = io__get_char(&io);
 65                         if (ch < 0 || ch == '\n')
 66                                 break;
 67                         symbol_name[i]  = ch;
 68                 }
 69                 symbol_name[i]  = '\0';
 70 
 71                 err = process_symbol(arg, symbol_name, symbol_type, start);
 72                 if (err)
 73                         break;
 74         }
 75 
 76         close(io.fd);
 77         return err;
 78 }
 79 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php