From f9da2fdc78b9418b77eab55f514dbb9c08b78632 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Mon, 25 Sep 2017 05:30:39 +0000 Subject: [PATCH] Do not sort CU vectors. We used to sort and uniquify CU vectors, but looks like CU vectors in .gdb_index sections created by gold are not guaranteed to be sorted. llvm-svn: 314095 --- lld/ELF/SyntheticSections.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index 9294a99..1f8df13 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -1797,16 +1797,17 @@ std::vector> GdbIndexSection::createCuVectors() { Off += Ent.Name.size() + 1; Ret.push_back({}); } - Ret[Sym->CuVectorIndex].push_back((Ent.Type << 24) | Idx); + + // gcc 5.4.1 produces a buggy .debug_gnu_pubnames that contains + // duplicate entries, so we want to dedup them. + std::vector &Vec = Ret[Sym->CuVectorIndex]; + uint32_t Val = (Ent.Type << 24) | Idx; + if (Vec.empty() || Vec.back() != Val) + Vec.push_back(Val); } Idx += Chunk.CompilationUnits.size(); } - for (std::vector &V : Ret) { - std::sort(V.begin(), V.end()); - V.erase(std::unique(V.begin(), V.end()), V.end()); - } - StringPoolSize = Off; return Ret; } -- 2.7.4