LLVM 22.0.0git
COFFWriter.h
Go to the documentation of this file.
1//===- COFFWriter.h ---------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, 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#ifndef LLVM_LIB_OBJCOPY_COFF_COFFWRITER_H
10#define LLVM_LIB_OBJCOPY_COFF_COFFWRITER_H
11
13#include "llvm/Support/Error.h"
15#include <cstddef>
16#include <utility>
17
18namespace llvm {
19namespace objcopy {
20namespace coff {
21
22struct Object;
23
25 Object &Obj;
26 std::unique_ptr<WritableMemoryBuffer> Buf;
27 raw_ostream &Out;
28
29 size_t FileSize;
30 size_t FileAlignment;
31 size_t SizeOfInitializedData;
32 StringTableBuilder StrTabBuilder;
33
34 template <class SymbolTy> std::pair<size_t, size_t> finalizeSymbolTable();
35 Error finalizeRelocTargets();
36 Error finalizeSymbolContents();
37 Error finalizeSymIdxContents();
38 void layoutSections();
39 Expected<size_t> finalizeStringTable();
40
41 Error finalize(bool IsBigObj);
42
43 void writeHeaders(bool IsBigObj);
44 void writeSections();
45 template <class SymbolTy> void writeSymbolStringTables();
46
47 Error write(bool IsBigObj);
48
49 Error patchDebugDirectory();
50 Expected<uint32_t> virtualAddressToFileAddress(uint32_t RVA);
51
52public:
53 virtual ~COFFWriter() {}
54 Error write();
55
57 : Obj(Obj), Out(Out), StrTabBuilder(StringTableBuilder::WinCOFF) {}
58};
59
60} // end namespace coff
61} // end namespace objcopy
62} // end namespace llvm
63
64#endif // LLVM_LIB_OBJCOPY_COFF_COFFWRITER_H
arc branch finalize
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
Tagged union holding either a T or a Error.
Definition Error.h:485
Utility for building string tables with deduplicated suffixes.
COFFWriter(Object &Obj, raw_ostream &Out)
Definition COFFWriter.h:56
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.