Path: blob/main/contrib/llvm-project/llvm/lib/ObjCopy/COFF/COFFWriter.h
35269 views
//===- COFFWriter.h ---------------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLVM_LIB_OBJCOPY_COFF_COFFWRITER_H9#define LLVM_LIB_OBJCOPY_COFF_COFFWRITER_H1011#include "llvm/MC/StringTableBuilder.h"12#include "llvm/Support/Error.h"13#include "llvm/Support/MemoryBuffer.h"14#include <cstddef>15#include <utility>1617namespace llvm {18namespace objcopy {19namespace coff {2021struct Object;2223class COFFWriter {24Object &Obj;25std::unique_ptr<WritableMemoryBuffer> Buf;26raw_ostream &Out;2728size_t FileSize;29size_t FileAlignment;30size_t SizeOfInitializedData;31StringTableBuilder StrTabBuilder;3233template <class SymbolTy> std::pair<size_t, size_t> finalizeSymbolTable();34Error finalizeRelocTargets();35Error finalizeSymbolContents();36void layoutSections();37Expected<size_t> finalizeStringTable();3839Error finalize(bool IsBigObj);4041void writeHeaders(bool IsBigObj);42void writeSections();43template <class SymbolTy> void writeSymbolStringTables();4445Error write(bool IsBigObj);4647Error patchDebugDirectory();48Expected<uint32_t> virtualAddressToFileAddress(uint32_t RVA);4950public:51virtual ~COFFWriter() {}52Error write();5354COFFWriter(Object &Obj, raw_ostream &Out)55: Obj(Obj), Out(Out), StrTabBuilder(StringTableBuilder::WinCOFF) {}56};5758} // end namespace coff59} // end namespace objcopy60} // end namespace llvm6162#endif // LLVM_LIB_OBJCOPY_COFF_COFFWRITER_H636465