aboutsummaryrefslogtreecommitdiff
path: root/gprofng/src/Symbol.h
blob: 25ccecafe7f89c9079cbb87ea2d41d9c548056fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* Copyright (C) 2025 Free Software Foundation, Inc.
   Contributed by Oracle.

   This file is part of GNU Binutils.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, 51 Franklin Street - Fifth Floor, Boston,
   MA 02110-1301, USA.  */

class Function;
class Module;

class Range
{
public:
  Range (uint64_t _low, uint64_t _high)
  {
    low = _low;
    high = _high;
  }

  inline bool
  inside (uint64_t val)
  {
    return val >= low && val < high;
  };

  uint64_t low;
  uint64_t high;
};

class Symbol
{
public:
  Symbol (Vector<Symbol *> *vec = NULL);
  ~Symbol ();

  Symbol *
  cardinal ()
  {
    return alias ? alias : this;
  }

  // Find symbols in 'syms' matched by 'ranges'.
  static Vector<Symbol *> *find_symbols (Vector<Symbol *> *syms,
					 Vector<Range *> *ranges);
  static Vector<Symbol *> *sort_by_name (Vector<Symbol *> *syms);

  // Find symbol in CU corresponding to pc or linker_name.
  static Symbol *get_symbol (Vector<Symbol *> *syms, uint64_t pc);
  static Symbol *get_symbol (Vector<Symbol *> *syms, char *linker_name);

  // Create and append a new function to the 'module'.
  // Copy attributes (size, name, etc) from Simbol,
  Function *createFunction(Module *module);
  void dump (const char *msg = NULL);

  Function *func;
  Sp_lang_code lang_code;
  uint64_t value;
  uint64_t save;
  int64_t size;
  uint64_t img_offset; // image offset in the ELF file
  char *name;
  Symbol *alias;
  int local_ind;
  int flags;
  bool defined;
};