blob: 62f9ba4df3294f1cbdc5d32e1f250edaf983c99c [file] [log] [blame]
Rui Ueyamae7378242015-12-04 23:11:05 +00001//===- PDB.cpp ------------------------------------------------------------===//
2//
3// The LLVM Linker
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "Driver.h"
11#include "Error.h"
12#include "Symbols.h"
13#include "llvm/Support/FileOutputBuffer.h"
14#include <memory>
15
16using namespace llvm;
17
18const int PageSize = 4096;
19const uint8_t Magic[32] = "Microsoft C/C++ MSF 7.00\r\n\032DS\0\0";
20
21void lld::coff::createPDB(StringRef Path) {
22 // Create a file.
23 size_t FileSize = PageSize * 3;
24 ErrorOr<std::unique_ptr<FileOutputBuffer>> BufOrErr =
25 FileOutputBuffer::create(Path, FileSize);
26 error(BufOrErr, Twine("failed to open ") + Path);
27 std::unique_ptr<FileOutputBuffer> Buf = std::move(*BufOrErr);
28
29 // Write the file magic.
30 uint8_t *P = Buf->getBufferStart();
31 memcpy(P, Magic, sizeof(Magic));
32}