From patchwork Tue Mar 14 02:05:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 69246 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1515388wrd; Mon, 13 Mar 2023 19:06:26 -0700 (PDT) X-Google-Smtp-Source: AK7set+hKnFLWqE87IGpNiE/RrJOYZKq13BbnGevaYn4NDNWrmzIEFwe4+Argpw6tQFpGlnckvNs X-Received: by 2002:a17:906:3e1b:b0:92a:55a1:63cb with SMTP id k27-20020a1709063e1b00b0092a55a163cbmr645548eji.69.1678759586604; Mon, 13 Mar 2023 19:06:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678759586; cv=none; d=google.com; s=arc-20160816; b=wAcHVR04eZw26vxHsgwiLl+X9655xd/rKS5MT/f1Ae/NzkBQ6lpDa37eEUL5Qt5KYL z8u39DPFnGLKzQSfQ8u/5GDYDDsZGOGJLHPcgqAnUmA/z4WNglobPGdGLuyimNifbW0Q bAso7BREW+tWu9ji6wLkZmgUI+1sUKU3OjhJdNlAdQqknTyIC10TeV3wli48ChEd42C7 lp7u5IvszemW5WEOXratDVkHSE8+0ClzMZwFSd/Uxjirj1BiAkJGd30MmW0nbtvCDaWE zR4Wua3uE1NcCahPgImUivBZ/f/TiGd+dGxTZLNb5Bhpvl91xcdpM6uZ6tTrs1pjygAQ NL7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=2XCJeWF5GHu4qss10cfSVyJDinYPehgxhJLnQLDHxWc=; b=v/Q/G999H+wiFgVl3v7fR810mQFAk72ng7cQwB5DbO3gcq8NWfsl4+sw7dBGR2OvhT kEMLIUCCbmNHQ2lEdKJTFI2Q5u4stRY4imGAIrtWj5fbnK0rX4Ic4Lj9hqF19acefkoJ kGVVXJHc6/+EzU79K4085TXpUugqHRfE0NOyOdcBUVkny4EYe/0VdFXkGDK3EPW9Ece4 wK0POhQvq9+y7yVVmFfc4UaF/Fr7PYh9ic1TrWspDsGc8erKHRCPGJCfPc3ptVLpwu2B s3bDfZG0UCLmCZ8cPFiM0z50meAdz0PksJKDCzEP8/jfalAdVaTgr5QMVmNf4jmPMRoM ecTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=gQrtcWgk; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id n15-20020a1709065e0f00b008bedd21abe0si1160361eju.567.2023.03.13.19.06.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Mar 2023 19:06:26 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=gQrtcWgk; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0F0AC3858C60 for ; Tue, 14 Mar 2023 02:06:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0F0AC3858C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1678759563; bh=2XCJeWF5GHu4qss10cfSVyJDinYPehgxhJLnQLDHxWc=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=gQrtcWgkrkYXMTtS7LkAOMumKs9orV6cY1OHTpxWkJZcCwuG6ButL6ByES+Cf6P5C pgyndy1MiRaXtl5oQpyLAm5WUZHvOzWiBdhRUCBQJ5kVSc+80gycw3w8AwTEXTziYN Kvya2HKgmcyJRso7C6tGk2rKQnzy/jSTS1mXSZp4= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by sourceware.org (Postfix) with ESMTPS id 6EE23385B52F for ; Tue, 14 Mar 2023 02:05:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6EE23385B52F Received: by mail-pl1-x630.google.com with SMTP id ix20so8537860plb.3 for ; Mon, 13 Mar 2023 19:05:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678759503; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2XCJeWF5GHu4qss10cfSVyJDinYPehgxhJLnQLDHxWc=; b=EmGKJDKAKe5CCrLmAkWlX55I8+o+sJyYWBu8gdTI4+BaW0CXYMTGItrfU0vDPyTJwH intsObucMZQtN1jHo+cDMuXdJ7DtnNKZqnhulKkUyStvAs50JHMn2cSesBa97bU8SyaU 5hvu2JQc4x3V+VDDqW1uLJgLMrG2z3Bxo1CxxgfkR462ztdwbuw5vknIUU3W6Uca9bo0 H+WH8KivPgNd+zfalAkpRevBL0hnmuB3DxZQ942y9sWJwxAuPmCfrvoQ+jmrwTSiI4lZ 1dcsMQcD+LVlfSSJD4Ueq2qw7wZBgAm7QMOmdsyAt69LZIJ82ycJA2v67QCFkSAkrVxd YNbw== X-Gm-Message-State: AO0yUKX9zdsK9uECqNCsNb8eA8/nNriIGvn2LOV4VQh+eYFrCtH8UApb ABWpVt7wtqjU2ZNJga0yELX4SKeCAuo= X-Received: by 2002:a17:903:2346:b0:19c:be03:d0ba with SMTP id c6-20020a170903234600b0019cbe03d0bamr45356585plh.18.1678759502768; Mon, 13 Mar 2023 19:05:02 -0700 (PDT) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id ko7-20020a17090307c700b0019b06263bcasm452904plb.247.2023.03.13.19.05.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Mar 2023 19:05:02 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 581AD1142C71; Tue, 14 Mar 2023 12:35:00 +1030 (ACDT) Date: Tue, 14 Mar 2023 12:35:00 +1030 To: binutils@sourceware.org Subject: gas/read.c: init more statics Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3035.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, 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 X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alan Modra via Binutils From: Alan Modra Reply-To: Alan Modra Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760307012265982214?= X-GMAIL-MSGID: =?utf-8?q?1760307012265982214?= * read.c (current_name, current_label, dwarf_file, dwarf_line): Move to file scope. (pobegin): Tidy pop_override_ok. (read_a_source_file): Make last_eol an auto var. (s_reloc): Constify bfd_relocs. (read_begin): Init more variables. diff --git a/gas/read.c b/gas/read.c index 08312ff6d2f..0320d0248e7 100644 --- a/gas/read.c +++ b/gas/read.c @@ -204,8 +204,17 @@ symbolS *mri_common_symbol; may be needed. */ static int mri_pending_align; +/* Record the current function so that we can issue an error message for + misplaced .func,.endfunc, and also so that .endfunc needs no + arguments. */ +static char *current_name; +static char *current_label; + #ifndef NO_LISTING #ifdef OBJ_ELF +static int dwarf_file; +static int dwarf_line; + /* This variable is set to be non-zero if the next string we see might be the name of the source file in DWARF debugging information. See the comment in emit_expr for the format we look for. */ @@ -276,6 +285,35 @@ read_begin (void) if (flag_mri) lex_type['?'] = 3; stabs_begin (); + +#ifndef WORKING_DOT_WORD + broken_words = NULL; + new_broken_words = 0; +#endif + + abs_section_offset = 0; + + line_label = NULL; + mri_common_symbol = NULL; + mri_pending_align = 0; + + current_name = NULL; + current_label = NULL; + +#ifndef NO_LISTING +#ifdef OBJ_ELF + dwarf_file = 0; + dwarf_line = -1; + dwarf_file_string = 0; +#endif +#endif + +#ifdef HANDLE_BUNDLE + bundle_align_p2 = 0; + bundle_lock_frag = NULL; + bundle_lock_frchain = NULL; + bundle_lock_depth = 0; +#endif } void @@ -517,7 +555,7 @@ get_absolute_expression (void) return get_absolute_expr (&exp); } -static int pop_override_ok = 0; +static int pop_override_ok; static const char *pop_table_name; void @@ -554,6 +592,7 @@ pobegin (void) /* Do the target-specific pseudo ops. */ pop_table_name = "md"; + pop_override_ok = 0; md_pop_insert (); /* Now object specific. Skip any that were in the target table. */ @@ -567,7 +606,6 @@ pobegin (void) /* Now CFI ones. */ pop_table_name = "cfi"; - pop_override_ok = 1; cfi_pop_insert (); } @@ -838,9 +876,8 @@ read_a_source_file (const char *name) #ifndef NO_LISTING /* In order to avoid listing macro expansion lines with labels multiple times, keep track of which line was last issued. */ - static char *last_eol; + char *last_eol = NULL; - last_eol = NULL; #endif while (input_line_pointer < buffer_limit) { @@ -4176,7 +4213,7 @@ s_reloc (int ignore ATTRIBUTE_UNUSED) int c; struct reloc_list *reloc; struct _bfd_rel { const char * name; bfd_reloc_code_real_type code; }; - static struct _bfd_rel bfd_relocs[] = + static const struct _bfd_rel bfd_relocs[] = { { "NONE", BFD_RELOC_NONE }, { "8", BFD_RELOC_8 }, @@ -4326,62 +4363,54 @@ emit_expr_with_reloc (expressionS *exp, /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will appear as a four byte positive constant in the .line section, followed by a 2 byte 0xffff. Look for that case here. */ - { - static int dwarf_line = -1; - - if (strcmp (segment_name (now_seg), ".line") != 0) - dwarf_line = -1; - else if (dwarf_line >= 0 - && nbytes == 2 - && exp->X_op == O_constant - && (exp->X_add_number == -1 || exp->X_add_number == 0xffff)) - listing_source_line ((unsigned int) dwarf_line); - else if (nbytes == 4 - && exp->X_op == O_constant - && exp->X_add_number >= 0) - dwarf_line = exp->X_add_number; - else - dwarf_line = -1; - } + if (strcmp (segment_name (now_seg), ".line") != 0) + dwarf_line = -1; + else if (dwarf_line >= 0 + && nbytes == 2 + && exp->X_op == O_constant + && (exp->X_add_number == -1 || exp->X_add_number == 0xffff)) + listing_source_line ((unsigned int) dwarf_line); + else if (nbytes == 4 + && exp->X_op == O_constant + && exp->X_add_number >= 0) + dwarf_line = exp->X_add_number; + else + dwarf_line = -1; /* When gcc emits DWARF 1 debugging pseudo-ops, a file name will appear as a 2 byte TAG_compile_unit (0x11) followed by a 2 byte AT_sibling (0x12) followed by a four byte address of the sibling followed by a 2 byte AT_name (0x38) followed by the name of the file. We look for that case here. */ - { - static int dwarf_file = 0; - - if (strcmp (segment_name (now_seg), ".debug") != 0) - dwarf_file = 0; - else if (dwarf_file == 0 - && nbytes == 2 - && exp->X_op == O_constant - && exp->X_add_number == 0x11) - dwarf_file = 1; - else if (dwarf_file == 1 - && nbytes == 2 - && exp->X_op == O_constant - && exp->X_add_number == 0x12) - dwarf_file = 2; - else if (dwarf_file == 2 - && nbytes == 4) - dwarf_file = 3; - else if (dwarf_file == 3 - && nbytes == 2 - && exp->X_op == O_constant - && exp->X_add_number == 0x38) - dwarf_file = 4; - else - dwarf_file = 0; - - /* The variable dwarf_file_string tells stringer that the string - may be the name of the source file. */ - if (dwarf_file == 4) - dwarf_file_string = 1; - else - dwarf_file_string = 0; - } + if (strcmp (segment_name (now_seg), ".debug") != 0) + dwarf_file = 0; + else if (dwarf_file == 0 + && nbytes == 2 + && exp->X_op == O_constant + && exp->X_add_number == 0x11) + dwarf_file = 1; + else if (dwarf_file == 1 + && nbytes == 2 + && exp->X_op == O_constant + && exp->X_add_number == 0x12) + dwarf_file = 2; + else if (dwarf_file == 2 + && nbytes == 4) + dwarf_file = 3; + else if (dwarf_file == 3 + && nbytes == 2 + && exp->X_op == O_constant + && exp->X_add_number == 0x38) + dwarf_file = 4; + else + dwarf_file = 0; + + /* The variable dwarf_file_string tells stringer that the string + may be the name of the source file. */ + if (dwarf_file == 4) + dwarf_file_string = 1; + else + dwarf_file_string = 0; #endif #endif @@ -6005,12 +6034,6 @@ s_func (int end_p) static void do_s_func (int end_p, const char *default_prefix) { - /* Record the current function so that we can issue an error message for - misplaced .func,.endfunc, and also so that .endfunc needs no - arguments. */ - static char *current_name; - static char *current_label; - if (end_p) { if (current_name == NULL) @@ -6255,7 +6278,7 @@ find_end_of_line (char *s, int mri_string) return _find_end_of_line (s, mri_string, 0, 0); } -static char *saved_ilp = NULL; +static char *saved_ilp; static char *saved_limit; /* Use BUF as a temporary input pointer for calling other functions in this