6f63216c3d
Previously, the special segments `__PAGEZERO` and `__LINKEDIT` were implemented as special LoadCommands. This diff implements them using special sections instead which have an `isHidden()` attribute. We do not emit section headers for hidden sections, but we use their addresses and file offsets to determine that of their containing segments. In addition to allowing us to share more segment-related code, this refactor is also important for the next step of emitting dylibs: 1) dylibs don't have segments like __PAGEZERO, so we need an easy way of omitting them w/o messing up segment indices 2) Unlike the kernel, which is happy to run an executable with out-of-order segments, dyld requires dylibs to have their segment load commands arranged in increasing address order. The refactor makes it easier to implement sorting of sections and segments. Differential Revision: https://reviews.llvm.org/D76839
32 lines
738 B
C++
32 lines
738 B
C++
//===- Writer.h -------------------------------------------------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLD_MACHO_WRITER_H
|
|
#define LLD_MACHO_WRITER_H
|
|
|
|
#include <cstdint>
|
|
|
|
namespace lld {
|
|
namespace macho {
|
|
|
|
class LoadCommand {
|
|
public:
|
|
virtual ~LoadCommand() = default;
|
|
virtual uint32_t getSize() const = 0;
|
|
virtual void writeTo(uint8_t *buf) const = 0;
|
|
};
|
|
|
|
void writeResult();
|
|
|
|
void createSyntheticSections();
|
|
|
|
} // namespace macho
|
|
} // namespace lld
|
|
|
|
#endif
|