mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-11-16 12:34:43 +00:00
The SFrame FRE start address (fre_start_addr) is defined as unsigned 32-bit integer, as it is an offset from SFrame FDE function start address (sfde_func_start_address) and functions only grow upwards (towards higher addresses). The SFrame FRE start IP offset is a synonym to the SFrame FRE start address. The SFrame FRE end IP offset is either the value of the subsequent FDE start address minus one, if that exists, or the FDE function size minus one otherwise. Both should therefore be handled as unsigned 32-bit integer. In libsframe the "lookup PC" (pc) and SFrame FDE function start address (sfde_func_start_address) are both signed integers, as they are actually offsets from the SFrame section. The unsigned FDE start/end IP offsets may therefore only be safely compared against the offset of the lookup PC from FDE function start address if the FDE function start address is lower or equal to the lookup PC, as this guarantees the offset to be always positive: Given: lookup_pc = pc - sframe_addr sfde_func_start_address = func_start_addr - sframe_addr If the FDE function start address is lower or equal than the lookup PC, which both are signed offsets from SFrame section, then the function start address is also lower or equal to the PC, which are both unsigned: sfde_func_start_address <= lookup_pc func_start_addr - sframe_addr <= pc - sframe_addr func_start_addr <= pc With that the offset of the lookup PC from FDE function start address (lookup_pc - sfde_func_start_address) must always be positive, if FDE function start address is lower or equal to the lookup PC: lookup_pc - sfde_func_start_address = pc - sframe_addr - (func_start_addr - sframe_addr) = pc - func_start_addr libsframe/ * sframe.c (sframe_find_fre): Define and handle start_ip_offset and end_ip_offset as unsigned (same as FRE fre_start_addr). (sframe_fre_check_range_p): Likewise. Define PC offset (from function start address) as unsigned. Signed-off-by: Jens Remus <jremus@linux.ibm.com>