From patchwork Tue Aug 17 18:51:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 1517803 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gq0Wn13Khz9sVq for ; Wed, 18 Aug 2021 04:52:20 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1223D393AC2C for ; Tue, 17 Aug 2021 18:52:17 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp001-out.apm-internet.net (smtp001-out.apm-internet.net [85.119.248.222]) by sourceware.org (Postfix) with ESMTPS id 779EE393AC2C for ; Tue, 17 Aug 2021 18:51:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 779EE393AC2C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=sandoe.co.uk Received: (qmail 1285 invoked from network); 17 Aug 2021 18:51:52 -0000 X-APM-Out-ID: 16292263110128 X-APM-Authkey: 257869/1(257869/1) 3 Received: from unknown (HELO ?192.168.1.214?) (81.138.1.83) by smtp001.apm-internet.net with SMTP; 17 Aug 2021 18:51:52 -0000 From: Iain Sandoe Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Subject: [pushed] Darwin: Reset section names table at the end of compile. Message-Id: Date: Tue, 17 Aug 2021 19:51:51 +0100 To: GCC Patches X-Mailer: Apple Mail (2.3445.104.21) X-Spam-Status: No, score=-15.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_COUK, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi, This fixes a fail seen when using JIT on Darwin where we fail to label the start of debug sections properly. This operation is controlled by a vector of tokens that is lazily allocated. For a single use (typical compile) this vector will be reclaimed as GGC. For JIT this is not sufficient since it does not reset the pointer to NULL (and thus we think the the vector is already allocated when a context is reused). The clears the vector and sets the pointer to NULL at the end of object output. tested on x86_64, i686-darwin (and x86_64-linux). pushed to master, thanks Iain Signed-off-by: Iain Sandoe gcc/ChangeLog: * config/darwin.c (darwin_file_end): Reset and reclaim the section names table at the end of compile. --- gcc/config/darwin.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index b160c23ea56..5d1d13c80aa 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -3129,6 +3129,14 @@ darwin_file_end (void) re-arranging data. */ if (!DARWIN_SECTION_ANCHORS || !flag_section_anchors) fprintf (asm_out_file, "\t.subsections_via_symbols\n"); + + /* We rely on this being NULL at the start of compilation; reset it here + so that JIT can reuse a context. */ + if (dwarf_sect_names_table != NULL) + { + dwarf_sect_names_table->truncate (0); + dwarf_sect_names_table = NULL; + } } /* TODO: Add a language hook for identifying if a decl is a vtable. */