150
|
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/ArrayRef.h"
|
|
14 #include "llvm/ADT/StringRef.h"
|
|
15 #include <cstdint>
|
|
16 #include <memory>
|
|
17
|
|
18 namespace lld {
|
|
19 namespace elf {
|
|
20 class InputFile;
|
|
21 class OutputSection;
|
|
22 class InputSectionBase;
|
|
23 void copySectionsIntoPartitions();
|
|
24 template <class ELFT> void createSyntheticSections();
|
|
25 void combineEhSections();
|
|
26 template <class ELFT> void writeResult();
|
|
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 struct PhdrEntry {
|
|
32 PhdrEntry(unsigned type, unsigned flags)
|
|
33 : p_align(type == llvm::ELF::PT_LOAD ? config->maxPageSize : 0),
|
|
34 p_type(type), p_flags(flags) {}
|
|
35 void add(OutputSection *sec);
|
|
36
|
|
37 uint64_t p_paddr = 0;
|
|
38 uint64_t p_vaddr = 0;
|
|
39 uint64_t p_memsz = 0;
|
|
40 uint64_t p_filesz = 0;
|
|
41 uint64_t p_offset = 0;
|
|
42 uint32_t p_align = 0;
|
|
43 uint32_t p_type = 0;
|
|
44 uint32_t p_flags = 0;
|
|
45
|
|
46 OutputSection *firstSec = nullptr;
|
|
47 OutputSection *lastSec = nullptr;
|
|
48 bool hasLMA = false;
|
|
49
|
|
50 uint64_t lmaOffset = 0;
|
|
51 };
|
|
52
|
|
53 void addReservedSymbols();
|
|
54 llvm::StringRef getOutputSectionName(const InputSectionBase *s);
|
|
55
|
|
56 template <class ELFT> uint32_t calcMipsEFlags();
|
|
57
|
|
58 uint8_t getMipsFpAbiFlag(uint8_t oldFlag, uint8_t newFlag,
|
|
59 llvm::StringRef fileName);
|
|
60
|
|
61 bool isMipsN32Abi(const InputFile *f);
|
|
62 bool isMicroMips();
|
|
63 bool isMipsR6();
|
|
64 } // namespace elf
|
|
65 } // namespace lld
|
|
66
|
|
67 #endif
|