sfde_func_start_fre_off));
}
- /* Number of FREs. */
- out_four (sframe_fde->num_fres);
+ /* Number of FREs must fit uint16_t. */
+ gas_assert (sframe_fde->num_fres <= UINT16_MAX);
+ out_two (sframe_fde->num_fres);
/* SFrame FDE function info. */
unsigned char func_info;
= get_dw_fde_end_addrS (xlate_ctx->dw_fde);
}
+ /* Number of FREs must fit uint16_t. Check now, and do not emit the SFrame
+ FDE if it doesnt fit (although, it is not expected to happen for
+ real-world, useful programs). The approach of truncating the FDE and
+ emitting multiple SFrame FDEs instead, is not a clearly preferable
+ handling either. Its a divergence from the model where an SFrame FDE
+ encodes stack trace data between a .cfi_startproc and .cfi_endproc pair.
+ Further, some components (linkers, stack tracers) want to associate the
+ Start PC of a function to a known symbol in the file? */
+ if (xlate_ctx->num_xlate_fres > UINT16_MAX)
+ {
+ as_warn (_("no SFrame FDE emitted; Number of FREs exceeds UINT16_MAX"));
+ return SFRAME_XLATE_ERR_NOTREPRESENTED;
+ }
+
/* ABI/arch except s390x cannot represent FP without RA saved. */
if (sframe_ra_tracking_p ()
&& sframe_get_abi_arch () != SFRAME_ABI_S390X_ENDIAN_BIG)
beginning of the SFrame Frame Row Entry sub-section. */
uint32_t sfde_func_start_fre_off;
/* Number of frame row entries for the function. */
- uint32_t sfde_func_num_fres;
+ uint16_t sfde_func_num_fres;
/* Additional information for stack tracing from the function:
- 4-bits: Identify the FRE type used for the function.
- 1-bit: Identify the FDE type of the function - mask or inc.
fde_tbl->entry[i].func_start_addr = fdep->sfde_func_start_address;
fde_tbl->entry[i].func_size = fdep->sfde_func_size;
fde_tbl->entry[i].func_start_fre_off = fdep->sfde_func_start_fre_off;
- fde_tbl->entry[i].func_num_fres = fdep->sfde_func_num_fres;
+ fde_tbl->entry[i].func_num_fres = (uint16_t)fdep->sfde_func_num_fres;
fde_tbl->entry[i].func_info = fdep->sfde_func_info;
fde_tbl->entry[i].func_rep_size = fdep->sfde_func_rep_size;
}
return SFRAME_ERR;
sframe_func_desc_entry_v3 *fdep = (sframe_func_desc_entry_v3 *) buf;
- *num_fres = fdep->sfde_func_num_fres;
+ *num_fres = (uint16_t)fdep->sfde_func_num_fres;
*fre_type = SFRAME_V1_FUNC_FRE_TYPE (fdep->sfde_func_info);
*fre_offset = fdep->sfde_func_start_fre_off;
fdep->sfde_func_start_address = (int32_t)fde->func_start_addr;
fdep->sfde_func_size = fde->func_size;
fdep->sfde_func_start_fre_off = fde->func_start_fre_off;
- fdep->sfde_func_num_fres = fde->func_num_fres;
+ fdep->sfde_func_num_fres = (uint16_t)fde->func_num_fres;
fdep->sfde_func_info = fde->func_info;
fdep->sfde_func_rep_size = fde->func_rep_size;
fdep->sfde_func_padding2 = 0;