From: Alan Modra <amodra@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] eh static data
Date: Fri, 10 Mar 2023 04:15:58 +0000 (GMT) [thread overview]
Message-ID: <20230310041558.4BA423858025@sourceware.org> (raw)
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4148b4fe9fd15607aad8b082c7b724f355f2da64
commit 4148b4fe9fd15607aad8b082c7b724f355f2da64
Author: Alan Modra <amodra@gmail.com>
Date: Fri Mar 10 10:05:44 2023 +1030
eh static data
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:
---
gas/as.c | 1 +
gas/as.h | 1 +
gas/ehopt.c | 50 +++++++++++++++++++++++++++++---------------------
3 files changed, 31 insertions(+), 21 deletions(-)
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));
+}
reply other threads:[~2023-03-10 4:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230310041558.4BA423858025@sourceware.org \
--to=amodra@sourceware.org \
--cc=bfd-cvs@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).