[lld] r238569 - COFF: Add /heap option.
Rui Ueyama
ruiu at google.com
Fri May 29 09:23:40 PDT 2015
Author: ruiu
Date: Fri May 29 11:23:40 2015
New Revision: 238569
URL: http://llvm.org/viewvc/llvm-project?rev=238569&view=rev
Log:
COFF: Add /heap option.
Added:
lld/trunk/test/COFF/heap.test
Modified:
lld/trunk/COFF/Config.h
lld/trunk/COFF/Driver.cpp
lld/trunk/COFF/Writer.cpp
Modified: lld/trunk/COFF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Config.h?rev=238569&r1=238568&r2=238569&view=diff
==============================================================================
--- lld/trunk/COFF/Config.h (original)
+++ lld/trunk/COFF/Config.h Fri May 29 11:23:40 2015
@@ -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;
Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=238569&r1=238568&r2=238569&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Fri May 29 11:23:40 2015
@@ -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;
Modified: lld/trunk/COFF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Writer.cpp?rev=238569&r1=238568&r2=238569&view=diff
==============================================================================
--- lld/trunk/COFF/Writer.cpp (original)
+++ lld/trunk/COFF/Writer.cpp Fri May 29 11:23:40 2015
@@ -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();
Added: lld/trunk/test/COFF/heap.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/heap.test?rev=238569&view=auto
==============================================================================
--- lld/trunk/test/COFF/heap.test (added)
+++ lld/trunk/test/COFF/heap.test Fri May 29 11:23:40 2015
@@ -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
More information about the llvm-commits
mailing list