summaryrefslogtreecommitdiff
path: root/lld/ELF/LinkerScript.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2017-01-05 14:20:35 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2017-01-05 14:20:35 +0000
commit337139830e14dacd3b511cc180475ec277638a09 (patch)
treef4059dee0ef1a026b85d210ff0c10fd4dfb6ef97 /lld/ELF/LinkerScript.cpp
parent23599ba7940d9891ed5eb982aaaed116f97aea74 (diff)
Change which input sections we concatenate
After Mark's patch I was wondering what was the rationale for the ELF spec requiring us to merge only sections with matching flags and types. I tried emailing https://groups.google.com/forum/#!forum/generic-abi, but looks like my emails are not being posted (the list is probably moderated). I emailed Cary Coutant instead. Cary pointed out that the section was a late addition and didn't got the scrutiny it deserved. Given that and the problems found by implementing the letter of the standard, I propose changing lld to merge all sections with the same name and issue errors if the types or some critical flags are different. This should allow an unmodified firefox linked with lld to run. This also merges some code with the linkerscript path. llvm-svn: 291107
Diffstat (limited to 'lld/ELF/LinkerScript.cpp')
-rw-r--r--lld/ELF/LinkerScript.cpp32
1 files changed, 1 insertions, 31 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 5057b57a4a54..ccc1059949db 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -264,42 +264,12 @@ LinkerScript<ELFT>::createInputSectionList(OutputSectionCommand &OutCmd) {
}
template <class ELFT>
-static SectionKey<ELFT::Is64Bits> createKey(InputSectionBase<ELFT> *C,
- StringRef OutsecName) {
- // When using linker script the merge rules are different.
- // Unfortunately, linker scripts are name based. This means that expressions
- // like *(.foo*) can refer to multiple input sections that would normally be
- // placed in different output sections. We cannot put them in different
- // output sections or we would produce wrong results for
- // start = .; *(.foo.*) end = .; *(.bar)
- // and a mapping of .foo1 and .bar1 to one section and .foo2 and .bar2 to
- // another. The problem is that there is no way to layout those output
- // sections such that the .foo sections are the only thing between the
- // start and end symbols.
-
- // An extra annoyance is that we cannot simply disable merging of the contents
- // of SHF_MERGE sections, but our implementation requires one output section
- // per "kind" (string or not, which size/aligment).
- // Fortunately, creating symbols in the middle of a merge section is not
- // supported by bfd or gold, so we can just create multiple section in that
- // case.
- typedef typename ELFT::uint uintX_t;
- uintX_t Flags = C->Flags & (SHF_MERGE | SHF_STRINGS);
-
- uintX_t Alignment = 0;
- if (isa<MergeInputSection<ELFT>>(C))
- Alignment = std::max<uintX_t>(C->Alignment, C->Entsize);
-
- return SectionKey<ELFT::Is64Bits>{OutsecName, /*Type*/ 0, Flags, Alignment};
-}
-
-template <class ELFT>
void LinkerScript<ELFT>::addSection(OutputSectionFactory<ELFT> &Factory,
InputSectionBase<ELFT> *Sec,
StringRef Name) {
OutputSectionBase *OutSec;
bool IsNew;
- std::tie(OutSec, IsNew) = Factory.create(createKey(Sec, Name), Sec);
+ std::tie(OutSec, IsNew) = Factory.create(Sec, Name);
if (IsNew)
OutputSections->push_back(OutSec);
OutSec->addSection(Sec);