diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-02-12 23:29:51 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-02-12 23:29:51 +0000 |
commit | b6a812ebb10c074266d6e4f9d2e2405bf57e4788 (patch) | |
tree | a108b29b58d3e0b9b9bdf17a74d667d207a3cc10 /llvm/lib/MC/MCParser/ELFAsmParser.cpp | |
parent | a12fcb790fb3694c6fcdf14047be72283ae4a0ee (diff) | |
download | llvm-b6a812ebb10c074266d6e4f9d2e2405bf57e4788.zip llvm-b6a812ebb10c074266d6e4f9d2e2405bf57e4788.tar.gz llvm-b6a812ebb10c074266d6e4f9d2e2405bf57e4788.tar.bz2 |
Add support for having multiple sections with the same name and comdat.
Using this in combination with -ffunction-sections allows LLVM to output a .o
file with mulitple sections named .text. This saves space by avoiding long
unique names of the form .text.<C++ mangled name>.
llvm-svn: 228980
Diffstat (limited to 'llvm/lib/MC/MCParser/ELFAsmParser.cpp')
-rw-r--r-- | llvm/lib/MC/MCParser/ELFAsmParser.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp index 21c65ce..7a120a1 100644 --- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp +++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp @@ -378,6 +378,8 @@ bool ELFAsmParser::ParseSectionArguments(bool IsPush, SMLoc loc) { unsigned Flags = 0; const MCExpr *Subsection = nullptr; bool UseLastGroup = false; + StringRef UniqueStr; + bool Unique = false; // Set the defaults first. if (SectionName == ".fini" || SectionName == ".init" || @@ -462,6 +464,14 @@ bool ELFAsmParser::ParseSectionArguments(bool IsPush, SMLoc loc) { return TokError("Linkage must be 'comdat'"); } } + if (getLexer().is(AsmToken::Comma)) { + Lex(); + if (getParser().parseIdentifier(UniqueStr)) + return TokError("expected identifier in directive"); + if (UniqueStr != "unique") + return TokError("expected 'unique'"); + Unique = true; + } } } @@ -509,8 +519,8 @@ EndStmt: } } - const MCSection *ELFSection = - getContext().getELFSection(SectionName, Type, Flags, Size, GroupName); + const MCSection *ELFSection = getContext().getELFSection( + SectionName, Type, Flags, Size, GroupName, Unique); getStreamer().SwitchSection(ELFSection, Subsection); if (getContext().getGenDwarfForAssembly()) { |