Index: lld/COFF/Config.h =================================================================== --- lld/COFF/Config.h +++ lld/COFF/Config.h @@ -124,6 +124,7 @@ std::vector natvisFiles; llvm::StringMap namedStreams; llvm::SmallString<128> pdbAltPath; + int pdbPageSize = 4096; llvm::SmallString<128> pdbPath; llvm::SmallString<128> pdbSourcePath; std::vector argv; Index: lld/COFF/Driver.h =================================================================== --- lld/COFF/Driver.h +++ lld/COFF/Driver.h @@ -176,6 +176,7 @@ void parseAlternateName(StringRef); void parseMerge(StringRef); +void parsePDBPageSize(StringRef); void parseSection(StringRef); void parseAligncomm(StringRef); Index: lld/COFF/Driver.cpp =================================================================== --- lld/COFF/Driver.cpp +++ lld/COFF/Driver.cpp @@ -1428,6 +1428,8 @@ config->pdbPath = arg->getValue(); if (auto *arg = args.getLastArg(OPT_pdbaltpath)) config->pdbAltPath = arg->getValue(); + if (auto *arg = args.getLastArg(OPT_pdbpagesize)) + parsePDBPageSize(arg->getValue()); if (args.hasArg(OPT_natvis)) config->natvisFiles = args.getAllArgValues(OPT_natvis); if (args.hasArg(OPT_pdbstream)) { Index: lld/COFF/DriverUtils.cpp =================================================================== --- lld/COFF/DriverUtils.cpp +++ lld/COFF/DriverUtils.cpp @@ -175,6 +175,26 @@ } } +void parsePDBPageSize(StringRef s) { + int v; + if (s.getAsInteger(0, v)) { + error("/pdbpagesize: invalid argument: " + s); + return; + } + if (v != 4096 && v != 8192 && v != 16384 && v != 32768) { + error("/pdbpagesize: invalid argument: " + s); + return; + } + + // FIXME: Remove this once other page sizes work. + if (v != 4096) { + warn("/pdbpagesize: page sizes != 4096 not yet implemented, ignoring flag"); + v = 4096; + } + + config->pdbPageSize = v; +} + static uint32_t parseSectionAttributes(StringRef s) { uint32_t ret = 0; for (char c : s.lower()) { Index: lld/COFF/Options.td =================================================================== --- lld/COFF/Options.td +++ lld/COFF/Options.td @@ -78,8 +78,9 @@ def out : P<"out", "Path to file to write output">; def natvis : P<"natvis", "Path to natvis file to embed in the PDB">; def pdb : P<"pdb", "PDB file path">; -def pdbstripped : P<"pdbstripped", "Stripped PDB file path">; def pdbaltpath : P<"pdbaltpath", "PDB file path to embed in the image">; +def pdbpagesize : P<"pdbpagesize", "PDB page size">; +def pdbstripped : P<"pdbstripped", "Stripped PDB file path">; def pdbstream : Joined<["/", "-", "/?", "-?"], "pdbstream:">, MetaVarName<"=">, HelpText<"Embed the contents of in the PDB as named stream ">; Index: lld/test/COFF/pdbpagesize.test =================================================================== --- /dev/null +++ lld/test/COFF/pdbpagesize.test @@ -0,0 +1,16 @@ +# RUN: yaml2obj %p/Inputs/empty.yaml -o %t.obj + +# RUN: not lld-link /entry:main %t.obj /out:%t.exe /debug /pdbpagesize:hi 2>&1 \ +# RUN: | FileCheck --check-prefix=INVALID %s + +# RUN: not lld-link /entry:main %t.obj /out:%t.exe /debug /pdbpagesize:15 2>&1 \ +# RUN: | FileCheck --check-prefix=INVALID %s + +# RUN: lld-link /entry:main %t.obj /out:%t.exe /debug /pdbpagesize:4096 + +# RUN: lld-link /entry:main %t.obj /out:%t.exe /debug /pdbpagesize:8192 2>&1 \ +# RUN: | FileCheck --check-prefix=TODO %s + +# INVALID: error: /pdbpagesize: invalid argument: + +# TODO: warning: /pdbpagesize: page sizes != 4096 not yet implemented, ignoring flag