diff options
Diffstat (limited to 'libsframe/sframe.c')
-rw-r--r-- | libsframe/sframe.c | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/libsframe/sframe.c b/libsframe/sframe.c index ea0e1c7..7357fc1 100644 --- a/libsframe/sframe.c +++ b/libsframe/sframe.c @@ -166,6 +166,7 @@ need_swapping (int endian) case SFRAME_ABI_AMD64_ENDIAN_LITTLE: return !is_little; case SFRAME_ABI_AARCH64_ENDIAN_BIG: + case SFRAME_ABI_S390X_ENDIAN_BIG: return is_little; default: break; @@ -520,7 +521,7 @@ flip_sframe (char *frame_buf, size_t buf_size, uint32_t to_foreign) fre_offset = fdep->sfde_func_start_fre_off; } - fp = frame_buf + sframe_get_hdr_size (ihp) + ihp->sfh_freoff; + fp = frame_buf + hdrsz + ihp->sfh_freoff; fp += fre_offset; for (; j < prev_frep_index + num_fres; j++) { @@ -535,8 +536,12 @@ flip_sframe (char *frame_buf, size_t buf_size, uint32_t to_foreign) prev_frep_index = j; } /* All FDEs and FREs must have been endian flipped by now. */ - if ((j != ihp->sfh_num_fres) || (bytes_flipped != (buf_size - hdrsz))) + if ((j != ihp->sfh_num_fres) || (bytes_flipped > (buf_size - hdrsz))) goto bad; + /* Optional trailing section padding. */ + for (fp = frame_buf + hdrsz + bytes_flipped; fp < frame_buf + buf_size; fp++) + if (*fp != '\0') + goto bad; /* Success. */ return 0; @@ -690,13 +695,22 @@ sframe_fre_get_base_reg_id (sframe_frame_row_entry *fre, int *errp) /* Get the CFA offset from the FRE. If the offset is invalid, sets errp. */ int32_t -sframe_fre_get_cfa_offset (sframe_decoder_ctx *dctx ATTRIBUTE_UNUSED, +sframe_fre_get_cfa_offset (sframe_decoder_ctx *dctx, sframe_frame_row_entry *fre, int *errp) { - return sframe_get_fre_offset (fre, SFRAME_FRE_CFA_OFFSET_IDX, errp); + int32_t offset = sframe_get_fre_offset (fre, SFRAME_FRE_CFA_OFFSET_IDX, errp); + + /* For s390x undo adjustment of CFA offset (to enable 8-bit offsets). */ + if (sframe_decoder_get_abi_arch (dctx) == SFRAME_ABI_S390X_ENDIAN_BIG) + offset = SFRAME_V2_S390X_CFA_OFFSET_DECODE (offset); + + return offset; } -/* Get the FP offset from the FRE. If the offset is invalid, sets errp. */ +/* Get the FP offset from the FRE. If the offset is invalid, sets errp. + + For s390x the offset may be an encoded register number, indicated by + LSB set to one, which is only valid in the topmost frame. */ int32_t sframe_fre_get_fp_offset (sframe_decoder_ctx *dctx, @@ -723,7 +737,12 @@ sframe_fre_get_fp_offset (sframe_decoder_ctx *dctx, return sframe_get_fre_offset (fre, fp_offset_idx, errp); } -/* Get the RA offset from the FRE. If the offset is invalid, sets errp. */ +/* Get the RA offset from the FRE. If the offset is invalid, sets errp. + + For s390x an RA offset value of SFRAME_FRE_RA_OFFSET_INVALID indicates + that the RA is not saved, which is only valid in the topmost frame. + For s390x the offset may be an encoded register number, indicated by + LSB set to one, which is only valid in the topmost frame. */ int32_t sframe_fre_get_ra_offset (sframe_decoder_ctx *dctx, @@ -857,7 +876,7 @@ sframe_decode_fre (const char *fre_buf, sframe_frame_row_entry *fre, return 0; } -/* Decode the specified SFrame buffer CF_BUF of size CF_SIZE and return the +/* Decode the specified SFrame buffer SF_BUF of size SF_SIZE and return the new SFrame decoder context. Sets ERRP for the caller if any error. Frees up the allocated memory in @@ -1060,18 +1079,6 @@ sframe_decoder_get_offsetof_fde_start_addr (sframe_decoder_ctx *dctx, + offsetof (sframe_func_desc_entry, sfde_func_start_address)); } -/* Find the function descriptor entry which contains the specified address - ADDR. - This function is deprecated and will be removed from libsframe.so.2. */ - -void * -sframe_get_funcdesc_with_addr (sframe_decoder_ctx *ctx __attribute__ ((unused)), - int32_t addr __attribute__ ((unused)), - int *errp) -{ - return sframe_ret_set_errno (errp, SFRAME_ERR_INVAL); -} - /* Find the function descriptor entry starting which contains the specified address ADDR. */ @@ -1620,7 +1627,7 @@ sframe_encoder_add_funcdesc (sframe_encoder_ctx *encoder, int32_t start_addr, uint32_t func_size, unsigned char func_info, - uint32_t num_fres __attribute__ ((unused))) + uint32_t num_fres ATTRIBUTE_UNUSED) { sframe_header *ehp; sf_fde_tbl *fd_info; @@ -1702,7 +1709,7 @@ sframe_encoder_add_funcdesc_v2 (sframe_encoder_ctx *encoder, uint32_t func_size, unsigned char func_info, uint8_t rep_block_size, - uint32_t num_fres __attribute__ ((unused))) + uint32_t num_fres ATTRIBUTE_UNUSED) { sf_fde_tbl *fd_info; int err; |