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

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

Version: ~ [ linux-6.2-rc3 ] ~ [ linux-6.1.5 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.87 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.162 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.228 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.269 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.302 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ 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 <ctype.h>
  3 #include "symbol/kallsyms.h"
  4 #include <stdio.h>
  5 #include <stdlib.h>
  6 
  7 u8 kallsyms2elf_type(char type)
  8 {
  9         type = tolower(type);
 10         return (type == 't' || type == 'w') ? STT_FUNC : STT_OBJECT;
 11 }
 12 
 13 int kallsyms__parse(const char *filename, void *arg,
 14                     int (*process_symbol)(void *arg, const char *name,
 15                                           char type, u64 start))
 16 {
 17         char *line = NULL;
 18         size_t n;
 19         int err = -1;
 20         FILE *file = fopen(filename, "r");
 21 
 22         if (file == NULL)
 23                 goto out_failure;
 24 
 25         err = 0;
 26 
 27         while (!feof(file)) {
 28                 u64 start;
 29                 int line_len, len;
 30                 char symbol_type;
 31                 char *symbol_name;
 32 
 33                 line_len = getline(&line, &n, file);
 34                 if (line_len < 0 || !line)
 35                         break;
 36 
 37                 line[--line_len] = '\0'; /* \n */
 38 
 39                 len = hex2u64(line, &start);
 40 
 41                 len++;
 42                 if (len + 2 >= line_len)
 43                         continue;
 44 
 45                 symbol_type = line[len];
 46                 len += 2;
 47                 symbol_name = line + len;
 48                 len = line_len - len;
 49 
 50                 if (len >= KSYM_NAME_LEN) {
 51                         err = -1;
 52                         break;
 53                 }
 54 
 55                 err = process_symbol(arg, symbol_name, symbol_type, start);
 56                 if (err)
 57                         break;
 58         }
 59 
 60         free(line);
 61         fclose(file);
 62         return err;
 63 
 64 out_failure:
 65         return -1;
 66 }
 67 

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

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | 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.

osdn.jp