* dw2gencfi.c, dw2gencfi.h: Rewrite from scratch.
* as.c (main): Always call cfi_finish. * config/tc-i386.c (x86_dwarf2_return_column): New. (x86_cie_data_alignment): New. (md_begin): Set them. (tc_x86_cfi_init): Remove. (tc_x86_regname_to_dw2regnum): Fix 32-bit register numbers; return int, not unsigned long; don't as_bad here. (tc_x86_frame_initial_instructions): Streamline; use updated api. * config/tc-i386.h (tc_cfi_init): Remove. (DWARF2_DEFAULT_RETURN_COLUMN): New. (DWARF2_CIE_DATA_ALIGNMENT): New. * gas/cfi/cfi-i386.d: Update for dw2gencfi rewrite. * gas/cfi/cfi-x86_64.d: Likewise. * gas/cfi/cfi-i386-2.d: New. * gas/cfi/cfi-i386-2.s: New.
This commit is contained in:
parent
b7d6ed970a
commit
a4447b9378
|
@ -1,3 +1,19 @@
|
|||
2003-05-27 Richard Henderson <rth@redhat.com>
|
||||
|
||||
* dw2gencfi.c, dw2gencfi.h: Rewrite from scratch.
|
||||
* as.c (main): Always call cfi_finish.
|
||||
* config/tc-i386.c (x86_dwarf2_return_column): New.
|
||||
(x86_cie_data_alignment): New.
|
||||
(md_begin): Set them.
|
||||
(tc_x86_cfi_init): Remove.
|
||||
(tc_x86_regname_to_dw2regnum): Fix 32-bit register numbers;
|
||||
return int, not unsigned long; don't as_bad here.
|
||||
(tc_x86_frame_initial_instructions): Streamline; use
|
||||
updated api.
|
||||
* config/tc-i386.h (tc_cfi_init): Remove.
|
||||
(DWARF2_DEFAULT_RETURN_COLUMN): New.
|
||||
(DWARF2_CIE_DATA_ALIGNMENT): New.
|
||||
|
||||
2003-05-27 Richard Henderson <rth@redhat.com>
|
||||
|
||||
* symbols.c (temp_label_name): New.
|
||||
|
|
4
gas/as.c
4
gas/as.c
|
@ -911,9 +911,9 @@ main (argc, argv)
|
|||
assembly debugging or on behalf of the compiler, emit it now. */
|
||||
dwarf2_finish ();
|
||||
|
||||
#ifdef TARGET_USE_CFIPOP
|
||||
/* If we constructed dwarf2 .eh_frame info, either via .cfi
|
||||
directives from the user or by the backend, emit it now. */
|
||||
cfi_finish ();
|
||||
#endif
|
||||
|
||||
if (seen_at_least_1_file ()
|
||||
&& (flag_always_generate_output || had_errors () == 0))
|
||||
|
|
|
@ -319,6 +319,12 @@ static unsigned int no_cond_jump_promotion = 0;
|
|||
/* Pre-defined "_GLOBAL_OFFSET_TABLE_". */
|
||||
symbolS *GOT_symbol;
|
||||
|
||||
/* The dwarf2 return column, adjusted for 32 or 64 bit. */
|
||||
unsigned int x86_dwarf2_return_column;
|
||||
|
||||
/* The dwarf2 data alignment, adjusted for 32 or 64 bit. */
|
||||
int x86_cie_data_alignment;
|
||||
|
||||
/* Interface to relax_segment.
|
||||
There are 3 major relax states for 386 jump insns because the
|
||||
different types of jumps add different sizes to frags when we're
|
||||
|
@ -987,6 +993,17 @@ md_begin ()
|
|||
record_alignment (bss_section, 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (flag_code == CODE_64BIT)
|
||||
{
|
||||
x86_dwarf2_return_column = 16;
|
||||
x86_cie_data_alignment = -8;
|
||||
}
|
||||
else
|
||||
{
|
||||
x86_dwarf2_return_column = 8;
|
||||
x86_cie_data_alignment = -4;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -6301,42 +6318,15 @@ intel_putback_token ()
|
|||
prev_token.str = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
tc_x86_cfi_init (void)
|
||||
{
|
||||
struct cfi_config cfi_config;
|
||||
|
||||
if (flag_code == CODE_64BIT)
|
||||
{
|
||||
cfi_config.addr_length = 8;
|
||||
cfi_config.eh_align = 8;
|
||||
cfi_config.code_align = 1;
|
||||
cfi_config.data_align = -8;
|
||||
cfi_config.ra_column = 0x10;
|
||||
cfi_config.reloc_type = BFD_RELOC_64;
|
||||
}
|
||||
else
|
||||
{
|
||||
cfi_config.addr_length = 4;
|
||||
cfi_config.eh_align = 4;
|
||||
cfi_config.code_align = 1;
|
||||
cfi_config.data_align = -4;
|
||||
cfi_config.ra_column = 0x08;
|
||||
cfi_config.reloc_type = BFD_RELOC_32;
|
||||
}
|
||||
|
||||
cfi_set_config (&cfi_config);
|
||||
}
|
||||
|
||||
unsigned long
|
||||
int
|
||||
tc_x86_regname_to_dw2regnum (const char *regname)
|
||||
{
|
||||
unsigned int regnum;
|
||||
unsigned int regnames_count;
|
||||
char *regnames_32[] =
|
||||
{
|
||||
"eax", "ebx", "ecx", "edx",
|
||||
"edi", "esi", "ebp", "esp",
|
||||
"eax", "ecx", "edx", "ebx",
|
||||
"esp", "ebp", "esi", "edi",
|
||||
"eip"
|
||||
};
|
||||
char *regnames_64[] =
|
||||
|
@ -6364,21 +6354,18 @@ tc_x86_regname_to_dw2regnum (const char *regname)
|
|||
if (strcmp (regname, regnames[regnum]) == 0)
|
||||
return regnum;
|
||||
|
||||
as_bad (_("unknown register name '%s'"), regname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
tc_x86_frame_initial_instructions (void)
|
||||
{
|
||||
if (flag_code == CODE_64BIT)
|
||||
{
|
||||
cfi_add_insn (CFA_def_cfa, tc_x86_regname_to_dw2regnum ("rsp"), 8);
|
||||
cfi_add_insn (CFA_offset, tc_x86_regname_to_dw2regnum ("rip"), -8);
|
||||
}
|
||||
else
|
||||
{
|
||||
cfi_add_insn (CFA_def_cfa, tc_x86_regname_to_dw2regnum ("esp"), 4);
|
||||
cfi_add_insn (CFA_offset, tc_x86_regname_to_dw2regnum ("eip"), -4);
|
||||
}
|
||||
static unsigned int sp_regno;
|
||||
|
||||
if (!sp_regno)
|
||||
sp_regno = tc_x86_regname_to_dw2regnum (flag_code == CODE_64BIT
|
||||
? "rsp" : "esp");
|
||||
|
||||
cfi_add_CFA_def_cfa (sp_regno, -x86_cie_data_alignment);
|
||||
cfi_add_CFA_offset (x86_dwarf2_return_column, x86_cie_data_alignment);
|
||||
}
|
||||
|
|
|
@ -546,18 +546,18 @@ extern void sco_id PARAMS ((void));
|
|||
#endif
|
||||
|
||||
/* We want .cfi_* pseudo-ops for generating unwind info. */
|
||||
#define TARGET_USE_CFIPOP
|
||||
#ifdef TARGET_USE_CFIPOP
|
||||
#define TARGET_USE_CFIPOP 1
|
||||
|
||||
#define tc_cfi_init() tc_x86_cfi_init ()
|
||||
extern void tc_x86_cfi_init PARAMS ((void));
|
||||
extern unsigned int x86_dwarf2_return_column;
|
||||
#define DWARF2_DEFAULT_RETURN_COLUMN x86_dwarf2_return_column
|
||||
|
||||
extern int x86_cie_data_alignment;
|
||||
#define DWARF2_CIE_DATA_ALIGNMENT x86_cie_data_alignment
|
||||
|
||||
#define tc_regname_to_dw2regnum tc_x86_regname_to_dw2regnum
|
||||
extern unsigned long tc_x86_regname_to_dw2regnum PARAMS ((const char *regname));
|
||||
extern int tc_x86_regname_to_dw2regnum PARAMS ((const char *regname));
|
||||
|
||||
#define tc_cfi_frame_initial_instructions tc_x86_frame_initial_instructions
|
||||
extern void tc_x86_frame_initial_instructions PARAMS ((void));
|
||||
|
||||
#endif /* TARGET_USE_CFIPOP */
|
||||
|
||||
#endif /* TC_I386 */
|
||||
|
|
1378
gas/dw2gencfi.c
1378
gas/dw2gencfi.c
File diff suppressed because it is too large
Load Diff
|
@ -24,77 +24,23 @@
|
|||
|
||||
#include "elf/dwarf2.h"
|
||||
|
||||
struct cfi_config {
|
||||
/* Target address length in bytes. (usually 4 or 8).
|
||||
Round it up for archs like S/390 with 31b addresses. */
|
||||
unsigned int addr_length;
|
||||
|
||||
/* Alignment of .eh_frame blocks in bytes (usually 1, 4 or 8). */
|
||||
unsigned int eh_align;
|
||||
|
||||
/* Code alignment (1 for x86/amd64 machines, 4 or 8 for
|
||||
RISC machines). Consult Dwarf2 standard for details. */
|
||||
int code_align;
|
||||
|
||||
/* Data (stack) alignment (-4 on x86, -8 on amd64, something
|
||||
positive on archs where stack grows up). Consult Dwarf2
|
||||
standard for details. */
|
||||
int data_align;
|
||||
|
||||
/* Return address column (0x8 on x86, 0x10 on amd64). Consult
|
||||
Dwarf2 standard for details. */
|
||||
int ra_column;
|
||||
|
||||
/* Relocation type for init_addr FDE record. (BFD_RELOC_64
|
||||
on amd64). */
|
||||
int reloc_type;
|
||||
};
|
||||
|
||||
/* Codes of CFI instructions taken from Dwarf2 standard. */
|
||||
enum cfi_insn {
|
||||
CFA_nop = DW_CFA_nop,
|
||||
CFA_set_loc = DW_CFA_set_loc,
|
||||
CFA_advance_loc1 = DW_CFA_advance_loc1,
|
||||
CFA_advance_loc2 = DW_CFA_advance_loc2,
|
||||
CFA_advance_loc4 = DW_CFA_advance_loc4,
|
||||
CFA_offset_extended = DW_CFA_offset_extended,
|
||||
CFA_resotre_extended = DW_CFA_restore_extended,
|
||||
CFA_undefined = DW_CFA_undefined,
|
||||
CFA_same_value = DW_CFA_same_value,
|
||||
CFA_register = DW_CFA_register,
|
||||
CFA_remember_state = DW_CFA_remember_state,
|
||||
CFA_restore_state = DW_CFA_restore_state,
|
||||
CFA_def_cfa = DW_CFA_def_cfa,
|
||||
CFA_def_cfa_register = DW_CFA_def_cfa_register,
|
||||
CFA_def_cfa_offset = DW_CFA_def_cfa_offset,
|
||||
CFA_advance_loc = DW_CFA_advance_loc,
|
||||
CFA_offset = DW_CFA_offset,
|
||||
CFA_restore = DW_CFA_restore,
|
||||
|
||||
/* These don't belong to the standard. */
|
||||
CFI_startproc = 0xff00,
|
||||
CFI_endproc = 0xff01,
|
||||
CFI_adjust_cfa_offset = 0xff10,
|
||||
CFI_verbose = 0xffff
|
||||
};
|
||||
struct symbol;
|
||||
|
||||
extern const pseudo_typeS cfi_pseudo_table[];
|
||||
|
||||
/* Insert .cfi_* directives to the list of pseudo-ops. */
|
||||
void cfi_pop_insert PARAMS ((void));
|
||||
|
||||
/* Set/change setup of the CFI machinery. This change won't
|
||||
affect already generated CIEs/FDEs. */
|
||||
void cfi_set_config PARAMS ((struct cfi_config *cfg));
|
||||
|
||||
/* cfi_finish() is called at the end of file. It will complain if
|
||||
the last CFI wasn't properly closed by .cfi_endproc. */
|
||||
void cfi_finish PARAMS ((void));
|
||||
extern void cfi_finish (void);
|
||||
|
||||
/* Add CFI instruction to the list of instructions
|
||||
of the current frame. cfi_add_insn() could be used
|
||||
in tc_cfi_frame_initial_instructions() to add instructions
|
||||
needed for every frame (ie. those that usually go to CIE). */
|
||||
void cfi_add_insn (enum cfi_insn insn, long param0, long param1);
|
||||
/* Entry points for backends to add unwind information. */
|
||||
extern void cfi_new_fde (struct symbol *);
|
||||
extern void cfi_end_fde (struct symbol *);
|
||||
extern void cfi_set_return_column (unsigned);
|
||||
extern void cfi_add_advance_loc (struct symbol *);
|
||||
extern void cfi_add_CFA_offset (unsigned, offsetT);
|
||||
extern void cfi_add_CFA_def_cfa (unsigned, offsetT);
|
||||
extern void cfi_add_CFA_register (unsigned, unsigned);
|
||||
extern void cfi_add_CFA_def_cfa_register (unsigned);
|
||||
extern void cfi_add_CFA_def_cfa_offset (offsetT);
|
||||
|
||||
#endif /* DW2GENCFI_H */
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
2003-05-27 Richard Henderson <rth@redhat.com>
|
||||
|
||||
* gas/cfi/cfi-i386.d: Update for dw2gencfi rewrite.
|
||||
* gas/cfi/cfi-x86_64.d: Likewise.
|
||||
* gas/cfi/cfi-i386-2.d: New.
|
||||
* gas/cfi/cfi-i386-2.s: New.
|
||||
|
||||
2003-05-23 Jason Eckhardt <jle@rice.edu>
|
||||
|
||||
* gas/i860/xp.s: New file.
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
#readelf: -wf
|
||||
#name: CFI on i386, 2
|
||||
The section .eh_frame contains:
|
||||
|
||||
00000000 00000014 00000000 CIE
|
||||
Version: 1
|
||||
Augmentation: "zR"
|
||||
Code alignment factor: 1
|
||||
Data alignment factor: -4
|
||||
Return address column: 8
|
||||
Augmentation data: 1b
|
||||
|
||||
DW_CFA_def_cfa: r4 ofs 4
|
||||
DW_CFA_offset: r8 at cfa-4
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
|
||||
00000018 00000018 0000001c FDE cie=00000000 pc=00000020..00000029
|
||||
DW_CFA_advance_loc: 1 to 00000021
|
||||
DW_CFA_def_cfa_offset: 8
|
||||
DW_CFA_offset: r5 at cfa-8
|
||||
DW_CFA_advance_loc: 4 to 00000025
|
||||
DW_CFA_offset: r3 at cfa-12
|
||||
DW_CFA_def_cfa_offset: 12
|
||||
DW_CFA_nop
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
.text
|
||||
.globl foo
|
||||
.type foo,@function
|
||||
.cfi_startproc
|
||||
foo:
|
||||
push %ebp
|
||||
.cfi_adjust_cfa_offset 4
|
||||
.cfi_offset %ebp, -8
|
||||
.align 4
|
||||
push %ebx
|
||||
.cfi_offset %ebx, -12
|
||||
.cfi_adjust_cfa_offset 4
|
||||
nop
|
||||
pop %ebx
|
||||
pop %ebp
|
||||
ret
|
||||
.cfi_endproc
|
|
@ -2,50 +2,46 @@
|
|||
#name: CFI on i386
|
||||
The section .eh_frame contains:
|
||||
|
||||
00000000 00000010 00000000 CIE
|
||||
00000000 00000014 00000000 CIE
|
||||
Version: 1
|
||||
Augmentation: ""
|
||||
Augmentation: "zR"
|
||||
Code alignment factor: 1
|
||||
Data alignment factor: -4
|
||||
Return address column: 8
|
||||
Augmentation data: 1b
|
||||
|
||||
DW_CFA_def_cfa: r7 ofs 4
|
||||
DW_CFA_def_cfa: r4 ofs 4
|
||||
DW_CFA_offset: r8 at cfa-4
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
|
||||
00000014 00000014 00000018 FDE cie=00000000 pc=00000000..00000012
|
||||
DW_CFA_advance_loc: 6 to 00000006
|
||||
00000018 00000014 0000001c FDE cie=00000000 pc=00000020..00000032
|
||||
DW_CFA_advance_loc: 6 to 00000026
|
||||
DW_CFA_def_cfa_offset: 4664
|
||||
DW_CFA_advance_loc: 11 to 00000011
|
||||
DW_CFA_advance_loc: 11 to 00000031
|
||||
DW_CFA_def_cfa_offset: 4
|
||||
DW_CFA_nop
|
||||
|
||||
0000002c 00000018 00000030 FDE cie=00000000 pc=00000012..0000001f
|
||||
DW_CFA_advance_loc: 1 to 00000013
|
||||
00000030 00000018 00000034 FDE cie=00000000 pc=0000004a..00000057
|
||||
DW_CFA_advance_loc: 1 to 0000004b
|
||||
DW_CFA_def_cfa_offset: 8
|
||||
DW_CFA_offset: r6 at cfa-8
|
||||
DW_CFA_advance_loc: 2 to 00000015
|
||||
DW_CFA_def_cfa_reg: r6
|
||||
DW_CFA_advance_loc: 9 to 0000001e
|
||||
DW_CFA_def_cfa_reg: r7
|
||||
DW_CFA_nop
|
||||
DW_CFA_offset: r5 at cfa-8
|
||||
DW_CFA_advance_loc: 2 to 0000004d
|
||||
DW_CFA_def_cfa_reg: r5
|
||||
DW_CFA_advance_loc: 9 to 00000056
|
||||
DW_CFA_def_cfa_reg: r4
|
||||
|
||||
00000048 00000014 0000004c FDE cie=00000000 pc=0000001f..0000002f
|
||||
DW_CFA_advance_loc: 2 to 00000021
|
||||
DW_CFA_def_cfa_reg: r1
|
||||
DW_CFA_advance_loc: 13 to 0000002e
|
||||
DW_CFA_def_cfa: r7 ofs 4
|
||||
DW_CFA_nop
|
||||
0000004c 00000014 00000050 FDE cie=00000000 pc=00000073..00000083
|
||||
DW_CFA_advance_loc: 2 to 00000075
|
||||
DW_CFA_def_cfa_reg: r3
|
||||
DW_CFA_advance_loc: 13 to 00000082
|
||||
DW_CFA_def_cfa: r4 ofs 4
|
||||
|
||||
00000060 00000010 00000064 FDE cie=00000000 pc=0000002f..00000035
|
||||
DW_CFA_nop
|
||||
00000064 00000010 00000068 FDE cie=00000000 pc=0000009b..000000a1
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
|
||||
00000074 00000010 00000078 FDE cie=00000000 pc=00000035..00000044
|
||||
DW_CFA_nop
|
||||
00000078 00000010 0000007c FDE cie=00000000 pc=000000b5..000000c4
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
|
|
|
@ -1,68 +1,51 @@
|
|||
#readelf: -wf
|
||||
#name: CFI on x86-64
|
||||
|
||||
The section .eh_frame contains:
|
||||
|
||||
00000000 00000014 00000000 CIE
|
||||
Version: 1
|
||||
Augmentation: ""
|
||||
Augmentation: "zR"
|
||||
Code alignment factor: 1
|
||||
Data alignment factor: -8
|
||||
Return address column: 16
|
||||
Augmentation data: 1b
|
||||
|
||||
DW_CFA_def_cfa: r7 ofs 8
|
||||
DW_CFA_offset: r16 at cfa-8
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
|
||||
00000018 0000001c 0000001c FDE cie=00000000 pc=00000000..00000014
|
||||
DW_CFA_advance_loc: 7 to 00000007
|
||||
00000018 00000014 0000001c FDE cie=00000000 pc=00000020..00000034
|
||||
DW_CFA_advance_loc: 7 to 00000027
|
||||
DW_CFA_def_cfa_offset: 4668
|
||||
DW_CFA_advance_loc: 12 to 00000013
|
||||
DW_CFA_advance_loc: 12 to 00000033
|
||||
DW_CFA_def_cfa_offset: 8
|
||||
DW_CFA_nop
|
||||
|
||||
00000038 00000024 0000003c FDE cie=00000000 pc=00000000..0000000f
|
||||
DW_CFA_advance_loc: 1 to 00000001
|
||||
00000030 0000001c 00000034 FDE cie=00000000 pc=00000038..00000047
|
||||
DW_CFA_advance_loc: 1 to 00000039
|
||||
DW_CFA_def_cfa_offset: 16
|
||||
DW_CFA_offset: r6 at cfa-16
|
||||
DW_CFA_advance_loc: 3 to 00000004
|
||||
DW_CFA_advance_loc: 3 to 0000003c
|
||||
DW_CFA_def_cfa_reg: r6
|
||||
DW_CFA_advance_loc: 10 to 0000000e
|
||||
DW_CFA_advance_loc: 10 to 00000046
|
||||
DW_CFA_def_cfa: r7 ofs 8
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
|
||||
00000060 0000001c 00000064 FDE cie=00000000 pc=00000000..00000013
|
||||
DW_CFA_advance_loc: 3 to 00000003
|
||||
00000050 00000014 00000054 FDE cie=00000000 pc=00000058..0000006b
|
||||
DW_CFA_advance_loc: 3 to 0000005b
|
||||
DW_CFA_def_cfa_reg: r12
|
||||
DW_CFA_advance_loc: 15 to 00000012
|
||||
DW_CFA_advance_loc: 15 to 0000006a
|
||||
DW_CFA_def_cfa_reg: r7
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
|
||||
00000080 0000001c 00000084 FDE cie=00000000 pc=00000000..00000006
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
00000068 00000010 0000006c FDE cie=00000000 pc=00000070..00000076
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
|
||||
000000a0 0000001c 000000a4 FDE cie=00000000 pc=00000000..00000012
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
0000007c 00000010 00000080 FDE cie=00000000 pc=00000084..00000096
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
DW_CFA_nop
|
||||
|
|
Loading…
Reference in New Issue