xref: /openbsd-src/gnu/llvm/lld/ELF/Writer.h (revision 05edf1c10c70aea023b49c9190728f24a4673803)
1ece8a530Spatrick //===- Writer.h -------------------------------------------------*- C++ -*-===//
2ece8a530Spatrick //
3ece8a530Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4ece8a530Spatrick // See https://llvm.org/LICENSE.txt for license information.
5ece8a530Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6ece8a530Spatrick //
7ece8a530Spatrick //===----------------------------------------------------------------------===//
8ece8a530Spatrick 
9ece8a530Spatrick #ifndef LLD_ELF_WRITER_H
10ece8a530Spatrick #define LLD_ELF_WRITER_H
11ece8a530Spatrick 
12ece8a530Spatrick #include "Config.h"
13ece8a530Spatrick #include "llvm/ADT/StringRef.h"
14ece8a530Spatrick #include <cstdint>
15ece8a530Spatrick 
16*05edf1c1Srobert namespace lld::elf {
17ece8a530Spatrick class InputFile;
18ece8a530Spatrick class OutputSection;
19ece8a530Spatrick void copySectionsIntoPartitions();
20ece8a530Spatrick template <class ELFT> void createSyntheticSections();
21ece8a530Spatrick template <class ELFT> void writeResult();
22ece8a530Spatrick 
23ece8a530Spatrick // This describes a program header entry.
24ece8a530Spatrick // Each contains type, access flags and range of output sections that will be
25ece8a530Spatrick // placed in it.
26ece8a530Spatrick struct PhdrEntry {
PhdrEntryPhdrEntry27ece8a530Spatrick   PhdrEntry(unsigned type, unsigned flags)
28adae0cfdSpatrick       : p_align(type == llvm::ELF::PT_LOAD ? config->textAlignPageSize : 0),
29ece8a530Spatrick         p_type(type), p_flags(flags) {}
30ece8a530Spatrick   void add(OutputSection *sec);
31ece8a530Spatrick 
32ece8a530Spatrick   uint64_t p_paddr = 0;
33ece8a530Spatrick   uint64_t p_vaddr = 0;
34ece8a530Spatrick   uint64_t p_memsz = 0;
35ece8a530Spatrick   uint64_t p_filesz = 0;
36ece8a530Spatrick   uint64_t p_offset = 0;
37ece8a530Spatrick   uint32_t p_align = 0;
38ece8a530Spatrick   uint32_t p_type = 0;
39ece8a530Spatrick   uint32_t p_flags = 0;
40ece8a530Spatrick 
41ece8a530Spatrick   OutputSection *firstSec = nullptr;
42ece8a530Spatrick   OutputSection *lastSec = nullptr;
43ece8a530Spatrick   bool hasLMA = false;
44ece8a530Spatrick 
45ece8a530Spatrick   uint64_t lmaOffset = 0;
46ece8a530Spatrick };
47ece8a530Spatrick 
48ece8a530Spatrick void addReservedSymbols();
49ece8a530Spatrick 
50ece8a530Spatrick template <class ELFT> uint32_t calcMipsEFlags();
51ece8a530Spatrick 
52ece8a530Spatrick uint8_t getMipsFpAbiFlag(uint8_t oldFlag, uint8_t newFlag,
53ece8a530Spatrick                          llvm::StringRef fileName);
54ece8a530Spatrick 
55ece8a530Spatrick bool isMipsN32Abi(const InputFile *f);
56ece8a530Spatrick bool isMicroMips();
57ece8a530Spatrick bool isMipsR6();
58*05edf1c1Srobert } // namespace lld::elf
59ece8a530Spatrick 
60ece8a530Spatrick #endif
61