<div dir="ltr"><div>On Tue, Sep 12, 2017 at 2:31 PM, Shoaib Meenai <span dir="ltr"><<a href="mailto:smeenai@fb.com" target="_blank">smeenai@fb.com</a>></span> wrote:<br></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">It's written in C, and it has 325 common symbols.<br></blockquote><div><br></div><div>It seems 325 common symbols are few to explain the regression you have experienced from <span style="font-size:12.8px"> </span><span style="font-size:12.8px">~4.5 seconds to ~5.3 seconds. This patch creates one virtual section for each common symbol, so the linker would create just 325 section objects which should be pretty fast. I cannot imagine that it takes almost one second. I wonder if there's a factor other than that.</span></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
I only read up on common symbols today, so please correct me if my<br>
understanding is off. From what I've read, you'll end up with a common symbol<br>
in your object file if you have an uninitialized non-static global variable,<br>
e.g. (in the global scope):<br>
<br>
int x;<br>
<br>
If you mark the variable static, or if you explicitly zero-initialize it,<br>
it'll end up in bss instead of COMMON. You can also use -fno-common to force<br>
the use of bss, and C++ does so by default.<br>
<br>
I understand that COMMON symbols were originally devised to deal with people<br>
writing `int x` instead of `extern int x` in headers. My library doesn't have<br>
that problem; the `int x` form is used only in source files, and the intent is<br>
to define a variable and have it be automatically zero-initialized. I was<br>
hoping that if a variable was preceded by an extern declaration, e.g.<br>
<br>
extern int x;<br>
...<br>
int x;<br>
<br>
the compiler would place it in bss instead of COMMON, but that doesn't appear<br>
to be the case.<br>
<br>
I'll try compiling my sources with -fno-common. This definitely seems like<br>
something a lot of libraries could run into though, since it looks like all<br>
you need to trigger it is an uninitialized global variable.<br>
<div class="gmail-HOEnZb"><div class="gmail-h5"><br>
On 9/12/17, 1:25 PM, "Rafael Avila de Espindola" <<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:<br>
<br>
How many common symbols do you see in your library? What language is it<br>
written in?<br>
<br>
Cheers,<br>
Rafael<br>
<br>
Shoaib Meenai <<a href="mailto:smeenai@fb.com">smeenai@fb.com</a>> writes:<br>
<br>
> I'm seeing an 18% regression in link times for a large library from this<br>
> change (it increases from ~4.5 seconds to ~5.3 seconds). I'm looking into why<br>
> the library I'm linking has so many common symbols, since from the discussion<br>
> on the patch it sounds like common symbols should be relatively rare, but<br>
> there are probably other binaries out there which are similarly regressed.<br>
><br>
> On 9/8/17, 9:24 AM, "llvm-commits on behalf of Dmitry Mikulin via llvm-commits" <<a href="mailto:llvm-commits-bounces@lists.llvm.org">llvm-commits-bounces@lists.<wbr>llvm.org</a> on behalf of <a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br>
><br>
> Author: dmikulin<br>
> Date: Fri Sep 8 09:22:43 2017<br>
> New Revision: 312796<br>
><br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D312796-26view-3Drev&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=nQIMrFkM1t_gqODnbXQIOkB-BBcc2v2l4j7arjM9y4k&s=F0escWBl3X6bxsDuK92_UGN64Bcg7zhj2C7t3I1SJqQ&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__llvm.<wbr>org_viewvc_llvm-2Dproject-<wbr>3Frev-3D312796-26view-3Drev&d=<wbr>DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>nQIMrFkM1t_gqODnbXQIOkB-<wbr>BBcc2v2l4j7arjM9y4k&s=<wbr>F0escWBl3X6bxsDuK92_<wbr>UGN64Bcg7zhj2C7t3I1SJqQ&e=</a><br>
> Log:<br>
> Currently lld creates a single section to collect all commons. There is no way<br>
> to separate commons based on file name patterns. The following linker script<br>
> construct does not work because commons are allocated before section placement<br>
> is done and the only synthesized BssSection that holds all commons has no file<br>
> associated with it:<br>
> SECTIONS { .common_0 : { *file0.o(COMMON) }}<br>
><br>
> This patch changes the allocation of commons to create a section per common<br>
> symbol and let the section logic do the layout.<br>
><br>
> Differential revision: <a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D37489&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=nQIMrFkM1t_gqODnbXQIOkB-BBcc2v2l4j7arjM9y4k&s=hohyhSx7Or16JdZrgLzWWM6xJR5MYfzYxT7efGbRmfM&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=https-3A__<wbr>reviews.llvm.org_D37489&d=<wbr>DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>nQIMrFkM1t_gqODnbXQIOkB-<wbr>BBcc2v2l4j7arjM9y4k&s=<wbr>hohyhSx7Or16JdZrgLzWWM6xJR5MYf<wbr>zYxT7efGbRmfM&e=</a><br>
><br>
> Added:<br>
> lld/trunk/test/ELF/<wbr>linkerscript/Inputs/common-<wbr>filespec1.s<br>
> lld/trunk/test/ELF/<wbr>linkerscript/Inputs/common-<wbr>filespec2.s<br>
> lld/trunk/test/ELF/<wbr>linkerscript/common-exclude.s<br>
> lld/trunk/test/ELF/<wbr>linkerscript/common-filespec.s<br>
> Modified:<br>
> lld/trunk/ELF/LinkerScript.cpp<br>
> lld/trunk/ELF/MapFile.cpp<br>
> lld/trunk/ELF/Symbols.cpp<br>
> lld/trunk/ELF/Symbols.h<br>
> lld/trunk/ELF/<wbr>SyntheticSections.cpp<br>
> lld/trunk/ELF/<wbr>SyntheticSections.h<br>
> lld/trunk/ELF/Writer.cpp<br>
> lld/trunk/test/ELF/common.s<br>
> lld/trunk/test/ELF/<wbr>linkerscript/common.s<br>
> lld/trunk/test/ELF/<wbr>linkerscript/discard-section-<wbr>err.s<br>
> lld/trunk/test/ELF/map-file.s<br>
><br>
> Modified: lld/trunk/ELF/LinkerScript.cpp<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_ELF_LinkerScript.cpp-3Frev-3D312796-26r1-3D312795-26r2-3D312796-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=nQIMrFkM1t_gqODnbXQIOkB-BBcc2v2l4j7arjM9y4k&s=aoZ7kwk46HKH2ETf1dfWh2-cXemDYt9vf9VnTnLdcuk&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__llvm.<wbr>org_viewvc_llvm-2Dproject_lld_<wbr>trunk_ELF_LinkerScript.cpp-<wbr>3Frev-3D312796-26r1-3D312795-<wbr>26r2-3D312796-26view-3Ddiff&d=<wbr>DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>nQIMrFkM1t_gqODnbXQIOkB-<wbr>BBcc2v2l4j7arjM9y4k&s=<wbr>aoZ7kwk46HKH2ETf1dfWh2-<wbr>cXemDYt9vf9VnTnLdcuk&e=</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/ELF/LinkerScript.cpp (original)<br>
> +++ lld/trunk/ELF/LinkerScript.cpp Fri Sep 8 09:22:43 2017<br>
> @@ -174,17 +174,17 @@ bool BytesDataCommand::classof(<wbr>const Bas<br>
> return C->Kind == BytesDataKind;<br>
> }<br>
><br>
> -static std::string filename(InputSectionBase *S) {<br>
> - if (!S->File)<br>
> +static std::string filename(InputFile *File) {<br>
> + if (!File)<br>
> return "";<br>
> - if (S->File->ArchiveName.empty())<br>
> - return S->File->getName();<br>
> - return (S->File->ArchiveName + "(" + S->File->getName() + ")").str();<br>
> + if (File->ArchiveName.empty())<br>
> + return File->getName();<br>
> + return (File->ArchiveName + "(" + File->getName() + ")").str();<br>
> }<br>
><br>
> bool LinkerScript::shouldKeep(<wbr>InputSectionBase *S) {<br>
> for (InputSectionDescription *ID : Opt.KeptSections) {<br>
> - std::string Filename = filename(S);<br>
> + std::string Filename = filename(S->File);<br>
> if (ID->FilePat.match(Filename))<br>
> for (SectionPattern &P : ID->SectionPatterns)<br>
> if (P.SectionPat.match(S->Name))<br>
> @@ -284,7 +284,7 @@ LinkerScript::<wbr>computeInputSections(const<br>
> if (Sec->Type == SHT_REL || Sec->Type == SHT_RELA)<br>
> continue;<br>
><br>
> - std::string Filename = filename(Sec);<br>
> + std::string Filename = filename(Sec->File);<br>
> if (!Cmd->FilePat.match(Filename) ||<br>
> Pat.ExcludedFilePat.match(<wbr>Filename) ||<br>
> !Pat.SectionPat.match(Sec-><wbr>Name))<br>
> @@ -328,8 +328,8 @@ LinkerScript::<wbr>computeInputSections(const<br>
> void LinkerScript::discard(<wbr>ArrayRef<InputSectionBase *> V) {<br>
> for (InputSectionBase *S : V) {<br>
> S->Live = false;<br>
> - if (S == InX::ShStrTab || S == InX::Common || S == InX::Dynamic ||<br>
> - S == InX::DynSymTab || S == InX::DynStrTab)<br>
> + if (S == InX::ShStrTab || S == InX::Dynamic || S == InX::DynSymTab ||<br>
> + S == InX::DynStrTab)<br>
> error("discarding " + S->Name + " section is not allowed");<br>
> discard(S->DependentSections);<br>
> }<br>
> @@ -868,7 +868,7 @@ ExprValue LinkerScript::getSymbolValue(c<br>
> if (auto *D = dyn_cast<DefinedRegular>(B))<br>
> return {D->Section, D->Value, Loc};<br>
> if (auto *C = dyn_cast<DefinedCommon>(B))<br>
> - return {InX::Common, C->Offset, Loc};<br>
> + return {C->Section, C->Offset, Loc};<br>
> }<br>
> error(Loc + ": symbol not found: " + S);<br>
> return 0;<br>
><br>
> Modified: lld/trunk/ELF/MapFile.cpp<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_ELF_MapFile.cpp-3Frev-3D312796-26r1-3D312795-26r2-3D312796-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=nQIMrFkM1t_gqODnbXQIOkB-BBcc2v2l4j7arjM9y4k&s=B87yHQNSR1ktCxKmP5fqTXzkkaYLMPAVfCo512EUe3U&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__llvm.<wbr>org_viewvc_llvm-2Dproject_lld_<wbr>trunk_ELF_MapFile.cpp-3Frev-<wbr>3D312796-26r1-3D312795-26r2-<wbr>3D312796-26view-3Ddiff&d=<wbr>DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>nQIMrFkM1t_gqODnbXQIOkB-<wbr>BBcc2v2l4j7arjM9y4k&s=<wbr>B87yHQNSR1ktCxKmP5fqTXzkkaYLMP<wbr>AVfCo512EUe3U&e=</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/ELF/MapFile.cpp (original)<br>
> +++ lld/trunk/ELF/MapFile.cpp Fri Sep 8 09:22:43 2017<br>
> @@ -57,7 +57,7 @@ template <class ELFT> static std::vector<br>
> DR->Section->Live)<br>
> V.push_back(DR);<br>
> } else if (auto *DC = dyn_cast<DefinedCommon>(B)) {<br>
> - if (InX::Common)<br>
> + if (DC->Section)<br>
> V.push_back(DC);<br>
> }<br>
> }<br>
> @@ -71,8 +71,8 @@ static SymbolMapTy getSectionSyms(ArrayR<br>
> for (Defined *S : Syms) {<br>
> if (auto *DR = dyn_cast<DefinedRegular>(S))<br>
> Ret[DR->Section].push_back(S);<br>
> - else<br>
> - Ret[InX::Common].push_back(S);<br>
> + else if (auto *DC = dyn_cast<DefinedCommon>(S))<br>
> + Ret[DC->Section].push_back(S);<br>
> }<br>
><br>
> // Sort symbols by address. We want to print out symbols in the<br>
><br>
> Modified: lld/trunk/ELF/Symbols.cpp<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_ELF_Symbols.cpp-3Frev-3D312796-26r1-3D312795-26r2-3D312796-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=nQIMrFkM1t_gqODnbXQIOkB-BBcc2v2l4j7arjM9y4k&s=XJ8Ntw-_OTE941EcbDm-3QfMbWAOcu1SOcgas_WsuSs&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__llvm.<wbr>org_viewvc_llvm-2Dproject_lld_<wbr>trunk_ELF_Symbols.cpp-3Frev-<wbr>3D312796-26r1-3D312795-26r2-<wbr>3D312796-26view-3Ddiff&d=<wbr>DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>nQIMrFkM1t_gqODnbXQIOkB-<wbr>BBcc2v2l4j7arjM9y4k&s=XJ8Ntw-_<wbr>OTE941EcbDm-3QfMbWAOcu1SOcgas_<wbr>WsuSs&e=</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/ELF/Symbols.cpp (original)<br>
> +++ lld/trunk/ELF/Symbols.cpp Fri Sep 8 09:22:43 2017<br>
> @@ -99,11 +99,13 @@ static uint64_t getSymVA(const SymbolBod<br>
> }<br>
> return VA;<br>
> }<br>
> - case SymbolBody::DefinedCommonKind:<br>
> + case SymbolBody::DefinedCommonKind: {<br>
> if (!Config->DefineCommon)<br>
> return 0;<br>
> - return InX::Common->getParent()->Addr + InX::Common->OutSecOff +<br>
> - cast<DefinedCommon>(Body).<wbr>Offset;<br>
> + auto DC = cast<DefinedCommon>(Body);<br>
> + return DC.Section->getParent()->Addr + DC.Section->OutSecOff +<br>
> + DC.Offset;<br>
> + }<br>
> case SymbolBody::SharedKind: {<br>
> auto &SS = cast<SharedSymbol>(Body);<br>
> if (SS.CopyRelSec)<br>
> @@ -202,9 +204,9 @@ OutputSection *SymbolBody::getOutputSect<br>
> return nullptr;<br>
> }<br>
><br>
> - if (isa<DefinedCommon>(this)) {<br>
> + if (auto *S = dyn_cast<DefinedCommon>(this)) {<br>
> if (Config->DefineCommon)<br>
> - return InX::Common->getParent();<br>
> + return S->Section->getParent();<br>
> return nullptr;<br>
> }<br>
><br>
><br>
> Modified: lld/trunk/ELF/Symbols.h<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_ELF_Symbols.h-3Frev-3D312796-26r1-3D312795-26r2-3D312796-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=nQIMrFkM1t_gqODnbXQIOkB-BBcc2v2l4j7arjM9y4k&s=ymRvyEWwgVa7bH65RA-PV_nwJPNRP_rdJ9CqTwXyozs&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__llvm.<wbr>org_viewvc_llvm-2Dproject_lld_<wbr>trunk_ELF_Symbols.h-3Frev-<wbr>3D312796-26r1-3D312795-26r2-<wbr>3D312796-26view-3Ddiff&d=<wbr>DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>nQIMrFkM1t_gqODnbXQIOkB-<wbr>BBcc2v2l4j7arjM9y4k&s=<wbr>ymRvyEWwgVa7bH65RA-PV_nwJPNRP_<wbr>rdJ9CqTwXyozs&e=</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/ELF/Symbols.h (original)<br>
> +++ lld/trunk/ELF/Symbols.h Fri Sep 8 09:22:43 2017<br>
> @@ -27,6 +27,7 @@ namespace elf {<br>
><br>
> class ArchiveFile;<br>
> class BitcodeFile;<br>
> +class BssSection;<br>
> class InputFile;<br>
> class LazyObjFile;<br>
> template <class ELFT> class ObjFile;<br>
> @@ -173,6 +174,7 @@ public:<br>
> // Computed by the writer.<br>
> uint64_t Offset;<br>
> uint64_t Size;<br>
> + BssSection *Section = nullptr;<br>
> };<br>
><br>
> // Regular defined symbols read from object file symbol tables.<br>
><br>
> Modified: lld/trunk/ELF/<wbr>SyntheticSections.cpp<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_ELF_SyntheticSections.cpp-3Frev-3D312796-26r1-3D312795-26r2-3D312796-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=nQIMrFkM1t_gqODnbXQIOkB-BBcc2v2l4j7arjM9y4k&s=hXG_5Y3y65iZ4sqHptPXnwR-j7hIeqRhMDdIVlgHkx4&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__llvm.<wbr>org_viewvc_llvm-2Dproject_lld_<wbr>trunk_ELF_SyntheticSections.<wbr>cpp-3Frev-3D312796-26r1-<wbr>3D312795-26r2-3D312796-26view-<wbr>3Ddiff&d=DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>nQIMrFkM1t_gqODnbXQIOkB-<wbr>BBcc2v2l4j7arjM9y4k&s=hXG_<wbr>5Y3y65iZ4sqHptPXnwR-<wbr>j7hIeqRhMDdIVlgHkx4&e=</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/ELF/<wbr>SyntheticSections.cpp (original)<br>
> +++ lld/trunk/ELF/<wbr>SyntheticSections.cpp Fri Sep 8 09:22:43 2017<br>
> @@ -54,35 +54,22 @@ uint64_t SyntheticSection::getVA() const<br>
> return 0;<br>
> }<br>
><br>
> -template <class ELFT> static std::vector<DefinedCommon *> getCommonSymbols() {<br>
> - std::vector<DefinedCommon *> V;<br>
> - for (Symbol *S : Symtab->getSymbols())<br>
> - if (auto *B = dyn_cast<DefinedCommon>(S-><wbr>body()))<br>
> - V.push_back(B);<br>
> - return V;<br>
> -}<br>
> -<br>
> -// Find all common symbols and allocate space for them.<br>
> -template <class ELFT> InputSection *elf::createCommonSection() {<br>
> +std::vector<InputSection *> elf::createCommonSections() {<br>
> if (!Config->DefineCommon)<br>
> - return nullptr;<br>
> + return {};<br>
><br>
> - // Sort the common symbols by alignment as an heuristic to pack them better.<br>
> - std::vector<DefinedCommon *> Syms = getCommonSymbols<ELFT>();<br>
> - if (Syms.empty())<br>
> - return nullptr;<br>
> -<br>
> - std::stable_sort(Syms.begin(), Syms.end(),<br>
> - [](const DefinedCommon *A, const DefinedCommon *B) {<br>
> - return A->Alignment > B->Alignment;<br>
> - });<br>
> + std::vector<InputSection *> Ret;<br>
> + for (Symbol *S : Symtab->getSymbols()) {<br>
> + auto *Sym = dyn_cast<DefinedCommon>(S-><wbr>body());<br>
> + if (!Sym || !Sym->Live)<br>
> + continue;<br>
><br>
> - // Allocate space for common symbols.<br>
> - BssSection *Sec = make<BssSection>("COMMON");<br>
> - for (DefinedCommon *Sym : Syms)<br>
> - if (Sym->Live)<br>
> - Sym->Offset = Sec->reserveSpace(Sym->Size, Sym->Alignment);<br>
> - return Sec;<br>
> + Sym->Section = make<BssSection>("COMMON");<br>
> + Sym->Offset = Sym->Section->reserveSpace(<wbr>Sym->Size, Sym->Alignment);<br>
> + Sym->Section->File = Sym->getFile();<br>
> + Ret.push_back(Sym->Section);<br>
> + }<br>
> + return Ret;<br>
> }<br>
><br>
> // Returns an LLD version string.<br>
> @@ -2321,7 +2308,6 @@ InputSection *InX::ARMAttributes;<br>
> BssSection *InX::Bss;<br>
> BssSection *InX::BssRelRo;<br>
> BuildIdSection *InX::BuildId;<br>
> -InputSection *InX::Common;<br>
> SyntheticSection *InX::Dynamic;<br>
> StringTableSection *InX::DynStrTab;<br>
> SymbolTableBaseSection *InX::DynSymTab;<br>
> @@ -2349,11 +2335,6 @@ template void PltSection::addEntry<ELF32<br>
> template void PltSection::addEntry<ELF64LE>(<wbr>SymbolBody &Sym);<br>
> template void PltSection::addEntry<ELF64BE>(<wbr>SymbolBody &Sym);<br>
><br>
> -template InputSection *elf::createCommonSection<<wbr>ELF32LE>();<br>
> -template InputSection *elf::createCommonSection<<wbr>ELF32BE>();<br>
> -template InputSection *elf::createCommonSection<<wbr>ELF64LE>();<br>
> -template InputSection *elf::createCommonSection<<wbr>ELF64BE>();<br>
> -<br>
> template MergeInputSection *elf::createCommentSection<<wbr>ELF32LE>();<br>
> template MergeInputSection *elf::createCommentSection<<wbr>ELF32BE>();<br>
> template MergeInputSection *elf::createCommentSection<<wbr>ELF64LE>();<br>
><br>
> Modified: lld/trunk/ELF/<wbr>SyntheticSections.h<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_ELF_SyntheticSections.h-3Frev-3D312796-26r1-3D312795-26r2-3D312796-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=nQIMrFkM1t_gqODnbXQIOkB-BBcc2v2l4j7arjM9y4k&s=lygUGc_3nqWGjJ7d0VlcIx7YSp6SrVkX4khOu7ceK8M&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__llvm.<wbr>org_viewvc_llvm-2Dproject_lld_<wbr>trunk_ELF_SyntheticSections.h-<wbr>3Frev-3D312796-26r1-3D312795-<wbr>26r2-3D312796-26view-3Ddiff&d=<wbr>DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>nQIMrFkM1t_gqODnbXQIOkB-<wbr>BBcc2v2l4j7arjM9y4k&s=lygUGc_<wbr>3nqWGjJ7d0VlcIx7YSp6SrVkX4khOu<wbr>7ceK8M&e=</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/ELF/<wbr>SyntheticSections.h (original)<br>
> +++ lld/trunk/ELF/<wbr>SyntheticSections.h Fri Sep 8 09:22:43 2017<br>
> @@ -740,7 +740,7 @@ private:<br>
> size_t Size = 0;<br>
> };<br>
><br>
> -template <class ELFT> InputSection *createCommonSection();<br>
> +std::vector<InputSection *> createCommonSections();<br>
> InputSection *createInterpSection();<br>
> template <class ELFT> MergeInputSection *createCommentSection();<br>
> void decompressAndMergeSections();<br>
> @@ -754,7 +754,6 @@ struct InX {<br>
> static BssSection *Bss;<br>
> static BssSection *BssRelRo;<br>
> static BuildIdSection *BuildId;<br>
> - static InputSection *Common;<br>
> static SyntheticSection *Dynamic;<br>
> static StringTableSection *DynStrTab;<br>
> static SymbolTableBaseSection *DynSymTab;<br>
><br>
> Modified: lld/trunk/ELF/Writer.cpp<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_ELF_Writer.cpp-3Frev-3D312796-26r1-3D312795-26r2-3D312796-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=nQIMrFkM1t_gqODnbXQIOkB-BBcc2v2l4j7arjM9y4k&s=Fo2NoJb9mo4IFU2cCnS7j5mYcFOr2N9yV4wo1Rosz-0&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__llvm.<wbr>org_viewvc_llvm-2Dproject_lld_<wbr>trunk_ELF_Writer.cpp-3Frev-<wbr>3D312796-26r1-3D312795-26r2-<wbr>3D312796-26view-3Ddiff&d=<wbr>DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>nQIMrFkM1t_gqODnbXQIOkB-<wbr>BBcc2v2l4j7arjM9y4k&s=<wbr>Fo2NoJb9mo4IFU2cCnS7j5mYcFOr2N<wbr>9yV4wo1Rosz-0&e=</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/ELF/Writer.cpp (original)<br>
> +++ lld/trunk/ELF/Writer.cpp Fri Sep 8 09:22:43 2017<br>
> @@ -299,9 +299,9 @@ template <class ELFT> void Writer<ELFT>:<br>
> Add(InX::BuildId);<br>
> }<br>
><br>
> - InX::Common = createCommonSection<ELFT>();<br>
> - if (InX::Common)<br>
> - Add(InX::Common);<br>
> + auto Commons = createCommonSections();<br>
> + for (InputSection *S : Commons)<br>
> + Add(S);<br>
><br>
> InX::Bss = make<BssSection>(".bss");<br>
> Add(InX::Bss);<br>
><br>
> Modified: lld/trunk/test/ELF/common.s<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_test_ELF_common.s-3Frev-3D312796-26r1-3D312795-26r2-3D312796-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=nQIMrFkM1t_gqODnbXQIOkB-BBcc2v2l4j7arjM9y4k&s=mZkHgNpDyXmZKHfqYrDVazT2K-8jzhgGbaDe_E27Jx4&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__llvm.<wbr>org_viewvc_llvm-2Dproject_lld_<wbr>trunk_test_ELF_common.s-3Frev-<wbr>3D312796-26r1-3D312795-26r2-<wbr>3D312796-26view-3Ddiff&d=<wbr>DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>nQIMrFkM1t_gqODnbXQIOkB-<wbr>BBcc2v2l4j7arjM9y4k&s=<wbr>mZkHgNpDyXmZKHfqYrDVazT2K-<wbr>8jzhgGbaDe_E27Jx4&e=</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/test/ELF/common.s (original)<br>
> +++ lld/trunk/test/ELF/common.s Fri Sep 8 09:22:43 2017<br>
> @@ -12,13 +12,13 @@<br>
> // CHECK-NEXT: ]<br>
> // CHECK-NEXT: Address: 0x201000<br>
> // CHECK-NEXT: Offset:<br>
> -// CHECK-NEXT: Size: 22<br>
> +// CHECK-NEXT: Size: 36<br>
> // CHECK-NEXT: Link: 0<br>
> // CHECK-NEXT: Info: 0<br>
> // CHECK-NEXT: AddressAlignment: 16<br>
><br>
> // CHECK: Name: sym1<br>
> -// CHECK-NEXT: Value: 0x201004<br>
> +// CHECK-NEXT: Value: 0x201000<br>
> // CHECK-NEXT: Size: 8<br>
> // CHECK-NEXT: Binding: Global<br>
> // CHECK-NEXT: Type: Object<br>
> @@ -26,7 +26,7 @@<br>
> // CHECK-NEXT: Section: .bss<br>
><br>
> // CHECK: Name: sym2<br>
> -// CHECK-NEXT: Value: 0x20100C<br>
> +// CHECK-NEXT: Value: 0x201008<br>
> // CHECK-NEXT: Size: 8<br>
> // CHECK-NEXT: Binding: Global<br>
> // CHECK-NEXT: Type: Object<br>
> @@ -34,7 +34,7 @@<br>
> // CHECK-NEXT: Section: .bss<br>
><br>
> // CHECK: Name: sym3<br>
> -// CHECK-NEXT: Value: 0x201014<br>
> +// CHECK-NEXT: Value: 0x201010<br>
> // CHECK-NEXT: Size: 2<br>
> // CHECK-NEXT: Binding: Global<br>
> // CHECK-NEXT: Type: Object<br>
> @@ -42,7 +42,7 @@<br>
> // CHECK-NEXT: Section: .bss<br>
><br>
> // CHECK: Name: sym4<br>
> -// CHECK-NEXT: Value: 0x201000<br>
> +// CHECK-NEXT: Value: 0x201020<br>
> // CHECK-NEXT: Size: 4<br>
> // CHECK-NEXT: Binding: Global<br>
> // CHECK-NEXT: Type: Object<br>
><br>
> Added: lld/trunk/test/ELF/<wbr>linkerscript/Inputs/common-<wbr>filespec1.s<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_test_ELF_linkerscript_Inputs_common-2Dfilespec1.s-3Frev-3D312796-26view-3Dauto&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=nQIMrFkM1t_gqODnbXQIOkB-BBcc2v2l4j7arjM9y4k&s=OTi1bORibcoRGd3l3yexjTochdxrHao98pq17krBYGY&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__llvm.<wbr>org_viewvc_llvm-2Dproject_lld_<wbr>trunk_test_ELF_linkerscript_<wbr>Inputs_common-2Dfilespec1.s-<wbr>3Frev-3D312796-26view-3Dauto&<wbr>d=DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>nQIMrFkM1t_gqODnbXQIOkB-<wbr>BBcc2v2l4j7arjM9y4k&s=<wbr>OTi1bORibcoRGd3l3yexjTochdxrHa<wbr>o98pq17krBYGY&e=</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/test/ELF/<wbr>linkerscript/Inputs/common-<wbr>filespec1.s (added)<br>
> +++ lld/trunk/test/ELF/<wbr>linkerscript/Inputs/common-<wbr>filespec1.s Fri Sep 8 09:22:43 2017<br>
> @@ -0,0 +1,2 @@<br>
> +.comm common_uniq_1,8,8<br>
> +.comm common_multiple,16,8<br>
><br>
> Added: lld/trunk/test/ELF/<wbr>linkerscript/Inputs/common-<wbr>filespec2.s<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_test_ELF_linkerscript_Inputs_common-2Dfilespec2.s-3Frev-3D312796-26view-3Dauto&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=nQIMrFkM1t_gqODnbXQIOkB-BBcc2v2l4j7arjM9y4k&s=L7MG3FqsEmFJk4lHR_DwrFl9wC4iy906C5ukU5K4-iI&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__llvm.<wbr>org_viewvc_llvm-2Dproject_lld_<wbr>trunk_test_ELF_linkerscript_<wbr>Inputs_common-2Dfilespec2.s-<wbr>3Frev-3D312796-26view-3Dauto&<wbr>d=DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>nQIMrFkM1t_gqODnbXQIOkB-<wbr>BBcc2v2l4j7arjM9y4k&s=<wbr>L7MG3FqsEmFJk4lHR_<wbr>DwrFl9wC4iy906C5ukU5K4-iI&e=</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/test/ELF/<wbr>linkerscript/Inputs/common-<wbr>filespec2.s (added)<br>
> +++ lld/trunk/test/ELF/<wbr>linkerscript/Inputs/common-<wbr>filespec2.s Fri Sep 8 09:22:43 2017<br>
> @@ -0,0 +1,2 @@<br>
> +.comm common_uniq_2,16,16<br>
> +.comm common_multiple,32,8<br>
><br>
> Added: lld/trunk/test/ELF/<wbr>linkerscript/common-exclude.s<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_test_ELF_linkerscript_common-2Dexclude.s-3Frev-3D312796-26view-3Dauto&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=nQIMrFkM1t_gqODnbXQIOkB-BBcc2v2l4j7arjM9y4k&s=b82z4zBHvvWyIABOGqEEBFCIHvF-HnzBQKeZMoUMU6E&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__llvm.<wbr>org_viewvc_llvm-2Dproject_lld_<wbr>trunk_test_ELF_linkerscript_<wbr>common-2Dexclude.s-3Frev-<wbr>3D312796-26view-3Dauto&d=<wbr>DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>nQIMrFkM1t_gqODnbXQIOkB-<wbr>BBcc2v2l4j7arjM9y4k&s=<wbr>b82z4zBHvvWyIABOGqEEBFCIHvF-<wbr>HnzBQKeZMoUMU6E&e=</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/test/ELF/<wbr>linkerscript/common-exclude.s (added)<br>
> +++ lld/trunk/test/ELF/<wbr>linkerscript/common-exclude.s Fri Sep 8 09:22:43 2017<br>
> @@ -0,0 +1,86 @@<br>
> +# REQUIRES: x86<br>
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %tfile0.o<br>
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/common-filespec1.s -o %tfile1.o<br>
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/common-filespec2.s -o %tfile2.o<br>
> +# RUN: echo "SECTIONS { .common.incl : { *(EXCLUDE_FILE (*file2.o) COMMON) } .common.excl : { *(COMMON) } }" > %t.script<br>
> +# RUN: ld.lld -o %t1 --script %t.script %tfile0.o %tfile1.o %tfile2.o<br>
> +# RUN: llvm-readobj -s -t %t1 | FileCheck %s<br>
> +<br>
> +# Commons from file0 and file1 are not excluded, so they must be in .common.incl<br>
> +# Commons from file2 are excluded from the first rule and should be caught by<br>
> +# the second in .common.excl<br>
> +# CHECK: Section {<br>
> +# CHECK: Index:<br>
> +# CHECK: Name: .common.incl<br>
> +# CHECK-NEXT: Type: SHT_NOBITS<br>
> +# CHECK-NEXT: Flags [<br>
> +# CHECK-NEXT: SHF_ALLOC<br>
> +# CHECK-NEXT: SHF_WRITE<br>
> +# CHECK-NEXT: ]<br>
> +# CHECK-NEXT: Address: 0x8<br>
> +# CHECK-NEXT: Offset: 0x<br>
> +# CHECK-NEXT: Size: 16<br>
> +# CHECK-NEXT: Link: 0<br>
> +# CHECK-NEXT: Info: 0<br>
> +# CHECK-NEXT: AddressAlignment: 8<br>
> +# CHECK-NEXT: EntrySize: 0<br>
> +# CHECK-NEXT: }<br>
> +# CHECK: Section {<br>
> +# CHECK: Index:<br>
> +# CHECK: Name: .common.excl<br>
> +# CHECK-NEXT: Type: SHT_NOBITS<br>
> +# CHECK-NEXT: Flags [<br>
> +# CHECK-NEXT: SHF_ALLOC<br>
> +# CHECK-NEXT: SHF_WRITE<br>
> +# CHECK-NEXT: ]<br>
> +# CHECK-NEXT: Address: 0x20<br>
> +# CHECK-NEXT: Offset: 0x<br>
> +# CHECK-NEXT: Size: 48<br>
> +# CHECK-NEXT: Link: 0<br>
> +# CHECK-NEXT: Info: 0<br>
> +# CHECK-NEXT: AddressAlignment: 16<br>
> +# CHECK-NEXT: EntrySize: 0<br>
> +# CHECK-NEXT: }<br>
> +# CHECK: Symbol {<br>
> +# CHECK: Name: common_multiple<br>
> +# CHECK-NEXT: Value: 0x20<br>
> +# CHECK-NEXT: Size: 32<br>
> +# CHECK-NEXT: Binding: Global<br>
> +# CHECK-NEXT: Type: Object<br>
> +# CHECK-NEXT: Other: 0<br>
> +# CHECK-NEXT: Section: .common.excl<br>
> +# CHECK-NEXT: }<br>
> +# CHECK: Symbol {<br>
> +# CHECK: Name: common_uniq_0<br>
> +# CHECK-NEXT: Value: 0x8<br>
> +# CHECK-NEXT: Size: 4<br>
> +# CHECK-NEXT: Binding: Global<br>
> +# CHECK-NEXT: Type: Object<br>
> +# CHECK-NEXT: Other: 0<br>
> +# CHECK-NEXT: Section: .common.incl<br>
> +# CHECK-NEXT: }<br>
> +# CHECK: Symbol {<br>
> +# CHECK: Name: common_uniq_1<br>
> +# CHECK-NEXT: Value: 0x10<br>
> +# CHECK-NEXT: Size: 8<br>
> +# CHECK-NEXT: Binding: Global<br>
> +# CHECK-NEXT: Type: Object<br>
> +# CHECK-NEXT: Other: 0<br>
> +# CHECK-NEXT: Section: .common.incl<br>
> +# CHECK-NEXT: }<br>
> +# CHECK: Symbol {<br>
> +# CHECK: Name: common_uniq_2<br>
> +# CHECK-NEXT: Value: 0x40<br>
> +# CHECK-NEXT: Size: 16<br>
> +# CHECK-NEXT: Binding: Global<br>
> +# CHECK-NEXT: Type: Object<br>
> +# CHECK-NEXT: Other: 0<br>
> +# CHECK-NEXT: Section: .common.excl<br>
> +# CHECK-NEXT: }<br>
> +<br>
> +.globl _start<br>
> +_start:<br>
> + jmp _start<br>
> +<br>
> +.comm common_uniq_0,4,4<br>
> +.comm common_multiple,8,8<br>
><br>
> Added: lld/trunk/test/ELF/<wbr>linkerscript/common-filespec.s<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_test_ELF_linkerscript_common-2Dfilespec.s-3Frev-3D312796-26view-3Dauto&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=nQIMrFkM1t_gqODnbXQIOkB-BBcc2v2l4j7arjM9y4k&s=0nWbX2M4RGRI6BW72U7yMwZSQK9ofetuuUCD8Hs--XM&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__llvm.<wbr>org_viewvc_llvm-2Dproject_lld_<wbr>trunk_test_ELF_linkerscript_<wbr>common-2Dfilespec.s-3Frev-<wbr>3D312796-26view-3Dauto&d=<wbr>DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>nQIMrFkM1t_gqODnbXQIOkB-<wbr>BBcc2v2l4j7arjM9y4k&s=<wbr>0nWbX2M4RGRI6BW72U7yMwZSQK9ofe<wbr>tuuUCD8Hs--XM&e=</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/test/ELF/<wbr>linkerscript/common-filespec.s (added)<br>
> +++ lld/trunk/test/ELF/<wbr>linkerscript/common-filespec.s Fri Sep 8 09:22:43 2017<br>
> @@ -0,0 +1,105 @@<br>
> +# REQUIRES: x86<br>
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %tfile0.o<br>
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/common-filespec1.s -o %tfile1.o<br>
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/common-filespec2.s -o %tfile2.o<br>
> +# RUN: echo "SECTIONS { .common_0 : { *file0.o(COMMON) } .common_1 : { *file1.o(COMMON) } .common_2 : { *file2.o(COMMON) } }" > %t.script<br>
> +# RUN: ld.lld -o %t1 --script %t.script %tfile0.o %tfile1.o %tfile2.o<br>
> +# RUN: llvm-readobj -s -t %t1 | FileCheck %s<br>
> +<br>
> +# Make sure all 3 sections are allocated and they have sizes and alignments<br>
> +# corresponding to the commons assigned to them<br>
> +# CHECK: Section {<br>
> +# CHECK: Index:<br>
> +# CHECK: Name: .common_0<br>
> +# CHECK-NEXT: Type: SHT_NOBITS<br>
> +# CHECK-NEXT: Flags [<br>
> +# CHECK-NEXT: SHF_ALLOC<br>
> +# CHECK-NEXT: SHF_WRITE<br>
> +# CHECK-NEXT: ]<br>
> +# CHECK-NEXT: Address: 0x4<br>
> +# CHECK-NEXT: Offset: 0x<br>
> +# CHECK-NEXT: Size: 4<br>
> +# CHECK-NEXT: Link: 0<br>
> +# CHECK-NEXT: Info: 0<br>
> +# CHECK-NEXT: AddressAlignment: 4<br>
> +# CHECK-NEXT: EntrySize: 0<br>
> +# CHECK-NEXT: }<br>
> +# CHECK: Section {<br>
> +# CHECK: Index:<br>
> +# CHECK: Name: .common_1<br>
> +# CHECK-NEXT: Type: SHT_NOBITS<br>
> +# CHECK-NEXT: Flags [<br>
> +# CHECK-NEXT: SHF_ALLOC<br>
> +# CHECK-NEXT: SHF_WRITE<br>
> +# CHECK-NEXT: ]<br>
> +# CHECK-NEXT: Address: 0x8<br>
> +# CHECK-NEXT: Offset: 0x<br>
> +# CHECK-NEXT: Size: 8<br>
> +# CHECK-NEXT: Link: 0<br>
> +# CHECK-NEXT: Info: 0<br>
> +# CHECK-NEXT: AddressAlignment: 8<br>
> +# CHECK-NEXT: EntrySize: 0<br>
> +# CHECK-NEXT: }<br>
> +# CHECK: Section {<br>
> +# CHECK: Index:<br>
> +# CHECK: Name: .common_2<br>
> +# CHECK-NEXT: Type: SHT_NOBITS<br>
> +# CHECK-NEXT: Flags [<br>
> +# CHECK-NEXT: SHF_ALLOC<br>
> +# CHECK-NEXT: SHF_WRITE<br>
> +# CHECK-NEXT: ]<br>
> +# CHECK-NEXT: Address: 0x10<br>
> +# CHECK-NEXT: Offset: 0x<br>
> +# CHECK-NEXT: Size: 48<br>
> +# CHECK-NEXT: Link: 0<br>
> +# CHECK-NEXT: Info: 0<br>
> +# CHECK-NEXT: AddressAlignment: 16<br>
> +# CHECK-NEXT: EntrySize: 0<br>
> +# CHECK-NEXT: }<br>
> +<br>
> +# Commons with unique name in each file must be assigned to that file's section.<br>
> +# For a common with multiple definitions, the largest one wins and it must be<br>
> +# assigned to the section from the file which provided the winning def<br>
> +# CHECK: Symbol {<br>
> +# CHECK: Name: common_multiple<br>
> +# CHECK-NEXT: Value: 0x10<br>
> +# CHECK-NEXT: Size: 32<br>
> +# CHECK-NEXT: Binding: Global<br>
> +# CHECK-NEXT: Type: Object<br>
> +# CHECK-NEXT: Other: 0<br>
> +# CHECK-NEXT: Section: .common_2<br>
> +# CHECK-NEXT: }<br>
> +# CHECK: Symbol {<br>
> +# CHECK: Name: common_uniq_0<br>
> +# CHECK-NEXT: Value: 0x4<br>
> +# CHECK-NEXT: Size: 4<br>
> +# CHECK-NEXT: Binding: Global<br>
> +# CHECK-NEXT: Type: Object<br>
> +# CHECK-NEXT: Other: 0<br>
> +# CHECK-NEXT: Section: .common_0<br>
> +# CHECK-NEXT: }<br>
> +# CHECK: Symbol {<br>
> +# CHECK: Name: common_uniq_1<br>
> +# CHECK-NEXT: Value: 0x8<br>
> +# CHECK-NEXT: Size: 8<br>
> +# CHECK-NEXT: Binding: Global<br>
> +# CHECK-NEXT: Type: Object<br>
> +# CHECK-NEXT: Other: 0<br>
> +# CHECK-NEXT: Section: .common_1<br>
> +# CHECK-NEXT: }<br>
> +# CHECK: Symbol {<br>
> +# CHECK: Name: common_uniq_2<br>
> +# CHECK-NEXT: Value: 0x30<br>
> +# CHECK-NEXT: Size: 16<br>
> +# CHECK-NEXT: Binding: Global<br>
> +# CHECK-NEXT: Type: Object<br>
> +# CHECK-NEXT: Other: 0<br>
> +# CHECK-NEXT: Section: .common_2<br>
> +# CHECK-NEXT: }<br>
> +<br>
> +.globl _start<br>
> +_start:<br>
> + jmp _start<br>
> +<br>
> +.comm common_uniq_0,4,4<br>
> +.comm common_multiple,8,8<br>
><br>
> Modified: lld/trunk/test/ELF/<wbr>linkerscript/common.s<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_test_ELF_linkerscript_common.s-3Frev-3D312796-26r1-3D312795-26r2-3D312796-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=nQIMrFkM1t_gqODnbXQIOkB-BBcc2v2l4j7arjM9y4k&s=vceDSQYVgZInI9HO6kBb02n0VfALTZs8ZmXemo39dYM&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__llvm.<wbr>org_viewvc_llvm-2Dproject_lld_<wbr>trunk_test_ELF_linkerscript_<wbr>common.s-3Frev-3D312796-26r1-<wbr>3D312795-26r2-3D312796-26view-<wbr>3Ddiff&d=DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>nQIMrFkM1t_gqODnbXQIOkB-<wbr>BBcc2v2l4j7arjM9y4k&s=<wbr>vceDSQYVgZInI9HO6kBb02n0VfALTZ<wbr>s8ZmXemo39dYM&e=</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/test/ELF/<wbr>linkerscript/common.s (original)<br>
> +++ lld/trunk/test/ELF/<wbr>linkerscript/common.s Fri Sep 8 09:22:43 2017<br>
> @@ -4,8 +4,6 @@<br>
> # RUN: ld.lld -o %t1 --script %t.script %t<br>
> # RUN: llvm-readobj -s -t %t1 | FileCheck %s<br>
><br>
> -# q2 alignment is greater than q1, so it should have smaller offset<br>
> -# because of sorting<br>
> # CHECK: Section {<br>
> # CHECK: Index:<br>
> # CHECK: Name: .common<br>
> @@ -16,7 +14,7 @@<br>
> # CHECK-NEXT: ]<br>
> # CHECK-NEXT: Address: 0x200<br>
> # CHECK-NEXT: Offset: 0x<br>
> -# CHECK-NEXT: Size: 256<br>
> +# CHECK-NEXT: Size: 384<br>
> # CHECK-NEXT: Link: 0<br>
> # CHECK-NEXT: Info: 0<br>
> # CHECK-NEXT: AddressAlignment: 256<br>
> @@ -24,7 +22,7 @@<br>
> # CHECK-NEXT: }<br>
> # CHECK: Symbol {<br>
> # CHECK: Name: q1<br>
> -# CHECK-NEXT: Value: 0x280<br>
> +# CHECK-NEXT: Value: 0x200<br>
> # CHECK-NEXT: Size: 128<br>
> # CHECK-NEXT: Binding: Global<br>
> # CHECK-NEXT: Type: Object<br>
> @@ -33,7 +31,7 @@<br>
> # CHECK-NEXT: }<br>
> # CHECK-NEXT: Symbol {<br>
> # CHECK-NEXT: Name: q2<br>
> -# CHECK-NEXT: Value: 0x200<br>
> +# CHECK-NEXT: Value: 0x300<br>
> # CHECK-NEXT: Size: 128<br>
> # CHECK-NEXT: Binding: Global<br>
> # CHECK-NEXT: Type: Object<br>
><br>
> Modified: lld/trunk/test/ELF/<wbr>linkerscript/discard-section-<wbr>err.s<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_test_ELF_linkerscript_discard-2Dsection-2Derr.s-3Frev-3D312796-26r1-3D312795-26r2-3D312796-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=nQIMrFkM1t_gqODnbXQIOkB-BBcc2v2l4j7arjM9y4k&s=MXuje1LylNbUM26IDwE5EEYRU5bBZe69uXFDKmzKh4g&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__llvm.<wbr>org_viewvc_llvm-2Dproject_lld_<wbr>trunk_test_ELF_linkerscript_<wbr>discard-2Dsection-2Derr.s-<wbr>3Frev-3D312796-26r1-3D312795-<wbr>26r2-3D312796-26view-3Ddiff&d=<wbr>DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>nQIMrFkM1t_gqODnbXQIOkB-<wbr>BBcc2v2l4j7arjM9y4k&s=<wbr>MXuje1LylNbUM26IDwE5EEYRU5bBZe<wbr>69uXFDKmzKh4g&e=</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/test/ELF/<wbr>linkerscript/discard-section-<wbr>err.s (original)<br>
> +++ lld/trunk/test/ELF/<wbr>linkerscript/discard-section-<wbr>err.s Fri Sep 8 09:22:43 2017<br>
> @@ -22,9 +22,4 @@<br>
> # RUN: FileCheck -check-prefix=DYNSTR %s<br>
> # DYNSTR: discarding .dynstr section is not allowed<br>
><br>
> -# RUN: echo "SECTIONS { /DISCARD/ : { *(COMMON) } }" > %t.script<br>
> -# RUN: not ld.lld -pie -o %t --script %t.script %t.o 2>&1 | \<br>
> -# RUN: FileCheck -check-prefix=COMMON %s<br>
> -# COMMON: discarding COMMON section is not allowed<br>
> -<br>
> .comm foo,4,4<br>
><br>
> Modified: lld/trunk/test/ELF/map-file.s<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_test_ELF_map-2Dfile.s-3Frev-3D312796-26r1-3D312795-26r2-3D312796-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=nQIMrFkM1t_gqODnbXQIOkB-BBcc2v2l4j7arjM9y4k&s=0Y0YxzC27SE0tTpInsY5fAZExRhv6WOmWe4YPF4EVhY&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__llvm.<wbr>org_viewvc_llvm-2Dproject_lld_<wbr>trunk_test_ELF_map-2Dfile.s-<wbr>3Frev-3D312796-26r1-3D312795-<wbr>26r2-3D312796-26view-3Ddiff&d=<wbr>DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>nQIMrFkM1t_gqODnbXQIOkB-<wbr>BBcc2v2l4j7arjM9y4k&s=<wbr>0Y0YxzC27SE0tTpInsY5fAZExRhv6W<wbr>OmWe4YPF4EVhY&e=</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/test/ELF/map-file.s (original)<br>
> +++ lld/trunk/test/ELF/map-file.s Fri Sep 8 09:22:43 2017<br>
> @@ -47,7 +47,7 @@ labs = 0x1AB5<br>
> // CHECK-NEXT: 0000000000201014 0000000000000001 4 {{.*}}{{/|\\}}map-file.s.tmp4.<wbr>a(map-file.s.tmp4.o):(.text)<br>
> // CHECK-NEXT: 0000000000201014 0000000000000000 0 baz<br>
> // CHECK-NEXT: 0000000000202000 0000000000000004 16 .bss<br>
> -// CHECK-NEXT: 0000000000202000 0000000000000004 16 <internal>:(COMMON)<br>
> +// CHECK-NEXT: 0000000000202000 0000000000000004 16 {{.*}}{{/|\\}}map-file.s.tmp1.<wbr>o:(COMMON)<br>
> // CHECK-NEXT: 0000000000202000 0000000000000004 0 common<br>
> // CHECK-NEXT: 0000000000000000 0000000000000008 1 .comment<br>
> // CHECK-NEXT: 0000000000000000 0000000000000008 1 <internal>:(.comment)<br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
> <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_llvm-2Dcommits&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=nQIMrFkM1t_gqODnbXQIOkB-BBcc2v2l4j7arjM9y4k&s=WT8EYeg7stKLcN9t6TUCBTYRJqw9w1KPiCJ8SkTI_nU&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__lists.<wbr>llvm.org_cgi-2Dbin_mailman_<wbr>listinfo_llvm-2Dcommits&d=<wbr>DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>nQIMrFkM1t_gqODnbXQIOkB-<wbr>BBcc2v2l4j7arjM9y4k&s=<wbr>WT8EYeg7stKLcN9t6TUCBTYRJqw9w1<wbr>KPiCJ8SkTI_nU&e=</a><br>
><br>
<br>
<br>
</div></div></blockquote></div><br></div></div>