xref: /llvm-project-15.0.7/lld/ELF/Writer.h (revision f4debddb)
1 //===- Writer.h -------------------------------------------------*- C++ -*-===//
2 //
3 //                             The LLVM Linker
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLD_ELF_WRITER_H
11 #define LLD_ELF_WRITER_H
12 
13 #include "llvm/ADT/StringRef.h"
14 #include <cstdint>
15 #include <memory>
16 
17 namespace lld {
18 namespace elf {
19 class InputFile;
20 class OutputSectionBase;
21 template <class ELFT> class InputSectionBase;
22 template <class ELFT> class ObjectFile;
23 template <class ELFT> class SymbolTable;
24 template <class ELFT> void writeResult();
25 template <class ELFT> void markLive();
26 template <class ELFT> bool isRelroSection(const OutputSectionBase *Sec);
27 
28 // This describes a program header entry.
29 // Each contains type, access flags and range of output sections that will be
30 // placed in it.
31 template <class ELFT> struct PhdrEntry {
32   PhdrEntry(unsigned Type, unsigned Flags);
33   void add(OutputSectionBase *Sec);
34 
35   typename ELFT::Phdr H = {};
36   OutputSectionBase *First = nullptr;
37   OutputSectionBase *Last = nullptr;
38   bool HasLMA = false;
39 };
40 
41 llvm::StringRef getOutputSectionName(llvm::StringRef Name);
42 
43 template <class ELFT> void reportDiscarded(InputSectionBase<ELFT> *IS);
44 
45 template <class ELFT> uint32_t getMipsEFlags();
46 
47 uint8_t getMipsFpAbiFlag(uint8_t OldFlag, uint8_t NewFlag,
48                          llvm::StringRef FileName);
49 
50 bool isMipsN32Abi(const InputFile *F);
51 std::string getErrorLocation(uint8_t *Loc);
52 }
53 }
54 
55 #endif
56