x86: tighten extend-to-32bit-address conditions
[binutils-gdb.git] / gas / ehopt.c
index 256932068c8fd2e1e59d86dfa5956e27ff7cfc4f..feea61b92237cf7dbc93c57ae7d3593fb5994d6e 100644 (file)
@@ -1,5 +1,5 @@
 /* ehopt.c--optimize gcc exception frame information.
-   Copyright (C) 1998-2021 Free Software Foundation, Inc.
+   Copyright (C) 1998-2023 Free Software Foundation, Inc.
    Written by Ian Lance Taylor <ian@cygnus.com>.
 
    This file is part of GAS, the GNU Assembler.
@@ -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
@@ -118,7 +116,7 @@ get_cie_info (struct cie_info *info)
 
   /* First make sure that the CIE Identifier Tag is 0/-1.  */
 
-  if (strncmp (segment_name (now_seg), ".debug_frame", 12) == 0)
+  if (startswith (segment_name (now_seg), ".debug_frame"))
     CIE_id = (char)0xff;
   else
     CIE_id = 0;
@@ -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.  */
@@ -283,11 +285,11 @@ check_eh_frame (expressionS *exp, unsigned int *pnbytes)
 #endif
 
   /* Select the proper section data.  */
-  if (strncmp (segment_name (now_seg), ".eh_frame", 9) == 0
+  if (startswith (segment_name (now_seg), ".eh_frame")
       && segment_name (now_seg)[9] != '_')
-    d = &eh_frame_data;
-  else if (strncmp (segment_name (now_seg), ".debug_frame", 12) == 0)
-    d = &debug_frame_data;
+    d = &frame.eh_data;
+  else if (startswith (segment_name (now_seg), ".debug_frame"))
+    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));
+}