// Open a given file path and return it as a memory-mapped file.
Optional<MemoryBufferRef> macho::readFile(StringRef path) {
- // Open a file.
ErrorOr<std::unique_ptr<MemoryBuffer>> mbOrErr = MemoryBuffer::getFile(path);
if (std::error_code ec = mbOrErr.getError()) {
error("cannot open " + path + ": " + ec.message());
return mbref;
}
- // Object files and archive files may be fat files, which contains
- // multiple real files for different CPU ISAs. Here, we search for a
- // file that matches with the current link target and returns it as
- // a MemoryBufferRef.
+ // Object files and archive files may be fat files, which contain multiple
+ // real files for different CPU ISAs. Here, we search for a file that matches
+ // with the current link target and returns it as a MemoryBufferRef.
const auto *arch = reinterpret_cast<const fat_arch *>(buf + sizeof(*hdr));
for (uint32_t i = 0, n = read32be(&hdr->nfat_arch); i < n; ++i) {
namespace macho {
class InputFile;
-class InputSection;
class OutputSection;
class InputSection {
public:
virtual ~InputSection() = default;
virtual uint64_t getSize() const { return data.size(); }
- virtual uint64_t getFileSize() const;
+ uint64_t getFileSize() const;
uint64_t getFileOffset() const;
uint64_t getVA() const;
- virtual void writeTo(uint8_t *buf);
+ void writeTo(uint8_t *buf);
InputFile *file = nullptr;
StringRef name;
}
}
+static_assert((CodeSignatureSection::blobHeadersSize % 8) == 0, "");
+static_assert((CodeSignatureSection::fixedHeadersSize % 8) == 0, "");
+
CodeSignatureSection::CodeSignatureSection()
: LinkEditSection(segment_names::linkEdit, section_names::codeSignature) {
align = 16; // required by libstuff
#include "OutputSegment.h"
#include "Target.h"
-#include "llvm/ADT/PointerUnion.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
uint64_t xarSize;
};
-static_assert((CodeSignatureSection::blobHeadersSize % 8) == 0, "");
-static_assert((CodeSignatureSection::fixedHeadersSize % 8) == 0, "");
-
struct InStruct {
MachHeaderSection *header = nullptr;
RebaseSection *rebase = nullptr;