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 18namespace lld { 19namespace elf { 20class InputFile; 21class OutputSection; 22class InputSectionBase; 23void copySectionsIntoPartitions(); 24template <class ELFT> void createSyntheticSections(); 25void combineEhSections(); 26template <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. 31struct 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 53void addReservedSymbols(); 54llvm::StringRef getOutputSectionName(const InputSectionBase *s); 55 56template <class ELFT> uint32_t calcMipsEFlags(); 57 58uint8_t getMipsFpAbiFlag(uint8_t oldFlag, uint8_t newFlag, 59 llvm::StringRef fileName); 60 61bool isMipsN32Abi(const InputFile *f); 62bool isMicroMips(); 63bool isMipsR6(); 64} // namespace elf 65} // namespace lld 66 67#endif 68