forked from OSchip/llvm-project
parent
b41b7e5a69
commit
c377e9aefe
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue