Debian Codegraph @

libcextract/DscFileGenerator.hh

raw
1 //===- DscFileGenerator.hh - Generate the libpulp .dsc file -----*- C++ -*-===//
2 //
3 // This project is licensed under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 /// \file
10 /// Generate the libulp .dsc file for a single userspace livepatch.
11 //
12 //===----------------------------------------------------------------------===//
13
14 /** DscFileGenerator: Generate libpulp .dsc file to be incorporated into livepatch
15 * object.
16 *
17 * Libpulp expects a .dsc file to be provided into the livepatch container
18 * (the .so file that is loaded with `ulp trigger`) into the `.ulp` section.
19 * This section is merged with the .so file using `ulp packer`.
20 *
21 * Author: Giuliano Belinassi
22 */
23
24 #pragma once
25
26 #include "SymbolExternalizer.hh"
27
28 #include <string>
29 #include <vector>
30
31 using namespace clang;
32
33
34 /** Class wrapping the analysis functions. */
35 class DscFileGenerator
36 {
37 public:
38 DscFileGenerator(const std::string &output,
39 ASTUnit *ast,
40 const std::vector<std::string> &funcs_to_extract,
41 const std::vector<ExternalizerLogEntry> &log,
42 InlineAnalysis &ia);
43
44 private:
45 /** Actually generates the file. */
46 void Run_Analysis(void);
47
48 /** Generate the .dsc header specifying the target ELF objects. */
49 void Target_ELF(void);
50
51 /** Generate the list of global functions to be patched. */
52 void Global_Functions(void);
53
54 /** Generate the list of local symbols to be patched. */
55 void Local_Symbols(void);
56
57
58 /** Stores the error code resulting from trying to open the target file. */
59 std::error_code EC;
60
61 /** Path to output. */
62 std::string OutputPath;
63
64 /** LLVM file stream object. */
65 llvm::raw_fd_ostream Out;
66
67 /** The AST object. */
68 ASTUnit *AST;
69
70 /** The list of functions that the user requested to be extracted. */
71 const std::vector<std::string> &FuncsToExtract;
72
73 /** A log of changes done by the SymbolExternalizer. */
74 const std::vector<ExternalizerLogEntry> &ExternalizerLog;
75
76 /** InlineAnalysis object. */
77 InlineAnalysis &IA;
78 };