From 03ba8f93255055adaf69984c17bcfea3b22340db Mon Sep 17 00:00:00 2001 Message-Id: <03ba8f93255055adaf69984c17bcfea3b22340db.1642970958.git.github@sicherha.de> From: Christoph Erhardt Date: Sun, 23 Jan 2022 21:42:21 +0100 Subject: [PATCH] Fix out-of-bounds error on aarch64 with `_GLIBCXX_ASSERTIONS` enabled While an iterator may point beyond the last element of a `std::span`, a pointer may not. Fixes #298. Signed-off-by: Christoph Erhardt --- elf/arch-arm64.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elf/arch-arm64.cc b/elf/arch-arm64.cc index aba86330..c608ae49 100644 --- a/elf/arch-arm64.cc +++ b/elf/arch-arm64.cc @@ -574,7 +574,7 @@ static void create_thunks(Context &ctx, OutputSection &osec) { thunk.offset = offset; // Scan relocations between B and C to collect symbols that need thunks. - tbb::parallel_for_each(&members[b], &members[c], [&](InputSection *isec) { + tbb::parallel_for_each(members.begin() + b, members.begin() + c, [&](InputSection *isec) { std::span> rels = isec->get_rels(ctx); isec->range_extn.resize(rels.size()); @@ -619,7 +619,7 @@ static void create_thunks(Context &ctx, OutputSection &osec) { } // Scan relocations again to fix symbol offsets in the last thunk. - tbb::parallel_for_each(&members[b], &members[c], [&](InputSection *isec) { + tbb::parallel_for_each(members.begin() + b, members.begin() + c, [&](InputSection *isec) { std::span> rels = isec->get_rels(ctx); for (i64 i = 0; i < rels.size(); i++) { -- 2.34.1