From 1aaf736d897170af4140643b49a5074b18f82fed Mon Sep 17 00:00:00 2001 From: Denis Protivensky Date: Mon, 15 Jun 2015 08:00:51 +0000 Subject: [LinkerScript] Add matching of output sections to segments Add method to query segments for specified output section name. Return error if the section is assigned to unknown segment. Check matching of sections to segments during layout on the subject of correctness. NOTE: no actual functionality of using custom segments is implemented. Differential Revision: http://reviews.llvm.org/D10359 llvm-svn: 239719 --- lld/lib/ReaderWriter/ELF/TargetLayout.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lld/lib/ReaderWriter/ELF/TargetLayout.cpp') diff --git a/lld/lib/ReaderWriter/ELF/TargetLayout.cpp b/lld/lib/ReaderWriter/ELF/TargetLayout.cpp index 87cbcd5cab5..c0dae207bd6 100644 --- a/lld/lib/ReaderWriter/ELF/TargetLayout.cpp +++ b/lld/lib/ReaderWriter/ELF/TargetLayout.cpp @@ -320,6 +320,7 @@ template void TargetLayout::createOutputSections() { } else { outputSection = new (_allocator.Allocate>()) OutputSection(section->outputSectionName()); + checkOutputSectionSegment(outputSection); _outputSections.push_back(outputSection); outputSectionInsert.first->second = outputSection; } @@ -327,6 +328,17 @@ template void TargetLayout::createOutputSections() { } } +// Check that output section has proper segment set +template +void TargetLayout::checkOutputSectionSegment( + const OutputSection *sec) { + std::vector phdrs; + if (_linkerScriptSema.getPHDRsForOutputSection(sec->name(), phdrs)) { + llvm::report_fatal_error( + "Linker script has wrong segments set for output sections"); + } +} + template uint64_t TargetLayout::getLookupSectionFlags(const OutputSection *os) const { -- cgit v1.2.3