/* ehopt.c--optimize gcc exception frame information.
- Copyright 1998, 2000, 2001, 2003, 2005, 2007, 2008
- Free Software Foundation, Inc.
+ Copyright (C) 1998-2016 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
ELF, since the exception frame information is always in a format
derived from DWARF. */
-#include "elf/dwarf2.h"
+#include "dwarf2.h"
/* Try to optimize gcc 2.8 exception frame information.
/* First make sure that the CIE Identifier Tag is 0/-1. */
- if (strcmp (segment_name (now_seg), ".debug_frame") == 0)
+ if (strncmp (segment_name (now_seg), ".debug_frame", 12) == 0)
CIE_id = (char)0xff;
else
CIE_id = 0;
return 1;
}
+enum frame_state
+{
+ state_idle,
+ state_saw_size,
+ state_saw_cie_offset,
+ state_saw_pc_begin,
+ state_seeing_aug_size,
+ state_skipping_aug,
+ state_wait_loc4,
+ state_saw_loc4,
+ state_error,
+};
+
/* This function is called from emit_expr. It looks for cases which
we can optimize.
{
struct frame_data
{
- enum frame_state
- {
- state_idle,
- state_saw_size,
- state_saw_cie_offset,
- state_saw_pc_begin,
- state_seeing_aug_size,
- state_skipping_aug,
- state_wait_loc4,
- state_saw_loc4,
- state_error,
- } state;
+ enum frame_state state;
int cie_info_ok;
struct cie_info cie_info;
#endif
/* Select the proper section data. */
- if (strcmp (segment_name (now_seg), ".eh_frame") == 0)
+ if (strncmp (segment_name (now_seg), ".eh_frame", 9) == 0
+ && segment_name (now_seg)[9] != '_')
d = &eh_frame_data;
- else if (strcmp (segment_name (now_seg), ".debug_frame") == 0)
+ else if (strncmp (segment_name (now_seg), ".debug_frame", 12) == 0)
d = &debug_frame_data;
else
return 0;
case state_saw_size:
case state_saw_cie_offset:
/* Assume whatever form it appears in, it appears atomically. */
- d->state += 1;
+ d->state = (enum frame_state) (d->state + 1);
break;
case state_saw_pc_begin:
diff = resolve_symbol_value (frag->fr_symbol);
- assert (ca > 0);
+ gas_assert (ca > 0);
diff /= ca;
if (diff < 0x40)
ret = 0;
diff = resolve_symbol_value (frag->fr_symbol);
ca = frag->fr_subtype >> 3;
- assert (ca > 0);
+ gas_assert (ca > 0);
diff /= ca;
switch (frag->fr_subtype & 7)
{
case 0:
- assert (diff < 0x40);
+ gas_assert (diff < 0x40);
loc4_frag->fr_literal[loc4_fix] = DW_CFA_advance_loc | diff;
break;
case 1:
- assert (diff < 0x100);
+ gas_assert (diff < 0x100);
loc4_frag->fr_literal[loc4_fix] = DW_CFA_advance_loc1;
frag->fr_literal[frag->fr_fix] = diff;
break;
case 2:
- assert (diff < 0x10000);
+ gas_assert (diff < 0x10000);
loc4_frag->fr_literal[loc4_fix] = DW_CFA_advance_loc2;
md_number_to_chars (frag->fr_literal + frag->fr_fix, diff, 2);
break;