[lld] r240067 - COFF: Unknown options in .drectve section is an error.
Rui Ueyama
ruiu at google.com
Thu Jun 18 14:50:38 PDT 2015
Author: ruiu
Date: Thu Jun 18 16:50:38 2015
New Revision: 240067
URL: http://llvm.org/viewvc/llvm-project?rev=240067&view=rev
Log:
COFF: Unknown options in .drectve section is an error.
We skip unknown options in the command line with a warning message
being printed out, but we shouldn't do that for .drectve section.
The section is not visible to the user. We should handle unknown
options as an error.
Modified:
lld/trunk/COFF/Driver.cpp
lld/trunk/test/COFF/baserel.test
Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=240067&r1=240066&r2=240067&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Thu Jun 18 16:50:38 2015
@@ -9,6 +9,7 @@
#include "Config.h"
#include "Driver.h"
+#include "Error.h"
#include "InputFiles.h"
#include "SymbolTable.h"
#include "Writer.h"
@@ -91,32 +92,35 @@ LinkerDriver::parseDirectives(StringRef
return EC;
std::unique_ptr<llvm::opt::InputArgList> Args = std::move(ArgsOrErr.get());
- // Handle /export
- for (auto *Arg : Args->filtered(OPT_export)) {
- ErrorOr<Export> E = parseExport(Arg->getValue());
- if (auto EC = E.getError())
- return EC;
- Config->Exports.push_back(E.get());
- }
-
- // Handle /alternatename
- for (auto *Arg : Args->filtered(OPT_alternatename))
- if (auto EC = parseAlternateName(Arg->getValue()))
- return EC;
-
- // Handle /failifmismatch
- for (auto *Arg : Args->filtered(OPT_failifmismatch))
- if (auto EC = checkFailIfMismatch(Arg->getValue()))
- return EC;
-
- // Handle /defaultlib
- for (auto *Arg : Args->filtered(OPT_defaultlib)) {
- if (Optional<StringRef> Path = findLib(Arg->getValue())) {
- ErrorOr<MemoryBufferRef> MBOrErr = openFile(*Path);
- if (auto EC = MBOrErr.getError())
+ for (auto *Arg : *Args) {
+ switch (Arg->getOption().getID()) {
+ case OPT_alternatename:
+ if (auto EC = parseAlternateName(Arg->getValue()))
+ return EC;
+ break;
+ case OPT_defaultlib:
+ if (Optional<StringRef> Path = findLib(Arg->getValue())) {
+ ErrorOr<MemoryBufferRef> MBOrErr = openFile(*Path);
+ if (auto EC = MBOrErr.getError())
+ return EC;
+ std::unique_ptr<InputFile> File = createFile(MBOrErr.get());
+ Res->push_back(std::move(File));
+ }
+ break;
+ case OPT_export: {
+ ErrorOr<Export> E = parseExport(Arg->getValue());
+ if (auto EC = E.getError())
+ return EC;
+ Config->Exports.push_back(E.get());
+ break;
+ }
+ case OPT_failifmismatch:
+ if (auto EC = checkFailIfMismatch(Arg->getValue()))
return EC;
- std::unique_ptr<InputFile> File = createFile(MBOrErr.get());
- Res->push_back(std::move(File));
+ break;
+ default:
+ llvm::errs() << Arg->getSpelling() << " is not allowed in .drectve\n";
+ return make_error_code(LLDError::InvalidOption);
}
}
return std::error_code();
Modified: lld/trunk/test/COFF/baserel.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/baserel.test?rev=240067&r1=240066&r2=240067&view=diff
==============================================================================
--- lld/trunk/test/COFF/baserel.test (original)
+++ lld/trunk/test/COFF/baserel.test Thu Jun 18 16:50:38 2015
@@ -127,10 +127,6 @@ sections:
Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
Alignment: 4
SectionData: 48656C6C6F0048656C6C6F20576F726C6400
- - Name: .drectve
- Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ]
- Alignment: 2147483648
- SectionData: 2F454E5452593A6D61696E20
symbols:
- Name: "@comp.id"
Value: 10394907
@@ -204,18 +200,6 @@ symbols:
SimpleType: IMAGE_SYM_TYPE_NULL
ComplexType: IMAGE_SYM_DTYPE_NULL
StorageClass: IMAGE_SYM_CLASS_STATIC
- - Name: .drectve
- Value: 0
- SectionNumber: 3
- SimpleType: IMAGE_SYM_TYPE_NULL
- ComplexType: IMAGE_SYM_DTYPE_NULL
- StorageClass: IMAGE_SYM_CLASS_STATIC
- SectionDefinition:
- Length: 12
- NumberOfRelocations: 0
- NumberOfLinenumbers: 0
- CheckSum: 0
- Number: 0
- Name: abs_symbol
Value: 0xDEADBEEF
SectionNumber: -1
More information about the llvm-commits
mailing list