aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCParser/ELFAsmParser.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-02-17 20:48:01 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-02-17 20:48:01 +0000
commit68fa249cb5a9755f05e437db618d85e0097de8c3 (patch)
treeb8a223ea649e474a993233c5738e73fba8e83932 /llvm/lib/MC/MCParser/ELFAsmParser.cpp
parent3dcb3934c6072f5e2eed15fd63cdc1a35bb5cad4 (diff)
downloadllvm-68fa249cb5a9755f05e437db618d85e0097de8c3.zip
llvm-68fa249cb5a9755f05e437db618d85e0097de8c3.tar.gz
llvm-68fa249cb5a9755f05e437db618d85e0097de8c3.tar.bz2
Add r228980 back.
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: 229541
Diffstat (limited to 'llvm/lib/MC/MCParser/ELFAsmParser.cpp')
-rw-r--r--llvm/lib/MC/MCParser/ELFAsmParser.cpp14
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()) {