[PECOFF] Handle PRIVATE keyword in the module definition file
A symbol in a module definition file may be annotated with the
PRIVATE keyword like this.
EXPORTS
func PRIVATE
The PRIVATE keyword does not affect the resulting .dll file.
But it prevents the symbol to be listed in the .lib (import
library) file.
llvm-svn: 218273
This commit is contained in:
parent
45f4d54c07
commit
117ef70c98
|
|
@ -38,6 +38,7 @@ enum class Kind {
|
|||
kw_library,
|
||||
kw_name,
|
||||
kw_noname,
|
||||
kw_private,
|
||||
kw_stacksize,
|
||||
kw_version,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -61,7 +61,8 @@ public:
|
|||
};
|
||||
|
||||
struct ExportDesc {
|
||||
ExportDesc() : ordinal(-1), noname(false), isData(false) {}
|
||||
ExportDesc()
|
||||
: ordinal(-1), noname(false), isData(false), isPrivate(false) {}
|
||||
bool operator<(const ExportDesc &other) const {
|
||||
return name.compare(other.name) < 0;
|
||||
}
|
||||
|
|
@ -71,6 +72,7 @@ public:
|
|||
int ordinal;
|
||||
bool noname;
|
||||
bool isData;
|
||||
bool isPrivate;
|
||||
};
|
||||
|
||||
/// \brief Casting support
|
||||
|
|
|
|||
|
|
@ -54,16 +54,17 @@ Token Lexer::lex() {
|
|||
"0123456789_.*~+!@#$%^&*()/");
|
||||
StringRef word = _buffer.substr(0, end);
|
||||
Kind kind = llvm::StringSwitch<Kind>(word)
|
||||
.Case("BASE", Kind::kw_base)
|
||||
.Case("DATA", Kind::kw_data)
|
||||
.Case("EXPORTS", Kind::kw_exports)
|
||||
.Case("HEAPSIZE", Kind::kw_heapsize)
|
||||
.Case("LIBRARY", Kind::kw_library)
|
||||
.Case("NAME", Kind::kw_name)
|
||||
.Case("NONAME", Kind::kw_noname)
|
||||
.Case("STACKSIZE", Kind::kw_stacksize)
|
||||
.Case("VERSION", Kind::kw_version)
|
||||
.Default(Kind::identifier);
|
||||
.Case("BASE", Kind::kw_base)
|
||||
.Case("DATA", Kind::kw_data)
|
||||
.Case("EXPORTS", Kind::kw_exports)
|
||||
.Case("HEAPSIZE", Kind::kw_heapsize)
|
||||
.Case("LIBRARY", Kind::kw_library)
|
||||
.Case("NAME", Kind::kw_name)
|
||||
.Case("NONAME", Kind::kw_noname)
|
||||
.Case("PRIVATE", Kind::kw_private)
|
||||
.Case("STACKSIZE", Kind::kw_stacksize)
|
||||
.Case("VERSION", Kind::kw_version)
|
||||
.Default(Kind::identifier);
|
||||
_buffer = (end == _buffer.npos) ? "" : _buffer.drop_front(end);
|
||||
return Token(kind, word);
|
||||
}
|
||||
|
|
@ -224,6 +225,10 @@ bool Parser::parseExport(PECOFFLinkingContext::ExportDesc &result) {
|
|||
result.isData = true;
|
||||
continue;
|
||||
}
|
||||
if (_tok._kind == Kind::kw_private) {
|
||||
result.isPrivate = true;
|
||||
continue;
|
||||
}
|
||||
ungetToken();
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ createModuleDefinitionFile(const PECOFFLinkingContext &ctx) {
|
|||
os << " NONAME";
|
||||
if (desc.isData)
|
||||
os << " DATA";
|
||||
if (desc.isPrivate)
|
||||
os << " PRIVATE";
|
||||
os << "\n";
|
||||
}
|
||||
os.flush();
|
||||
|
|
|
|||
|
|
@ -3,4 +3,4 @@
|
|||
EXPORTS
|
||||
exportfn1 @5 ; foo
|
||||
exportfn2
|
||||
exportfn5=exportfn6
|
||||
exportfn5=exportfn6 PRIVATE
|
||||
|
|
|
|||
Loading…
Reference in New Issue