From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by sourceware.org (Postfix) with ESMTPS id 84BA93858C52 for ; Wed, 18 Jan 2023 15:30:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 84BA93858C52 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-il1-x133.google.com with SMTP id h26so17153025ila.11 for ; Wed, 18 Jan 2023 07:30:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/ejTeA2Mg3iDOkI+FldyDxfHtuLl+KoJPkJ5mamF1QY=; b=J5BK/SRLsUXxqSs84LYmD0NhB5kZHbOJ+biMrNChY20fy/z3cxalU/6+e3ebTZL833 dAPExW4cbZkOsReTOkR0tP7VOJipGU9enGSOzuDsi+zMNyc9n1r23HOtEKZ88jlBQ5Wb 4ajZ8kUMAOrANuypXwOvROgLH8R2T+b92oGP3+F6M7kFaVoJNNXtmbeVPkPGv1tjiPcU KXDAcwjxdP9gTAlM2zGhEsyK75tN46Qj4Km/3TXQr5MsfUKFpVdpcZZEssS5MShxdJMe vnczhUA0ZGWqw7fI3gK+nds/foTKKuoNzB2nR8TaLsWKzSnOpDOrJKiK9OsRiyw0bsMX azrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/ejTeA2Mg3iDOkI+FldyDxfHtuLl+KoJPkJ5mamF1QY=; b=7bZTFBtbkKUD4rr8gRgyf9jmdtS6i7WDwgO8RWz57hxSNw8hMF3a/Pcp2Dnrxo5Q69 J1DnIS8C78stTOCM/+DhsEXiYEFVsZUYsFy7GCh5lBXs3smSOCHPgW2fi5bJz3y2GBOC 3QHVb1aVc0Ln/GT2i9rCBjSVSssxQpL2pIvdVdVtsBp6tNOGdIcdcWuJHxfeq2GADGIJ N5fdNBdKFw7a8+1NlSlukKYpVhWcaRT3zf0/O8ePu5CJmJxQiKGr54Ai9PNCI/CP59VA uqo4i/nncmWyprMPE+QdLO6yDcj6JVQPzv4vrq/aZCCPuHehrtHEXzLc8rVHG3vMvE6l MhTQ== X-Gm-Message-State: AFqh2krvUAdaEHPJngTkBUriRNFUdogkHsk/EA6lmfCWJb2rDMRZW68H D+mR0ymb8watCOdZlkRcl/+c7+nsytNNSvL2 X-Google-Smtp-Source: AMrXdXvjtMW3qM7f9nIlFUOh1qSh6c/V8UAtFN7Ao7Zo4/HVYj8Hbhdznq5i2KI3RFqAnD6XOopqzg== X-Received: by 2002:a92:c84e:0:b0:30d:8f90:7ac4 with SMTP id b14-20020a92c84e000000b0030d8f907ac4mr6145972ilq.1.1674055836759; Wed, 18 Jan 2023 07:30:36 -0800 (PST) Received: from localhost.localdomain (97-122-76-186.hlrn.qwest.net. [97.122.76.186]) by smtp.gmail.com with ESMTPSA id m4-20020a056e020de400b0030bf2476c5fsm10106502ilj.25.2023.01.18.07.30.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 07:30:36 -0800 (PST) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 1/6] Use default section indexes in fixup_symbol_section Date: Wed, 18 Jan 2023 08:30:20 -0700 Message-Id: <20230118153025.342512-2-tromey@adacore.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230118153025.342512-1-tromey@adacore.com> References: <20230118153025.342512-1-tromey@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: If fixup_section does not find a matching section, it arbitrarily chooses the first one. However, it seems better to make this default depend on the type of the symbol -- i.e., default data symbols to .data and text symbols to .text. I've also made fixup_section static, as it only has one caller. --- gdb/symtab.c | 16 ++++++++++++---- gdb/symtab.h | 3 --- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/gdb/symtab.c b/gdb/symtab.c index b3445133c8c..fe247ab70eb 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -1704,9 +1704,10 @@ symtab_free_objfile_observer (struct objfile *objfile) /* Debug symbols usually don't have section information. We need to dig that out of the minimal symbols and stash that in the debug symbol. */ -void +static void fixup_section (struct general_symbol_info *ginfo, - CORE_ADDR addr, struct objfile *objfile) + CORE_ADDR addr, struct objfile *objfile, + int default_section) { struct minimal_symbol *msym; @@ -1757,7 +1758,7 @@ fixup_section (struct general_symbol_info *ginfo, a search of the section table. */ struct obj_section *s; - int fallback = -1; + int fallback = default_section; ALL_OBJFILE_OSECTIONS (objfile, s) { @@ -1808,9 +1809,16 @@ fixup_symbol_section (struct symbol *sym, struct objfile *objfile) /* We should have an objfile by now. */ gdb_assert (objfile); + /* Note that if this ends up as -1, fixup_section will handle that + reasonably well. So, it's fine to use the objfile's section + index without doing the check that is done by the wrapper macros + like SECT_OFF_TEXT. */ + int default_section = objfile->sect_index_text; switch (sym->aclass ()) { case LOC_STATIC: + default_section = objfile->sect_index_data; + /* FALLTHROUGH. */ case LOC_LABEL: addr = sym->value_address (); break; @@ -1824,7 +1832,7 @@ fixup_symbol_section (struct symbol *sym, struct objfile *objfile) return sym; } - fixup_section (sym, addr, objfile); + fixup_section (sym, addr, objfile, default_section); return sym; } diff --git a/gdb/symtab.h b/gdb/symtab.h index ae3a81991df..ac3f6391dc3 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -2607,9 +2607,6 @@ extern struct block_symbol compiler (armcc). */ bool producer_is_realview (const char *producer); -void fixup_section (struct general_symbol_info *ginfo, - CORE_ADDR addr, struct objfile *objfile); - extern unsigned int symtab_create_debug; /* Print a "symtab-create" debug statement. */ -- 2.38.1