xref: /freebsd/contrib/llvm-project/lld/ELF/Writer.h (revision 9768746b)
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 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLD_ELF_WRITER_H
10 #define LLD_ELF_WRITER_H
11 
12 #include "Config.h"
13 #include "llvm/ADT/StringRef.h"
14 #include <cstdint>
15 
16 namespace lld {
17 namespace elf {
18 class InputFile;
19 class OutputSection;
20 void copySectionsIntoPartitions();
21 template <class ELFT> void createSyntheticSections();
22 void combineEhSections();
23 template <class ELFT> void writeResult();
24 
25 // This describes a program header entry.
26 // Each contains type, access flags and range of output sections that will be
27 // placed in it.
28 struct PhdrEntry {
29   PhdrEntry(unsigned type, unsigned flags)
30       : p_align(type == llvm::ELF::PT_LOAD ? config->maxPageSize : 0),
31         p_type(type), p_flags(flags) {}
32   void add(OutputSection *sec);
33 
34   uint64_t p_paddr = 0;
35   uint64_t p_vaddr = 0;
36   uint64_t p_memsz = 0;
37   uint64_t p_filesz = 0;
38   uint64_t p_offset = 0;
39   uint32_t p_align = 0;
40   uint32_t p_type = 0;
41   uint32_t p_flags = 0;
42 
43   OutputSection *firstSec = nullptr;
44   OutputSection *lastSec = nullptr;
45   bool hasLMA = false;
46 
47   uint64_t lmaOffset = 0;
48 };
49 
50 void addReservedSymbols();
51 
52 template <class ELFT> uint32_t calcMipsEFlags();
53 
54 uint8_t getMipsFpAbiFlag(uint8_t oldFlag, uint8_t newFlag,
55                          llvm::StringRef fileName);
56 
57 bool isMipsN32Abi(const InputFile *f);
58 bool isMicroMips();
59 bool isMipsR6();
60 } // namespace elf
61 } // namespace lld
62 
63 #endif
64