binutils-gdb/libsframe
Indu Bhagat 3169b734cf libsframe: fix sframe_find_fre for pltN entries
For a toy application on x86_64, for example, following is the SFrame
stack trace information for the 3 pltN entries of 16 bytes each:

   func idx [1]: pc = 0x401030, size = 48 bytes
   STARTPC[m]      CFA       FP        RA
   0000000000000000  sp+8      u         u
   000000000000000b  sp+16     u         u

The data in first column is the start_ip_offset.  Also note that the FDE
is of type SFRAME_FDE_TYPE_PCMASK (denoted by the [m] on LHS).

Where each pltN (note: excluding plt0 entry) entry looks like:

  401030: jmp    *0x2fca(%rip)
  401036: push   $0x0
  40103b: jmp    401020<_init+0x20>

  401040: jmp    *0x2fc2(%rip)
  401046: push   $0x1
  40104b: jmp    401020<_init+0x20>

  401050: jmp    *0x2fba(%rip)
  401056: push   $0x2
  40105b: jmp    401020<_init+0x20>

Now, to find SFrame stack trace information from an FDE of type
SFRAME_FDE_TYPE_PCMASK, sframe_find_fre () was doing an operation
like,
  (start_ip_offset & 0xf) >= (pc & 0xf)

This works for pltN entry of size, say, less than 16 bytes.  But if the
pltN entries or similar code stubs (for which SFrame FDE of type
SFRAME_FDE_TYPE_PCMASK may be used), evolve to be of size > 16 bytes,
this will cease to work.

To match the range covered by the SFrame FRE, one should instead perform
a modulo operation.  The constant for the modulo operation must be the
size of the pltN entry.  Further, this constant should ideally be
encoded in the format, as it may be different for each ABI.

In SFrame Version 2 of the format, we will move towards encoding it
explicitly in the SFrame FDE.  For now, fix up the logic to at least
move towards modulo operation.

libsframe/
	* sframe.c (sframe_fre_check_range_p): New definition.
	(sframe_find_fre): Refactor a bit and use the new definition
	above.
include/
	* sframe.h (SFRAME_FDE_TYPE_PCMASK): Update comment.
libsframe/doc/
	* sframe-spec.texi: Fix the text for SFRAME_FDE_TYPE_PCMASK FDE
	type.
2023-06-29 11:03:32 -07:00
..
doc libsframe: fix sframe_find_fre for pltN entries 2023-06-29 11:03:32 -07:00
testsuite libsframe: testsuite: add sframe_find_fre tests for pltN entries 2023-06-09 11:24:25 -07:00
aclocal.m4
config.h.in
configure libsframe: add symbol versioning 2023-06-27 12:01:56 -07:00
configure.ac libsframe: add symbol versioning 2023-06-27 12:01:56 -07:00
libsframe.ver libsframe: add symbol versioning 2023-06-27 12:01:56 -07:00
libtool-version libsframe: add library versioning 2023-06-27 12:01:56 -07:00
Makefile.am libsframe: add symbol versioning 2023-06-27 12:01:56 -07:00
Makefile.in libsframe: add symbol versioning 2023-06-27 12:01:56 -07:00
sframe-dump.c libsframe: use uint8_t for return type of sframe_fre_get_base_reg_id 2023-06-27 12:01:56 -07:00
sframe-error.c
sframe-impl.h libsframe: avoid unnecessary type casts 2023-06-05 14:17:15 -07:00
sframe.c libsframe: fix sframe_find_fre for pltN entries 2023-06-29 11:03:32 -07:00