From 34b2e8029b52396f336b9fc8873f841aa7425670 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Sat, 13 Mar 2021 18:24:03 +0900 Subject: [PATCH] wip --- input_sections.cc | 10 ++++++---- mold.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/input_sections.cc b/input_sections.cc index 81aec67f..1cfb04f7 100644 --- a/input_sections.cc +++ b/input_sections.cc @@ -576,8 +576,10 @@ void InputSection::scan_relocations() { } void InputSection::kill() { - is_alive = false; - for (FdeRecord &fde : fdes) - fde.is_alive = false; - file.sections[section_idx] = nullptr; + if (is_alive.exchange(false)) { + is_alive = false; + for (FdeRecord &fde : fdes) + fde.is_alive = false; + file.sections[section_idx] = nullptr; + } } diff --git a/mold.h b/mold.h index 1361deb5..b6adf8b3 100644 --- a/mold.h +++ b/mold.h @@ -413,7 +413,7 @@ public: bool is_ehframe = false; // For COMDAT de-duplication and garbage collection - bool is_alive = true; + std::atomic_bool is_alive = true; // For garbage collection std::atomic_bool is_visited = false;