Rui Ueyama | e737824 | 2015-12-04 23:11:05 +0000 | [diff] [blame^] | 1 | //===- 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 | |
| 16 | using namespace llvm; |
| 17 | |
| 18 | const int PageSize = 4096; |
| 19 | const uint8_t Magic[32] = "Microsoft C/C++ MSF 7.00\r\n\032DS\0\0"; |
| 20 | |
| 21 | void 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 | } |