aboutsummaryrefslogtreecommitdiff
path: root/libsframe/testsuite/libsframe.encode/encode-1.c
AgeCommit message (Collapse)AuthorFilesLines
2026-01-15[SFrame-V3] gas: bfd: include: libsframe: fixup terminology 'PC Type' vs ↵Indu Bhagat1-2/+2
'FDE Type' In SFrame V2, we did use the the term 'FDE Type' for the two designated 'PC Type' for the SFrame FDEs (SFRAME_FDE_TYPE_PCINC, SFRAME_FDE_TYPE_PCMASK). In hindsight, 'FDE Type' was an inappropriate term for the said intent. Fix this terminology by defining two new constants: - SFRAME_V3_FDE_PCTYPE_MASK - SFRAME_V3_FDE_PCTYPE_INC The old constants from V2 (SFRAME_FDE_TYPE_PCINC, SFRAME_FDE_TYPE_PCMASK) remain, but are now unused in the codebase. The term 'FDE Type' should be used for the actual FDE Types. In a subsequent commit, we will add SFRAME_FDE_TYPE_FLEX FDE Type for SFrame V3. bfd/ * elf64-s390.c (_bfd_s390_elf_create_sframe_plt): Rename inappropriate SFRAME_FDE_TYPE_PCINC to SFRAME_V3_FDE_PCTYPE_INC. * elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Likewise. Also rename inappropriate SFRAME_FDE_TYPE_PCMASK to SFRAME_V3_FDE_PCTYPE_MASK. gas/ * gen-sframe.c (output_sframe_funcdesc): Likewise. * sframe-opt.c (sframe_convert_frag): Likewise. libsframe/ * sframe-dump.c (dump_sframe_func_with_fres): Likewise. * sframe.c (sframe_fre_check_range_p): Likewise. (sframe_fde_create_func_info): Likewise. libsframe/testsuite/ * libsframe.encode/encode-1.c: Likewise. * libsframe.find/findfre-1.c: Likewise. * libsframe.find/findfunc-1.c: Likewise. * libsframe.find/plt-findfre-1.c: Likewise. * libsframe.find/plt-findfre-2.c: Likewise.
2026-01-15[SFrame-V3] include: gas: libsframe: add 8-bits of func_info2 for ↵Indu Bhagat1-2/+2
extensibility in FDE The existing field func_info (in the SFrame FDE) is used to convey important information around the encoding and interpretation of the rest of the stack trace data for the respective SFrame FDE: the SFrame FRE type, SFrame FDE PC type, etc. Currently there is 1 bit left for AArch64, and 2 bits for AMD64, s390x (and other future ABIs to be supported). Provision some additional space now (specifically an additional 8-bits) for future needs for V3 and beyond. Compared to V2, this now increases the size of SFrame FDE by 1 byte in V3. In this patch, the additional func_info2 byte is not used functionally yet. Hence, rather mechanical changes in libsframe, bfd and libsframe/testsuite accompany. We will put func_info2 into use in a later patch by reserving 5 of these bits for SFrame FDE types. With the addition of a new byte for additional func info (func_info2), add a new arg to allow usecases like textual dumper to get all data members in one API: sframe_decoder_get_funcdesc_v3. To keep the APIs symmetric looking, add new arg to sframe_encoder_add_funcdesc_v3 too. Since bfd uses these APIs, carry out the mechanical change in the respective APIs too. And of course, the testsuite which exercises these APIs. bfd/ * elf-sframe.c (_bfd_elf_merge_section_sframe): Get and set func_info2. * elf64-s390.c (_bfd_s390_elf_create_sframe_plt): Pass 0 for func_info2 for SFrame FDE for PLT. * elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Likewise. gas/ * gen-sframe.c (output_sframe_funcdesc): Emit the uint8_t for func_info2. libsframe/ * sframe-dump.c (dump_sframe_func_with_fres): * sframe.c (sframe_fde_tbl_init): Handle the new additional member. (sframe_encoder_write_fde): Likewise. * sframe.c (sframe_decoder_get_funcdesc_v3): Update func_info2. libsframe/testsuite/ * libsframe.decode/DATA2: Update data file with SFrame section data. * libsframe.encode/encode-1.c: Pass 0 for func_info2 arg. * libsframe.find/findfre-1.c: Likewise. * libsframe.find/findfunc-1.c: Likewise. * libsframe.find/plt-findfre-1.c: Likewise. * libsframe.find/plt-findfre-2.c: Likewise. include/ * sframe.h: Add new uint8_t sfde_func_info2 to sframe_func_desc_entry_v3. * sframe-api.h (sframe_decoder_get_funcdesc_v3): New arg. (sframe_encoder_add_funcdesc_v3): Likewise.
2026-01-15[SFrame-V3] include: libsframe: bfd: gas: testsuite: support for signed ↵Indu Bhagat1-11/+11
64-bit offset in SFrame FDE This change enables support text > 2 GiB in SFrame format. Each SFrame FDE needs to hold information about the start PC of the function it pertains to. Currently, the field 'sfde_func_start_address' in SFrame FDE is encoded as a 32-bit offset to the start PC of the function from the field itself. In SFrame V2, this offset was a signed 32-bit offset. The signedness gives the flexibility of having .sframe ELF section before or after the .text* sections. But the size of 32-bit puts the limitation that .sframe togther with the .text* sections must fit the 2 GiB range. Currently, if the linker sees the offset not representable as 32-bit signed offset, it issues an error (not seen in the wild, simulated by forcing a function to align via an '.align 2147483648' directive): test.o:(.sframe+0x1c): relocation truncated to fit: R_X86_64_PC32 against `.text' make: *** [Makefile:7: all] Error 1 ATM, EH Frame also suffers with the same issue. Moving forward, some cloud applications have been shown to be nearing 1.5 GiB threshold. Extending the offset to int64_t now seems to be good choice to make now for future-proof'ing the sections. The use of int64_t offset is done for all SFrame V3 sections. This bump from int32_t to int64_t should not lead to an increase in the size of SFrame sections, because of the following additional changes to the SFrame FDE specification: - Reduce the type of sfde_func_num_fres (from uint32_t to uint16_t) - Remove the 2 bytes of padding (sfde_func_padding2). These served the two-fold purpose of keeping FDE data aligned _and_ unused space for future needs. Now that the offset is int64_t, start using the sframe_decoder_get_funcdesc_v3 () instead of sframe_decoder_get_funcdesc_v2 () in GNU ld. This patch changes the offset type in the SFrame FDE definition to an int64_t. No further changes in gas are necessary because the code already accounts for writing out as per the size of the member of the struct: emit_expr (&exp, sizeof_member (sframe_func_desc_entry, sfde_func_start_offset)); bfd/ * elf-sframe.c (sframe_read_value): Signed offset for start PC is 8-bytes now. (_bfd_elf_merge_section_sframe): Likewise. * elf64-s390.c (_bfd_s390_elf_create_sframe_plt): Use V3 API. (elf_s390_finish_dynamic_sections): Signed offset for start PC is 8-bytes now. * elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Use V3 API. (_bfd_x86_elf_finish_dynamic_sections): Signed offset for start PC is 8-bytes now. gas/ * sframe.c (output_sframe_funcdesc): Rename to sfde_func_start_offset. libsframe/ * libsframe/sframe.c (sframe_fde_tbl_init): Rename to sfde_func_start_offset. (flip_fde): Likewise. (sframe_decoder_get_secrel_func_start_addr): Use int64_t. (sframe_fre_check_range_p): Likewise. (sframe_decoder_get_offsetof_fde_start_addr): Rename to sfde_func_start_offset. (sframe_get_funcdesc_with_addr_internal): Use int64_t. (sframe_find_fre): Likewise. (sframe_encoder_get_offsetof_fde_start_addr): Rename to sfde_func_start_offset. (sframe_encoder_add_funcdesc_internal): Use int64_t. (sframe_encoder_add_funcdesc): Likewise. And rename to sfde_func_start_offset. (sframe_encoder_write_fde): Rename to sfde_func_start_offset. libsframe/testsuite/ * libsframe.decode/DATA2: Regenerate the data file. * libsframe.encode/encode-1.c: Use int64_t for start pc offset. * libsframe.find/findfre-1.c: Likewise. * libsframe.find/findfunc-1.c: Likewise. * libsframe.find/plt-findfre-1.c: Likewise. * libsframe.find/plt-findfre-2.c: Likewise. include/ * sframe-api.h (sframe_find_fre): Update arg type to int64_t. (sframe_encoder_add_funcdesc): Likewise. * sframe.h: Change data type to int64_t.
2026-01-01Update year range in copyright notice of binutils filesAlan Modra1-1/+1
Avoid warnings about invalid escapes in etc/update-copyright.py by using raw strings, add BinutilsFilter to skip psql.rc and add "Kalray SA." as another copyright holder.
2025-12-19libsframe: testsuite: fix build failureIndu Bhagat1-1/+1
Previous commit 4651bea1193 to fix PR ld/32789 missed making the necessary changes to the libsframe testsuite. libsframe/testsuite/ PR ld/32789 PR libsframe/33731 * libsframe.encode/encode-1.c: Add additional arg for sorting FDEs. Set to true. * libsframe.find/findfre-1.c: Likewise. * libsframe.find/findfunc-1.c: Likewise. * libsframe.find/plt-findfre-1.c: Likewise. * libsframe.find/plt-findfre-2.c: Likewise.
2025-10-06libsframe: testsuite: make test names uniqueIndu Bhagat1-2/+2
Previous commit 4dc07bf6 missed making some of the testnames in encode-1 unique. libsframe/testsuite/ PR libsframe/33437 * libsframe.encode/encode-1.c: Update test name to ensure they are unique.
2025-10-02libsframe: testsuite: make test names uniqueIndu Bhagat1-17/+7
Fix PR libsframe/33437 - libsframe test names are not unique The TEST () macro definition originally in plt-findfre-2.c, was being used to differentiate between multiple runs of the testcases. Adapt that definition a bit to allow for a variable number of arguments following the test condition: A test name format string may be used by macro users, such that the name of the tests are unique. Move the new variadic TEST macro definition in the testsuite's common header sframe-test.h, and use it throughout the testsuite. Reviewed-by: Jens Remus <jremus@linux.ibm.com> libsframe/testsuite/ PR libsframe/33437 * libsframe.decode/be-flipping.c: Use new TEST macro with suffix. * libsframe.decode/frecnt-1.c: Likewise. * libsframe.decode/frecnt-2.c: Likewise. * libsframe.encode/encode-1.c: Likewise. * libsframe.find/findfre-1.c: Likewise. * libsframe.find/findfunc-1.c: Likewise. * libsframe.find/plt-findfre-1.c: Likewise. * libsframe.find/plt-findfre-2.c: Likewise. * sframe-test.h: Move the TEST macro definition to this testsuite header.
2025-09-12libsframe: testsuite: Fix testsuite build on Solaris [PR33168]Rainer Orth1-11/+1
As reported in PR libsframe/33168, the libsframe tests don't build on Solaris. The failure is In file included from libsframe/testsuite/libsframe.decode/be-flipping.c:28: /usr/include/dejagnu.h:48:1: error: conflicting types for ‘wait’; have ‘void(void)’ 48 | wait (void) | ^~~~ In file included from /usr/include/stdlib.h:16, from libsframe/testsuite/libsframe.decode/be-flipping.c:21: /usr/include/sys/wait.h:85:14: note: previous declaration of ‘wait’ with type ‘pid_t(int *)’ {aka ‘long int(int *)’} 85 | extern pid_t wait(int *); | ^~~~ We have a combination of two factors here: * Solaris <stdlib.h> has and configure.ac predefines __EXTENSIONS__ due to the use of AC_USE_SYSTEM_EXTENSIONS. * This conflicts with <dejagnu.h>'s definition void wait (void) { ... } While this version of wait was removed in upstream DejaGnu, the removal only happened after the latest release, 1.6.3. To avoid this, I've moved all testsuite includes into a new sframe-test.h, adding a workaround for the wait conflict. -Wall and -I$(srcdir) have been removed from AM_CPPFLAGS since they don't seem to be needed. To fix the Makefile fragment duplication, the local.mk files now use $(testsuite_LDADD) and $(testsuite_CPPFLAGS) throughout. Tested on {i386,amd64}-pc-solaris2.11, {sparc,sparcv9}-sun-solaris2.11, {x86_64,i686}-pc-linux-gnu, and amd64-pc-freebsd14.0. Coauthored-By: Alan Modra <amodra@gmail.com> 2025-08-31 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> Alan Modra <amodra@gmail.com> libsframe: PR libsframe/33168 * testsuite/sframe-test.h: New file. * testsuite/libsframe.decode/be-flipping.c: Replace includes by sframe-test.h. * testsuite/libsframe.decode/frecnt-1.c: Likewise. * testsuite/libsframe.decode/frecnt-2.c: Likewise. * testsuite/libsframe.encode/encode-1.c: Likewise. * testsuite/libsframe.find/findfre-1.c: Likewise. * testsuite/libsframe.find/findfunc-1.c: Likewise. * testsuite/libsframe.find/plt-findfre-1.c: Likewise. * testsuite/libsframe.find/plt-findfre-2.c: Likewise. * Makefile.am (AM_CPPFLAGS): Remove -I$(srcdir). * Makefile.in: Regenerate. * testsuite/local.mk (testsuite_LDADD): New variable. (testsuite_CPPFLAGS): Likewise. * testsuite/libsframe.decode/local.mk: Use $(testsuite_LDADD), $(testsuite_CPPFLAGS). * testsuite/libsframe.encode/local.mk: Likewise. * testsuite/libsframe.find/local.mk: Likewise.
2025-08-17libsframe: testsuite: use SFrame V2 specific APIsIndu Bhagat1-4/+6
Use sframe_encoder_add_funcdesc_v2 instead of sframe_encoder_add_funcdesc. Similarly, use sframe_decoder_get_funcdesc_v2 instead of sframe_decoder_get_funcdesc. sframe_encoder_add_funcdesc, and sframe_decoder_get_funcdesc were first added for SFrame V1. For the purpose of these testcases, the two V2 APIs are (almost) functionally equivalent. In future, we may want to make sframe_encoder_add_funcdesc and sframe_decoder_get_funcdesc internal to libsframe only. Using the V2 named APIs is better for clarity as well. libsframe/testsuite/ * libsframe.encode/encode-1.c: Use V2 named APIs instead. * libsframe.find/findfre-1.c: Likewise. * libsframe.find/findfunc-1.c: Likewise. * libsframe.decode/be-flipping.c: Likewise. * libsframe.decode/frecnt-1.c: Likewise. * libsframe.decode/frecnt-2.c: Likewise.
2025-08-17libsframe: testsuite: reduce usage of magic numbers from encode-1.cIndu Bhagat1-14/+42
Previously, some of the libsframe tests were updated to reduce the usage of magic numbers. This patch makes encode-1.c follow similar coding style as other tests, reducing the number of magic constants. libsframe/testsuite/ * libsframe.encode/encode-1.c: Avoid magic numbers.
2025-07-06bfd: gas: ld: libsframe: adopt new encoding for FDE func start addr fieldIndu Bhagat1-3/+4
This patch convenes a set of changes in bfd, gas, ld, libsframe towards moving to the new encoding for the 'sfde_func_start_address' field in SFrame FDE. First, gas must now mark all SFrame sections with the new flag SFRAME_F_FDE_FUNC_START_PCREL. gas was already emitting the field in the said encoding. * gas/gen-sframe.c (output_sframe_internal): Emit the flag SFRAME_F_FDE_FUNC_START_PCREL. Similarly for ld, adopt the new semantics of sfde_func_start_address consistently. This means: - When merging SFrame sections, check that all input SFrame sections have the SFRAME_F_FDE_FUNC_START_PCREL flag set. If the check fails, ld errors out. - When merging SFrame sections, keep even the in-memory contents of the FDE function start address (buffer passed to libsframe sframe_encoder_write () for writing out) encoded in the new semantics. While it is, in theory, possible that instead of doing this change here, we adjust the value of sfde_func_start_address at the final write (sframe_encoder_write) time. But latter is not favorable for maintenanance and may be generally confusing for developers. - When creating SFrame for PLT entries, emit flag SFRAME_F_FDE_FUNC_START_PCREL. include/ * sframe-api.h (SFRAME_F_LD_MUSTHAVE_FLAGS): New definition. bfd/ * elf-sframe.c (_bfd_elf_merge_section_sframe): Check for flag combinatation SFRAME_F_LD_MUSTHAVE_FLAGS set for all input and output SFrame sections. If not, error out. Also, adopt the new semantics of function start address encoding. * bfd/elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Emit flag SFRAME_F_FDE_FUNC_START_PCREL. Next, for dumping SFrame sections, now that we are emitting the same encoding in GAS, non-relocatable and relocatable SFrame links, it is the time to set relocate to TRUE in debug_displays[]. binutils/ * dwarf.c (struct dwarf_section_display): Allow sframe sections to now be relocated. gas/testsuite/ * gas/cfi-sframe/cfi-sframe-aarch64-pac-ab-key-1.d: Update the test. Relocatable SFrame sections now display non-zero value (appropriate function start address). Now, as the SFrame sections on-disk and in-memory use the new semantics of sfde_func_start_address encoding (i.e., function start address is the offset from the sfde_func_start_address field to the start PC), the calculation to make it human readable (i.e., relatable to the addresses in .text sections) needs adjustment. libsframe/ * sframe-dump.c (dump_sframe_func_with_fres): Adjust the function start address for dumping. Now that both the emission of the new encoding, and the relocation of sections before dumping them is in place, it is time to adjust the testcases. gas/testsuite/ * gas/cfi-sframe/cfi-sframe-aarch64-1.d: Update expected output to include SFRAME_F_FDE_FUNC_START_PCREL instead of NONE. * gas/cfi-sframe/cfi-sframe-aarch64-2.d: Likewise. * gas/cfi-sframe/cfi-sframe-aarch64-3.d: Likewise. * gas/cfi-sframe/cfi-sframe-aarch64-4.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-1.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-10.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-11.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-2.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-3.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-4.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-5.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-6.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-7.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-8.d: Likewise. * gas/cfi-sframe/cfi-sframe-common-9.d: Likewise. * gas/cfi-sframe/cfi-sframe-x86_64-1.d: Likewise. * gas/cfi-sframe/cfi-sframe-x86_64-2.d: Likewise. * gas/cfi-sframe/cfi-sframe-x86_64-empty-1.d: Likewise. * gas/cfi-sframe/cfi-sframe-x86_64-empty-2.d: Likewise. * gas/cfi-sframe/cfi-sframe-x86_64-empty-3.d: Likewise. * gas/cfi-sframe/cfi-sframe-x86_64-empty-4.d: Likewise. * gas/cfi-sframe/common-empty-1.d: Likewise. * gas/cfi-sframe/common-empty-2.d: Likewise. * gas/cfi-sframe/common-empty-3.d: Likewise. * gas/scfi/x86_64/scfi-cfi-sections-1.d: Likewise. * gas/scfi/x86_64/scfi-dyn-stack-1.d: Likewise. ld/testsuite/ * ld-aarch64/sframe-simple-1.d: Update expected output to include SFRAME_F_FDE_FUNC_START_PCREL. * ld-x86-64/sframe-ibt-plt-1.d: Likewise. * ld-x86-64/sframe-plt-1.d: Likewise. * ld-x86-64/sframe-pltgot-1.d: Likewise. * ld-x86-64/sframe-pltgot-2.d: Likewise. * ld-x86-64/sframe-simple-1.d: Likewise. Naturally, the change of semantics for 'SFrame FDE function start address' has consequences on the implementation in libsframe. As per the new semantics: - Function start address in the SFrame FDE (sfde_func_start_address) is an offset from the FDE function start address field to the start PC of the associated function. Note that, the libsframe library brings the SFrame section contents into its own memory to create a sframe_decoder_ctx object via sframe_decode (). Many internal and user-interfacing APIs then may use sframe_decoder_ctx object to interact and fulfill the work. In context of changing semantics for sfde_func_start_address, following relevant examples may help understand the impact: - sframe_find_fre () finds a the SFrame stack trace data (SFrame FRE) given a lookup offset (offset of lookup_pc from the start of SFrame section). Now that the sfde_func_start_address includes the distance from the sfde_func_start_address field to the start of SFrame section itself, the comparison checks of sfde_func_start_address with the incoming lookup offset need adjustment. - Some internal functions (sframe_get_funcdesc_with_addr_internal () finds SFrame FDE by using binary seach comparing sfde_func_start_address fields, etc.) need adjustments. - sframe_encoder_write () sorts the SFrame FDEs before writing out the SFrame data. Sorting of SFrame FDE via the internal function sframe_sort_funcdesc() needs adjustments: the new encoding of sfde_func_start_address means the distances are not from the same anchor, so cannot be sorted directly. This patch takes the approach of adding a new internal function: - sframe_decoder_get_secrel_func_start_addr (): This function returns the offset of the start PC of the function from the start of SFrame section, i.e., it gives a section-relative offset. As the sframe_decoder_get_secrel_func_start_addr () API needs the value of the function index in the FDE list, another internal API needs sframe_fre_check_range_p () adjustments too. Sorting the FDEs (via sframe_sort_funcdesc ()) is done by first bringing all offsets in sfde_func_start_address relative to start of SFrame section, followed by sorting, and then readjusting the offsets accroding to the new position in the FDE list. libsframe/ * sframe.c (sframe_decoder_get_secrel_func_start_addr): New static function. (sframe_fre_check_range_p): Adjust the interface a bit. (sframe_get_funcdesc_with_addr_internal): Use sframe_decoder_get_secrel_func_start_addr () when comparing sfde_func_start_address with user input offset. (sframe_find_fre): Adopt the new semantics. (sframe_sort_funcdesc): Likewise. For the libsframe testsuite, use the new encoding for FDE func start addr: distance between the FDE sfde_func_start_address field and the start PC of the function itself. Use SFRAME_F_FDE_FUNC_START_PCREL flag, though the sframe_encode () interface in libsframe applies no sanity checks for the encoding itself. libsframe/testsuite/ * libsframe.find/findfre-1.c: Adjust to use the new SFRAME_F_FDE_FUNC_START_PCREL specific encoding. * libsframe.find/findfunc-1.c: Likewise. * libsframe.find/plt-findfre-1.c: Likewise. * libsframe/testsuite/libsframe.decode/DATA2: Update data file due to usage of new SFRAME_F_FDE_FUNC_START_PCREL flag. * libsframe/testsuite/libsframe.encode/encode-1.c: Use flag SFRAME_F_FDE_FUNC_START_PCREL.
2025-01-01Update year range in copyright notice of binutils filesAlan Modra1-1/+1
2024-01-04Update year range in copyright notice of binutils filesAlan Modra1-1/+1
Adds two new external authors to etc/update-copyright.py to cover bfd/ax_tls.m4, and adds gprofng to dirs handled automatically, then updates copyright messages as follows: 1) Update cgen/utils.scm emitted copyrights. 2) Run "etc/update-copyright.py --this-year" with an extra external author I haven't committed, 'Kalray SA.', to cover gas testsuite files (which should have their copyright message removed). 3) Build with --enable-maintainer-mode --enable-cgen-maint=yes. 4) Check out */po/*.pot which we don't update frequently.
2023-01-01Update year range in copyright notice of binutils filesAlan Modra1-1/+1
The newer update-copyright.py fixes file encoding too, removing cr/lf on binutils/bfdtest2.c and ld/testsuite/ld-cygwin/exe-export.exp, and embedded cr in binutils/testsuite/binutils-all/ar.exp string match.
2022-12-15libsframe asan: avoid generating misaligned loadsIndu Bhagat1-8/+8
There are two places where unaligned loads were seen on aarch64: - #1. access to the SFrame FRE stack offsets in the in-memory representation/abstraction provided by libsframe. - #2. access to the SFrame FRE start address in the on-disk representation of the frame row entry. For #1, we can fix this by reordering the struct members of sframe_frame_row_entry in libsframe/sframe-api.h. For #2, we need to default to using memcpy instead, and copy out the bytes to a location for output. SFrame format is an unaligned on-disk format. As such, there are other blobs of memory in the on-disk SFrame FRE that are on not on their natural boundaries. But that does not pose further problems yet, because the users are provided access to the on-disk SFrame FRE data via libsframe's sframe_frame_row_entry, the latter has its' struct members aligned on their respective natural boundaries (and initialized using memcpy). PR 29856 libsframe asan: load misaligned at sframe.c:516 ChangeLog: PR libsframe/29856 * bfd/elf64-x86-64.c: Adjust as the struct members have been reordered. * libsframe/sframe.c (sframe_decode_fre_start_address): Use memcpy to perform 16-bit/32-bit reads. * libsframe/testsuite/libsframe.encode/encode-1.c: Adjust as the struct members have been reordered. include/ChangeLog: PR libsframe/29856 * sframe-api.h: Reorder fre_offsets for natural alignment.
2022-12-09libsframe: rename API sframe_fde_func_info to sframe_fde_create_func_infoIndu Bhagat1-4/+4
The new name better reflects the purpose of the function. ChangeLog: * bfd/elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Use new name. * libsframe/sframe.c (sframe_fde_create_func_info): Rename sframe_fde_func_info to this. * libsframe/testsuite/libsframe.encode/encode-1.c: Use new name. include/ChangeLog: * sframe-api.h (sframe_fde_create_func_info): Rename sframe_fde_func_info to this.
2022-11-15libsframe: add the SFrame libraryWeimin Pan1-0/+177
libsframe is a library that allows you to: - decode a .sframe section - probe and inspect a .sframe section - encode (and eventually write) a .sframe section. This library is currently being used by the linker, readelf, objdump. This library will also be used by the SFrame unwinder which is still to be upstream'd. The file include/sframe-api.h defines the user-facing APIs for decoding, encoding and probing .sframe sections. A set of error codes together with their error message strings are also defined. Endian flipping is performed automatically at read and write time, if cross-endianness is detected. ChangeLog: * Makefile.def: Add libsframe as new module with its dependencies. * Makefile.in: Regenerated. * binutils/Makefile.am: Add libsframe. * binutils/Makefile.in: Regenerated. * configure: Regenerated * configure.ac: Add libsframe to host_libs. * libsframe/Makefile.am: New file. * libsframe/Makefile.in: New file. * libsframe/aclocal.m4: New file. * libsframe/config.h.in: New file. * libsframe/configure: New file. * libsframe/configure.ac: New file. * libsframe/sframe-error.c: New file. * libsframe/sframe-impl.h: New file. * libsframe/sframe.c: New file. include/ChangeLog: * sframe-api.h: New file. testsuite/ChangeLog: * libsframe/testsuite/Makefile.am: New file. * libsframe/testsuite/Makefile.in: Regenerated. * libsframe/testsuite/libsframe.decode/Makefile.am: New file. * libsframe/testsuite/libsframe.decode/Makefile.in: Regenerated. * libsframe/testsuite/libsframe.decode/decode.exp: New file. * libsframe/testsuite/libsframe.encode/Makefile.am: Likewise. * libsframe/testsuite/libsframe.encode/Makefile.in: Regenerated. * libsframe/testsuite/libsframe.encode/encode.exp: New file. * libsframe/testsuite/libsframe.encode/encode-1.c: Likewise. * libsframe/testsuite/libsframe.decode/be-flipping.c: Likewise. * libsframe/testsuite/libsframe.decode/frecnt-1.c: Likewise. * libsframe/testsuite/libsframe.decode/frecnt-2.c: Likewise. * libsframe/testsuite/libsframe.decode/DATA-BE: New file. * libsframe/testsuite/libsframe.decode/DATA1: Likewise. * libsframe/testsuite/libsframe.decode/DATA2: Likewise.