LIEF: Library to Instrument Executable Formats Version 0.16.0
Loading...
Searching...
No Matches
Abstract/Function.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2024 R. Thomas
2 * Copyright 2017 - 2024 Quarkslab
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef LIEF_ABSTRACT_FUNCTION_H
17#define LIEF_ABSTRACT_FUNCTION_H
18
19#include <vector>
20#include <string>
21#include <set>
22
24#include "LIEF/visibility.h"
25
26namespace LIEF {
27
29class LIEF_API Function : public Symbol {
30 public:
33 enum class FLAGS {
34 NONE = 0,
39 CONSTRUCTOR,
40
45 DESTRUCTOR,
46
48 DEBUG_INFO,
49
52 EXPORTED,
53
55 IMPORTED,
56 };
57
58 using flags_list_t = std::vector<FLAGS>;
59 using flags_t = std::set<FLAGS>;
60
61 public:
63 Function(const std::string& name);
64 Function(uint64_t address);
65 Function(const std::string& name, uint64_t address);
66 Function(const std::string& name, uint64_t address, const flags_list_t& flags);
69 ~Function() override;
70
73
76
79 uint64_t address() const;
80 void address(uint64_t address);
81
83 void accept(Visitor& visitor) const override;
84
85 LIEF_API friend std::ostream& operator<<(std::ostream& os, const Function& entry);
86
87 protected:
88 flags_t flags_;
89};
90}
91
92#endif
93
Class that represents a function in the binary.
Definition Abstract/Function.hpp:29
~Function() override
void address(uint64_t address)
Function & operator=(const Function &)
Function(const Function &)
Function(const std::string &name, uint64_t address)
std::set< FLAGS > flags_t
Definition Abstract/Function.hpp:59
FLAGS
Flags used to characterize the semantic of the function.
Definition Abstract/Function.hpp:33
void accept(Visitor &visitor) const override
Method so that the visitor can visit us.
std::vector< FLAGS > flags_list_t
Definition Abstract/Function.hpp:58
Function(const std::string &name)
friend std::ostream & operator<<(std::ostream &os, const Function &entry)
flags_list_t flags() const
List of FLAGS.
Function(uint64_t address)
uint64_t address() const
Address of the current function. For functions that are set with the FLAGS::IMPORTED flag,...
Function(const std::string &name, uint64_t address, const flags_list_t &flags)
Function & add(FLAGS f)
Add a flag to the current function.
This class represents a symbol in an executable format.
Definition Abstract/Symbol.hpp:28
Definition Visitor.hpp:225
LIEF namespace.
Definition Abstract/Binary.hpp:32
#define LIEF_API
Definition visibility.h:41