From patchwork Fri Mar 10 04:15:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 67202 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp676468wrd; Thu, 9 Mar 2023 20:15:37 -0800 (PST) X-Google-Smtp-Source: AK7set/mQYaDIcDC1jlDae0RsaaZk94M3Izzy5Lh2uTgd/D6k6JQFmz0fZDrtMMDvxf2LsX1xFqU X-Received: by 2002:a17:907:a2cf:b0:884:c45f:1c04 with SMTP id re15-20020a170907a2cf00b00884c45f1c04mr25175660ejc.2.1678421737144; Thu, 09 Mar 2023 20:15:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678421737; cv=none; d=google.com; s=arc-20160816; b=CreRxLIt/FOmT+Lyfh4BnThEXR9Xv3baR+yxJmP+YzZ6tmDi+V6VNWMTeyQOA7PW/Y 7LnOKZsacWZgJXE2dUfVzLGofWLaBP6wiXaZdlsKd8b27JL8L4ajoV1ZzCllxZFNWeVL G0/h7/MgWtmly5UZQOB2KlDtMI/gcuYfdZ63uIm4ECFH/2JYMPoFbtJzTUCiD676aLmg RgyHZaJyisYuiv9bk8rE9qd6hDhy14O6ioWzupl45oKtG3/ixvJtPE1gFeiuHAWgpJKn 5FjtPJHPzUzIpOeHITxtO0mfptide4o8U/o+GPePXL6U3b15Z7bJ9EPppgt3kKD5KKsU 4IXw== 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=4d4ZzpAW3rXkXLdEfBmdU8ftdeaJshP6NixQDsKvV34=; b=ZiNSm9zOSo16njoNZyfz/0zofbi02WvQiMmQNPO9rI5CzshBQ8BPBakIOzvWSkDy18 ehgnCxeR35WZ8ju3eHIMh38Ev9redIW6YyVsZZmg+7rBUjOBA/2CFMuuTabO+9DNh83Q 1i6Spj+vn5IVH8Dh4ifucRMX5ASlyHXKgQ6YUwMRNKQkRaTJqv2YGhJ27xqQ67y1mJEN /WBY0bemPD4Xd8DJiFJJ98Jp/9jaQ1d+PhytfkTLQlw961cvJG27kzy52jKnuowKl8WZ pAVOXDj92TU9SquTikN1nXIKwkQZ/e2X8+TTsKrUojzAx2KEo4JqX2v68GA8KroZ0Ddk +PsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=XnPn6wCD; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ia21-20020a170907a07500b008dd3a4b3ef9si661027ejc.299.2023.03.09.20.15.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 20:15:37 -0800 (PST) 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=XnPn6wCD; 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 259EA3858289 for ; Fri, 10 Mar 2023 04:15:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 259EA3858289 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1678421736; bh=4d4ZzpAW3rXkXLdEfBmdU8ftdeaJshP6NixQDsKvV34=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=XnPn6wCDZzt03AqFKNtS6JToIM8je586JMSr5WORyFcOklZugyO0LwX3VRL+6Z3Hu r5kL/8HOOUMwPjBjlGFg1zovGAjFxFx8elaLuMZwpyGMI5/xrqadypMr7TMt/eD3Ro KhTkkQyKpdEuAyUUhN51+R7Teyktm6VDcdT2IEa8= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id B7F1138582A1 for ; Fri, 10 Mar 2023 04:15:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B7F1138582A1 Received: by mail-pf1-x430.google.com with SMTP id y10so2868373pfi.8 for ; Thu, 09 Mar 2023 20:15:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678421726; 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=4d4ZzpAW3rXkXLdEfBmdU8ftdeaJshP6NixQDsKvV34=; b=dB/VVLehGjcg9fkXyHhxMKhFQXE3tEKB1LSMD+oVP6Tl83tRayodDE9VN11uKJORdQ /9AYdvUuwPP3sdt3ncA8QBvN3ilJLQcuPiEoiLeuCVCcY/dwDzUf8190bySSuxa5+tR3 CWs/aMKl9JKcVZk+06THeWXUzeAYGAWbK9Rm1x4csgt5t1Axpg+EJZB1wqVq0gMu9mvT TWFZOk8YDty7REf3QWchCr8cml1g/3S5B78ahl2uhTnP4XEBWHGGv1b5+zZHqeYiZMyA Xtb7fUbrNpdYxe4oE2aW6G3atO/MrByKvTEiG4vvG0/gafZdXtIY49FqKYJ8RoLoT+Fl H+qQ== X-Gm-Message-State: AO0yUKWET8nWHoodNdWW7HlM5T6QzMbx2laKq+c5KcZ9NYW09nak5A42 1db/2IbK/HqoN05VXWQNaDOBT5W8iTg= X-Received: by 2002:aa7:9418:0:b0:5cd:d766:8a26 with SMTP id x24-20020aa79418000000b005cdd7668a26mr20614735pfo.8.1678421726575; Thu, 09 Mar 2023 20:15:26 -0800 (PST) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:4d08:cebd:d73f:b794]) by smtp.gmail.com with ESMTPSA id a22-20020a62bd16000000b00593e84f2d08sm357971pff.52.2023.03.09.20.15.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 20:15:26 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id C784F1142C73; Fri, 10 Mar 2023 14:45:23 +1030 (ACDT) Date: Fri, 10 Mar 2023 14:45:23 +1030 To: binutils@sourceware.org Subject: eh static data Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3034.5 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?1759952751533809915?= X-GMAIL-MSGID: =?utf-8?q?1759952751533809915?= Fix another case of oss-fuzz tripping over gas static state, ie. starting over testing another input file with rubbish left uncleared in bss. size_end_sym pointed at garbage. * ehopt.c (get_cie_info): Delete forward declaration. (struct frame_data): Move to file scope. (frame): New static, packaged.. (check_eh_frame): ..eh_frame_data and debug_frame_data. (eh_begin): New function. * as.c (gas_init): Call eh_begin. * as.h (eh_begin): Declare. diff --git a/gas/as.c b/gas/as.c index 62f32fc865a..a18438c2542 100644 --- a/gas/as.c +++ b/gas/as.c @@ -1328,6 +1328,7 @@ gas_init (void) read_begin (); input_scrub_begin (); expr_begin (); + eh_begin (); int macro_strip_at = 0; #ifdef TC_I960 diff --git a/gas/as.h b/gas/as.h index 4c5fa9ecf7d..4d3a71410ff 100644 --- a/gas/as.h +++ b/gas/as.h @@ -538,6 +538,7 @@ int check_eh_frame (struct expressionS *, unsigned int *); int eh_frame_estimate_size_before_relax (fragS *); int eh_frame_relax_frag (fragS *); void eh_frame_convert_frag (fragS *); +void eh_begin (void); int generic_force_reloc (struct fix *); /* SFrame FRE optimization. */ diff --git a/gas/ehopt.c b/gas/ehopt.c index 268554d89a7..feea61b9223 100644 --- a/gas/ehopt.c +++ b/gas/ehopt.c @@ -94,8 +94,6 @@ struct cie_info int z_augmentation; }; -static int get_cie_info (struct cie_info *); - /* Extract information from the CIE. */ static int @@ -238,6 +236,27 @@ enum frame_state state_error, }; +struct frame_data +{ + enum frame_state state; + + int cie_info_ok; + struct cie_info cie_info; + + symbolS *size_end_sym; + fragS *loc4_frag; + int loc4_fix; + + int aug_size; + int aug_shift; +}; + +static struct eh_state +{ + struct frame_data eh_data; + struct frame_data debug_data; +} frame; + /* This function is called from emit_expr. It looks for cases which we can optimize. @@ -254,23 +273,6 @@ enum frame_state int check_eh_frame (expressionS *exp, unsigned int *pnbytes) { - struct frame_data - { - enum frame_state state; - - int cie_info_ok; - struct cie_info cie_info; - - symbolS *size_end_sym; - fragS *loc4_frag; - int loc4_fix; - - int aug_size; - int aug_shift; - }; - - static struct frame_data eh_frame_data; - static struct frame_data debug_frame_data; struct frame_data *d; /* Don't optimize. */ @@ -285,9 +287,9 @@ check_eh_frame (expressionS *exp, unsigned int *pnbytes) /* Select the proper section data. */ if (startswith (segment_name (now_seg), ".eh_frame") && segment_name (now_seg)[9] != '_') - d = &eh_frame_data; + d = &frame.eh_data; else if (startswith (segment_name (now_seg), ".debug_frame")) - d = &debug_frame_data; + d = &frame.debug_data; else return 0; @@ -570,3 +572,9 @@ eh_frame_convert_frag (fragS *frag) frag->fr_subtype = 0; frag->fr_offset = 0; } + +void +eh_begin (void) +{ + memset (&frame, 0, sizeof (frame)); +}