From 220cae7a832f2ece86a99c335b57b297f7d22c90 Mon Sep 17 00:00:00 2001 From: Khomutov Nikita Date: Fri, 12 Apr 2024 06:19:27 +0300 Subject: [PATCH] [ADLT] add assert on ph-indexes shifting Calling removeEmptyPTLoad may shift generated program header indexes prepared for .adlt section. The case if optimization applied requires another implementation of extracting program header indexes and not supported by the moment. Signed-off-by: Khomutov Nikita Change-Id: I11f3a43b5fe88124b60bdb36ef1e8fbfc74a2951 --- lld/ELF/Writer.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 79de07611662..3b176ab56020 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -116,6 +116,11 @@ static void removeEmptyPTLoad(SmallVector &phdrs) { for (OutputSection *sec : outputSections) if (removed.count(sec->ptLoad)) sec->ptLoad = nullptr; + + if (config->adlt) { + assert(it == phdrs.end() && "adlt: ph-index in .adlt invalid due to shift"); + } + phdrs.erase(it, phdrs.end()); } -- Gitee