LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
Function.hpp
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
23#include "LIEF/Abstract/Symbol.hpp"
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,
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:
62 Function();
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);
67 Function(const Function&);
68 Function& operator=(const Function&);
69 ~Function() override;
70
72 flags_list_t flags() const;
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 Function.hpp:29
FLAGS
Flags used to characterize the semantic of the function.
Definition Function.hpp:33
void accept(Visitor &visitor) const override
Method so that the visitor can visit us.
flags_list_t flags() const
List of FLAGS.
uint64_t address() const
Address of the current function. For functions that are set with the FLAGS::IMPORTED flag,...
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:219
LIEF namespace.
Definition Abstract/Binary.hpp:32