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

source code of lld/ELF/Writer.h