mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-05 15:15:42 +00:00
gas: use "stack trace" instead of "unwind" for SFrame
SFrame format is meant for generating stack traces only. gas/ * as.c: Replace the use of "unwind" with "stack trace". * config/tc-aarch64.c: Likewise. * config/tc-aarch64.h: Likewise. * config/tc-i386.c: Likewise. * config/tc-i386.h: Likewise. * gen-sframe.c: Likewise. * gen-sframe.h: Likewise. * testsuite/gas/cfi-sframe/cfi-sframe-aarch64-2.s: Likewise. * testsuite/gas/cfi-sframe/cfi-sframe-common-8.s: Likewise. * testsuite/gas/cfi-sframe/common-empty-2.s: Likewise. * testsuite/gas/cfi-sframe/common-empty-3.s: Likewise.
This commit is contained in:
2
gas/as.c
2
gas/as.c
@@ -317,7 +317,7 @@ Options:\n\
|
|||||||
fprintf (stream, _("\
|
fprintf (stream, _("\
|
||||||
generate GNU Build notes if none are present in the input\n"));
|
generate GNU Build notes if none are present in the input\n"));
|
||||||
fprintf (stream, _("\
|
fprintf (stream, _("\
|
||||||
--gsframe generate SFrame unwind info\n"));
|
--gsframe generate SFrame stack trace information\n"));
|
||||||
#endif /* OBJ_ELF */
|
#endif /* OBJ_ELF */
|
||||||
|
|
||||||
fprintf (stream, _("\
|
fprintf (stream, _("\
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ enum aarch64_abi_type
|
|||||||
};
|
};
|
||||||
|
|
||||||
unsigned int aarch64_sframe_cfa_sp_reg;
|
unsigned int aarch64_sframe_cfa_sp_reg;
|
||||||
/* The other CFA base register for SFrame unwind info. */
|
/* The other CFA base register for SFrame stack trace info. */
|
||||||
unsigned int aarch64_sframe_cfa_fp_reg;
|
unsigned int aarch64_sframe_cfa_fp_reg;
|
||||||
unsigned int aarch64_sframe_cfa_ra_reg;
|
unsigned int aarch64_sframe_cfa_ra_reg;
|
||||||
|
|
||||||
@@ -8474,7 +8474,7 @@ aarch64_init_frag (fragS * fragP, int max_chars)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Whether SFrame unwind info is supported. */
|
/* Whether SFrame stack trace info is supported. */
|
||||||
|
|
||||||
bool
|
bool
|
||||||
aarch64_support_sframe_p (void)
|
aarch64_support_sframe_p (void)
|
||||||
|
|||||||
@@ -263,19 +263,19 @@ extern void aarch64_after_parse_args (void);
|
|||||||
|
|
||||||
#ifdef OBJ_ELF
|
#ifdef OBJ_ELF
|
||||||
|
|
||||||
/* Whether SFrame unwind info is supported. */
|
/* Whether SFrame stack trace info is supported. */
|
||||||
extern bool aarch64_support_sframe_p (void);
|
extern bool aarch64_support_sframe_p (void);
|
||||||
#define support_sframe_p aarch64_support_sframe_p
|
#define support_sframe_p aarch64_support_sframe_p
|
||||||
|
|
||||||
/* The stack-pointer register number for SFrame unwind info. */
|
/* The stack-pointer register number for SFrame stack trace info. */
|
||||||
extern unsigned int aarch64_sframe_cfa_sp_reg;
|
extern unsigned int aarch64_sframe_cfa_sp_reg;
|
||||||
#define SFRAME_CFA_SP_REG aarch64_sframe_cfa_sp_reg
|
#define SFRAME_CFA_SP_REG aarch64_sframe_cfa_sp_reg
|
||||||
|
|
||||||
/* The base-pointer register number for CFA unwind info. */
|
/* The base-pointer register number for CFA stack trace info. */
|
||||||
extern unsigned int aarch64_sframe_cfa_fp_reg;
|
extern unsigned int aarch64_sframe_cfa_fp_reg;
|
||||||
#define SFRAME_CFA_FP_REG aarch64_sframe_cfa_fp_reg
|
#define SFRAME_CFA_FP_REG aarch64_sframe_cfa_fp_reg
|
||||||
|
|
||||||
/* The return address register number for CFA unwind info. */
|
/* The return address register number for CFA stack trace info. */
|
||||||
extern unsigned int aarch64_sframe_cfa_ra_reg;
|
extern unsigned int aarch64_sframe_cfa_ra_reg;
|
||||||
#define SFRAME_CFA_RA_REG aarch64_sframe_cfa_ra_reg
|
#define SFRAME_CFA_RA_REG aarch64_sframe_cfa_ra_reg
|
||||||
|
|
||||||
|
|||||||
@@ -607,7 +607,7 @@ static int use_big_obj = 0;
|
|||||||
static int shared = 0;
|
static int shared = 0;
|
||||||
|
|
||||||
unsigned int x86_sframe_cfa_sp_reg;
|
unsigned int x86_sframe_cfa_sp_reg;
|
||||||
/* The other CFA base register for SFrame unwind info. */
|
/* The other CFA base register for SFrame stack trace info. */
|
||||||
unsigned int x86_sframe_cfa_fp_reg;
|
unsigned int x86_sframe_cfa_fp_reg;
|
||||||
unsigned int x86_sframe_cfa_ra_reg;
|
unsigned int x86_sframe_cfa_ra_reg;
|
||||||
|
|
||||||
@@ -9285,7 +9285,7 @@ x86_cleanup (void)
|
|||||||
bool
|
bool
|
||||||
x86_support_sframe_p (void)
|
x86_support_sframe_p (void)
|
||||||
{
|
{
|
||||||
/* At this time, SFrame unwind is supported for AMD64 ABI only. */
|
/* At this time, SFrame stack trace is supported for AMD64 ABI only. */
|
||||||
return (x86_elf_abi == X86_64_ABI);
|
return (x86_elf_abi == X86_64_ABI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -363,15 +363,15 @@ extern bfd_vma x86_64_section_letter (int, const char **);
|
|||||||
extern void x86_cleanup (void);
|
extern void x86_cleanup (void);
|
||||||
#define md_cleanup() x86_cleanup ()
|
#define md_cleanup() x86_cleanup ()
|
||||||
|
|
||||||
/* Whether SFrame unwind info is supported. */
|
/* Whether SFrame stack trace info is supported. */
|
||||||
extern bool x86_support_sframe_p (void);
|
extern bool x86_support_sframe_p (void);
|
||||||
#define support_sframe_p x86_support_sframe_p
|
#define support_sframe_p x86_support_sframe_p
|
||||||
|
|
||||||
/* The stack-pointer register number for SFrame unwind info. */
|
/* The stack-pointer register number for SFrame stack trace info. */
|
||||||
extern unsigned int x86_sframe_cfa_sp_reg;
|
extern unsigned int x86_sframe_cfa_sp_reg;
|
||||||
#define SFRAME_CFA_SP_REG x86_sframe_cfa_sp_reg
|
#define SFRAME_CFA_SP_REG x86_sframe_cfa_sp_reg
|
||||||
|
|
||||||
/* The frame-pointer register number for CFA unwind info. */
|
/* The frame-pointer register number for SFrame stack trace info. */
|
||||||
extern unsigned int x86_sframe_cfa_fp_reg;
|
extern unsigned int x86_sframe_cfa_fp_reg;
|
||||||
#define SFRAME_CFA_FP_REG x86_sframe_cfa_fp_reg
|
#define SFRAME_CFA_FP_REG x86_sframe_cfa_fp_reg
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
/* Whether frame row entries track RA.
|
/* Whether frame row entries track RA.
|
||||||
|
|
||||||
A target may not need return address tracking for stack unwinding. If it
|
A target may not need return address tracking for stack tracing. If it
|
||||||
does need the same, SFRAME_CFA_RA_REG must be defined with the return
|
does need the same, SFRAME_CFA_RA_REG must be defined with the return
|
||||||
address register number. */
|
address register number. */
|
||||||
|
|
||||||
@@ -892,7 +892,7 @@ sframe_xlate_ctx_add_fre (struct sframe_xlate_ctx *xlate_ctx,
|
|||||||
xlate_ctx->num_xlate_fres++;
|
xlate_ctx->num_xlate_fres++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A SFrame Frame Row Entry is self-sufficient in terms of unwind information
|
/* A SFrame Frame Row Entry is self-sufficient in terms of stack tracing info
|
||||||
for a given PC. It contains information assimilated from multiple CFI
|
for a given PC. It contains information assimilated from multiple CFI
|
||||||
instructions, and hence, a new SFrame FRE is initialized with the data from
|
instructions, and hence, a new SFrame FRE is initialized with the data from
|
||||||
the previous known FRE, if any.
|
the previous known FRE, if any.
|
||||||
@@ -1024,7 +1024,7 @@ sframe_xlate_do_def_cfa_offset (struct sframe_xlate_ctx *xlate_ctx,
|
|||||||
gas_assert (cur_fre);
|
gas_assert (cur_fre);
|
||||||
/* Define the current CFA rule to use the provided offset (but to keep
|
/* Define the current CFA rule to use the provided offset (but to keep
|
||||||
the old register). However, if the old register is not FP/SP,
|
the old register). However, if the old register is not FP/SP,
|
||||||
skip creating SFrame unwind info for the function. */
|
skip creating SFrame stack trace info for the function. */
|
||||||
if ((cur_fre->cfa_base_reg == SFRAME_CFA_FP_REG)
|
if ((cur_fre->cfa_base_reg == SFRAME_CFA_FP_REG)
|
||||||
|| (cur_fre->cfa_base_reg == SFRAME_CFA_SP_REG))
|
|| (cur_fre->cfa_base_reg == SFRAME_CFA_SP_REG))
|
||||||
{
|
{
|
||||||
@@ -1081,7 +1081,7 @@ sframe_xlate_do_val_offset (struct sframe_xlate_ctx *xlate_ctx ATTRIBUTE_UNUSED,
|
|||||||
/* Previous value of register is CFA + offset. However, if the specified
|
/* Previous value of register is CFA + offset. However, if the specified
|
||||||
register is not interesting (FP or RA reg), the current DW_CFA_val_offset
|
register is not interesting (FP or RA reg), the current DW_CFA_val_offset
|
||||||
instruction can be safely skipped without sacrificing the asynchonicity of
|
instruction can be safely skipped without sacrificing the asynchonicity of
|
||||||
unwind information. */
|
stack trace information. */
|
||||||
if (cfi_insn->u.r == SFRAME_CFA_FP_REG)
|
if (cfi_insn->u.r == SFRAME_CFA_FP_REG)
|
||||||
return SFRAME_XLATE_ERR_NOTREPRESENTED; /* Not represented. */
|
return SFRAME_XLATE_ERR_NOTREPRESENTED; /* Not represented. */
|
||||||
#ifdef SFRAME_FRE_RA_TRACKING
|
#ifdef SFRAME_FRE_RA_TRACKING
|
||||||
@@ -1103,8 +1103,8 @@ sframe_xlate_do_remember_state (struct sframe_xlate_ctx *xlate_ctx)
|
|||||||
struct sframe_row_entry *last_fre = xlate_ctx->last_fre;
|
struct sframe_row_entry *last_fre = xlate_ctx->last_fre;
|
||||||
|
|
||||||
/* If there is no FRE state to remember, nothing to do here. Return
|
/* If there is no FRE state to remember, nothing to do here. Return
|
||||||
early with non-zero error code, this will cause no SFrame unwind info
|
early with non-zero error code, this will cause no SFrame stack trace
|
||||||
for the function involved. */
|
info for the function involved. */
|
||||||
if (!last_fre)
|
if (!last_fre)
|
||||||
return SFRAME_XLATE_ERR_INVAL;
|
return SFRAME_XLATE_ERR_INVAL;
|
||||||
|
|
||||||
@@ -1248,7 +1248,7 @@ sframe_do_cfi_insn (struct sframe_xlate_ctx *xlate_ctx,
|
|||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
/* Other CFI opcodes are not processed at this time.
|
/* Other CFI opcodes are not processed at this time.
|
||||||
These do not impact the coverage of the basic stack unwinding
|
These do not impact the coverage of the basic stack tracing
|
||||||
information as conveyed in the SFrame format.
|
information as conveyed in the SFrame format.
|
||||||
- DW_CFA_register,
|
- DW_CFA_register,
|
||||||
- ...
|
- ...
|
||||||
@@ -1285,7 +1285,7 @@ sframe_do_fde (struct sframe_xlate_ctx *xlate_ctx,
|
|||||||
err = sframe_do_cfi_insn (xlate_ctx, cfi_insn);
|
err = sframe_do_cfi_insn (xlate_ctx, cfi_insn);
|
||||||
if (err != SFRAME_XLATE_OK)
|
if (err != SFRAME_XLATE_OK)
|
||||||
{
|
{
|
||||||
/* Skip generating SFrame unwind info for the function if any
|
/* Skip generating SFrame stack trace info for the function if any
|
||||||
offending CFI is encountered by sframe_do_cfi_insn (). */
|
offending CFI is encountered by sframe_do_cfi_insn (). */
|
||||||
return err; /* Return the error code. */
|
return err; /* Return the error code. */
|
||||||
}
|
}
|
||||||
@@ -1309,10 +1309,11 @@ sframe_do_fde (struct sframe_xlate_ctx *xlate_ctx,
|
|||||||
return SFRAME_XLATE_OK;
|
return SFRAME_XLATE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create SFrame unwind info for all functions.
|
/* Create SFrame stack trace info for all functions.
|
||||||
|
|
||||||
This function consumes the already generated FDEs (by dw2gencfi) and
|
This function consumes the already generated DWARF FDEs (by dw2gencfi) and
|
||||||
generates unwind data in SFrame format. */
|
generates data which is later emitted as stack trace information encoded in
|
||||||
|
the SFrame format. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
create_sframe_all (void)
|
create_sframe_all (void)
|
||||||
@@ -1330,7 +1331,8 @@ create_sframe_all (void)
|
|||||||
|
|
||||||
/* Process and link SFrame FDEs if no error. Also skip adding an SFrame
|
/* Process and link SFrame FDEs if no error. Also skip adding an SFrame
|
||||||
FDE if it does not contain any SFrame FREs. There is little use of an
|
FDE if it does not contain any SFrame FREs. There is little use of an
|
||||||
SFrame FDE if there is no unwind information about the function. */
|
SFrame FDE if there is no stack tracing information for the
|
||||||
|
function. */
|
||||||
int err = sframe_do_fde (xlate_ctx, dw_fde);
|
int err = sframe_do_fde (xlate_ctx, dw_fde);
|
||||||
if (err || xlate_ctx->num_xlate_fres == 0)
|
if (err || xlate_ctx->num_xlate_fres == 0)
|
||||||
{
|
{
|
||||||
@@ -1355,7 +1357,7 @@ output_sframe (segT sframe_seg)
|
|||||||
/* Setup the version specific access functions. */
|
/* Setup the version specific access functions. */
|
||||||
sframe_set_version (SFRAME_VERSION_1);
|
sframe_set_version (SFRAME_VERSION_1);
|
||||||
|
|
||||||
/* Process all fdes and create SFrame unwind information. */
|
/* Process all fdes and create SFrame stack trace information. */
|
||||||
create_sframe_all ();
|
create_sframe_all ();
|
||||||
|
|
||||||
output_sframe_internal ();
|
output_sframe_internal ();
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ struct sframe_version_ops
|
|||||||
unsigned char (*set_func_info) (unsigned int, unsigned int, unsigned int);
|
unsigned char (*set_func_info) (unsigned int, unsigned int, unsigned int);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Generate SFrame unwind info and prepare contents for the output.
|
/* Generate SFrame stack trace info and prepare contents for the output.
|
||||||
outout_sframe () is called at the end of file. */
|
outout_sframe () is called at the end of file. */
|
||||||
|
|
||||||
extern void output_sframe (segT sframe_seg);
|
extern void output_sframe (segT sframe_seg);
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
## main idea behind this is to use the unused bits in the pointer values.
|
## main idea behind this is to use the unused bits in the pointer values.
|
||||||
## Each pointer is patched with a PAC before writing to memory, and is verified
|
## Each pointer is patched with a PAC before writing to memory, and is verified
|
||||||
## before using it.
|
## before using it.
|
||||||
## When the pointers are mangled, the unwinder needs to know so it can mask off
|
## When the pointers are mangled, the stack trace generator needs to know so it
|
||||||
## the PAC from the pointer value to recover the return address, and
|
## can mask off the PAC from the pointer value to recover the return address,
|
||||||
## conversely, skip doing so if the pointers are not mangled.
|
## and conversely, skip doing so if the pointers are not mangled.
|
||||||
##
|
##
|
||||||
## .cfi_negate_ra_state CFI directive is used to convey this information.
|
## .cfi_negate_ra_state CFI directive is used to convey this information.
|
||||||
##
|
##
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
## cfi_val_offset when used with "not interesting" registers (from the
|
## cfi_val_offset when used with "not interesting" registers (from the
|
||||||
## perspective of SFrame section, non FP/RA registers are not
|
## perspective of SFrame section, non FP/RA registers are not
|
||||||
## interesting) does not affect the asynchronicity of the SFrame
|
## interesting) does not affect the asynchronicity of the SFrame
|
||||||
## unwind information. Such CFI directives can be skipped for SFrame
|
## stack trace information. Such CFI directives can be skipped for SFrame
|
||||||
## unwind info generation.
|
## stack trace info generation.
|
||||||
.cfi_startproc
|
.cfi_startproc
|
||||||
.long 0
|
.long 0
|
||||||
.cfi_def_cfa_offset 16
|
.cfi_def_cfa_offset 16
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
## CFA register is not defined to be SP/FP.
|
## CFA register is not defined to be SP/FP.
|
||||||
## No SFrame unwind info for this function will be generated.
|
## No SFrame stack trace info for this function will be generated.
|
||||||
.cfi_startproc simple
|
.cfi_startproc simple
|
||||||
.long 0
|
.long 0
|
||||||
.long 0
|
.long 0
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
## The return column is not the default value.
|
## The return column is not the default value.
|
||||||
## No SFrame unwind info for this function will be generated.
|
## No SFrame stack trace info for this function will be generated.
|
||||||
.cfi_startproc
|
.cfi_startproc
|
||||||
.cfi_return_column 0
|
.cfi_return_column 0
|
||||||
.long 0
|
.long 0
|
||||||
|
|||||||
Reference in New Issue
Block a user