[InstCombine] Signed saturation patterns
[llvm-core.git] / tools / llvm-objcopy / COFF / Writer.h
blob681a8d5e4a66cb7a2774a368504c5bed11502364
1 //===- Writer.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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_TOOLS_OBJCOPY_COFF_WRITER_H
10 #define LLVM_TOOLS_OBJCOPY_COFF_WRITER_H
12 #include "Buffer.h"
13 #include "llvm/MC/StringTableBuilder.h"
14 #include "llvm/Support/Error.h"
15 #include <cstddef>
16 #include <utility>
18 namespace llvm {
19 namespace objcopy {
20 namespace coff {
22 struct Object;
24 class COFFWriter {
25 Object &Obj;
26 Buffer &Buf;
28 size_t FileSize;
29 size_t FileAlignment;
30 size_t SizeOfInitializedData;
31 StringTableBuilder StrTabBuilder;
33 template <class SymbolTy> std::pair<size_t, size_t> finalizeSymbolTable();
34 Error finalizeRelocTargets();
35 Error finalizeSymbolContents();
36 void layoutSections();
37 size_t finalizeStringTable();
39 Error finalize(bool IsBigObj);
41 void writeHeaders(bool IsBigObj);
42 void writeSections();
43 template <class SymbolTy> void writeSymbolStringTables();
45 Error write(bool IsBigObj);
47 Error patchDebugDirectory();
49 public:
50 virtual ~COFFWriter() {}
51 Error write();
53 COFFWriter(Object &Obj, Buffer &Buf)
54 : Obj(Obj), Buf(Buf), StrTabBuilder(StringTableBuilder::WinCOFF) {}
57 } // end namespace coff
58 } // end namespace objcopy
59 } // end namespace llvm
61 #endif // LLVM_TOOLS_OBJCOPY_COFF_WRITER_H