COFF: Add /heap option.

llvm-svn: 238569
This commit is contained in:
Rui Ueyama 2015-05-29 16:23:40 +00:00
parent b41b7e5a69
commit c377e9aefe
4 changed files with 32 additions and 2 deletions

View File

@ -28,6 +28,8 @@ public:
uint64_t ImageBase = 0x140000000;
uint64_t StackReserve = 1024 * 1024;
uint64_t StackCommit = 4096;
uint64_t HeapReserve = 1024 * 1024;
uint64_t HeapCommit = 4096;
bool insertFile(llvm::StringRef Path) {
return VisitedFiles.insert(Path.lower()).second;

View File

@ -143,6 +143,15 @@ bool link(int Argc, const char *Argv[]) {
}
}
// Handle /heap
if (auto *Arg = Args->getLastArg(OPT_heap)) {
if (auto EC = parseNumbers(Arg->getValue(), &Config->HeapReserve,
&Config->HeapCommit)) {
llvm::errs() << "/heap: " << EC.message() << "\n";
return false;
}
}
// Parse all input files and put all symbols to the symbol table.
// The symbol table will take care of name resolution.
SymbolTable Symtab;

View File

@ -267,8 +267,8 @@ void Writer::writeHeader() {
PE->AddressOfEntryPoint = Entry->getRVA();
PE->SizeOfStackReserve = Config->StackReserve;
PE->SizeOfStackCommit = Config->StackCommit;
PE->SizeOfHeapReserve = 1024 * 1024;
PE->SizeOfHeapCommit = 4096;
PE->SizeOfHeapReserve = Config->HeapReserve;
PE->SizeOfHeapCommit = Config->HeapCommit;
PE->NumberOfRvaAndSize = NumberfOfDataDirectory;
if (OutputSection *Text = findSection(".text")) {
PE->BaseOfCode = Text->getRVA();

19
lld/test/COFF/heap.test Normal file
View File

@ -0,0 +1,19 @@
# RUN: lld -flavor link2 /entry:main /out:%t.exe %p/Inputs/ret42.obj
# RUN: llvm-readobj -file-headers %t.exe | FileCheck -check-prefix=DEFAULT %s
DEFAULT: SizeOfHeapReserve: 1048576
DEFAULT: SizeOfHeapCommit: 4096
# RUN: lld -flavor link2 /entry:main /out:%t.exe /heap:0x3000 \
# RUN: %p/Inputs/ret42.obj
# RUN: llvm-readobj -file-headers %t.exe | FileCheck -check-prefix=CHECK1 %s
CHECK1: SizeOfHeapReserve: 12288
CHECK1: SizeOfHeapCommit: 4096
# RUN: lld -flavor link2 /entry:main /out:%t.exe /heap:0x5000,0x3000 \
# RUN: %p/Inputs/ret42.obj
# RUN: llvm-readobj -file-headers %t.exe | FileCheck -check-prefix=CHECK2 %s
CHECK2: SizeOfHeapReserve: 20480
CHECK2: SizeOfHeapCommit: 12288