Skip to content
Snippets Groups Projects
  1. Feb 02, 2023
  2. Jan 24, 2023
    • Indu Bhagat's avatar
      libsframe/doc: fix some warnings · 436bcab7
      Indu Bhagat authored
      'make pdf' in libsframe shows some warnings, some of which (especially
      the Overfull warnings) are causing undesirable effects on the rendered
      output.  Few examples of the warnings:
      
        Underfull \hbox (badness 10000) in paragraph at lines 406--407
         @texttt pauth_
      
        Underfull \hbox (badness 10000) in paragraph at lines 407--410
         @textrm Specify which key is used for signing the return
      
        ...
      
        Overfull \hbox (2.0987pt too wide) in paragraph at lines 412--413
         @texttt fdetype[]|
      
        ...
      
        Overfull \hbox (28.87212pt too wide) in paragraph at lines 446--447
         @textrm SFRAME[]FDE[]TYPE[]PCMASK|
      
        ...
      
      This patch adjusts column widths of the affected cells to fix a subset
      of these warnings.  For the rest of the warnings, use explicit newline
      command to fix them.
      
      libsframe/
      	* doc/sframe-spec.texi: Fix various underfull and overfull
      	warnings.
      436bcab7
  3. Jan 19, 2023
  4. Jan 13, 2023
    • Indu Bhagat's avatar
      libsframe: replace an strncat with strcat · 68e0003e
      Indu Bhagat authored
      Calling strncat with the size of the src string is not so meaningful.
      The length argument to strncat should specify the remaining bytes
      bytes in the destination; although in this case, it appears to be
      unncessary altogether to use strncat in the first place.
      
      libsframe/
              * sframe-dump.c (dump_sframe_func_with_fres): Use of strcat is
      	just as fine.
      68e0003e
  5. Jan 06, 2023
    • Indu Bhagat's avatar
      sframe: fix the defined SFRAME_FRE_TYPE_*_LIMIT constants · 725a19bf
      Indu Bhagat authored
      An earlier commit 3f107464 defined the SFRAME_FRE_TYPE_*_LIMIT
      constants.  These constants are used (by gas and libsframe) to pick an
      SFrame FRE type based on the function size.  Those constants, however,
      were buggy, causing the generated SFrame sections to be bloated as
      SFRAME_FRE_TYPE_ADDR2/SFRAME_FRE_TYPE_ADDR4 got chosen more often than
      necessary.
      
      gas/
      	* sframe-opt.c (sframe_estimate_size_before_relax): Use
      	typecast.
      	(sframe_convert_frag): Likewise.
      
      libsframe/
      	* sframe.c (sframe_calc_fre_type): Use a more appropriate type
      	for argument.  Adjust the check for SFRAME_FRE_TYPE_ADDR4_LIMIT
      	to keep it warning-free but meaningful.
      
      include/
      	* sframe-api.h (sframe_calc_fre_type): Use a more appropriate
      	type for the argument.
      	* sframe.h (SFRAME_FRE_TYPE_ADDR1_LIMIT): Correct the constant.
      	(SFRAME_FRE_TYPE_ADDR2_LIMIT): Likewise.
      	(SFRAME_FRE_TYPE_ADDR4_LIMIT): Likewise.
      725a19bf
    • Indu Bhagat's avatar
      libsframe: adjust an incorrect check in flip_sframe · cd9aea32
      Indu Bhagat authored
      When sframe_encoder_write needs to flip the buffer containing the SFrame
      section before writing, it is not necessary that the SFrame FDES are in
      the order of their sfde_func_start_fre_off.  On the contrary, SFrame
      FDEs will be sorted in the order of their start address.  So, remove
      this incorrect assumption which is basically assuming that the last
      sfde_func_start_fre_off seen will help determine the end of the flipped
      buffer.
      
      The function now keeps track of the bytes_flipped and then compares it with
      the expected value.  Also, added two more checks at appropriate places:
       - check that the SFrame FDE read is within bounds
       - check that the SFrame FRE read is within bounds
      
      libsframe/
      
      	* sframe.c (flip_sframe): Adjust an incorrect check.
      	Add other checks to ensure reads are within the buffer size.
      cd9aea32
  6. Jan 01, 2023
  7. Dec 25, 2022
    • Indu Bhagat's avatar
      libsframe: write out SFrame FRE start address correctly · 68bb0d27
      Indu Bhagat authored
      The following test was failing on ppc64 and s390x:
        "FAIL: encode-1: Encode buffer match"
      
      The offending stub was how we memcpy the FRE start address to the buffer
      (on-disk format).  When the host is big-endian, the address of the
      source buffer for the memcpy needs to point to the uint8_t/uint16_t sized
      value of the FRE start addr, not uint32_t sized value; we intend to copy
      out only the fre_start_addr_sz number of bytes.
      
      ChangeLog:
      
      	* libsframe/sframe.c (sframe_encoder_write_fre_start_addr): New
      	function.
      	(sframe_encoder_write_fre): Use it instead of memcpy.
      68bb0d27
  8. Dec 23, 2022
    • Indu Bhagat's avatar
      libsframe: testsuite: fix memory leaks in testcases · 28f1a767
      Indu Bhagat authored
      ChangeLog:
      
      	* libsframe/testsuite/libsframe.decode/be-flipping.c: Free
      	SFrame buffer.
      	* libsframe/testsuite/libsframe.decode/frecnt-1.c: Likewise.
      	* libsframe/testsuite/libsframe.decode/frecnt-2.c: Likewise.
      28f1a767
    • Indu Bhagat's avatar
      libsframe: fix a memory leak in sframe_decode · 995bc597
      Indu Bhagat authored
      sframe_decode () needs to malloc a temporary buffer of the same size as
      the input buffer (containing the SFrame section bytes) when endian
      flipping is needed.  The decoder keeps the endian flipped contents in
      this buffer for its usage.  This code is necessary when the target
      endianneess is not the same as host endianness.
      
      The malloc'd buffer needs to be kept track of, so that it can freed up in
      sframe_decoder_free () later.
      
      ChangeLog:
      
      	* libsframe/sframe-impl.h (struct sframe_decoder_ctx): Add new
      	member to keep track of the internally malloc'd buffer.
      	* libsframe/sframe.c (sframe_decoder_free): Free it up.
      	(sframe_decode): Update the reference to the buffer.
      995bc597
  9. Dec 22, 2022
  10. Dec 17, 2022
  11. Dec 15, 2022
    • Indu Bhagat's avatar
      libsframe asan: avoid generating misaligned loads · 8c078abd
      Indu Bhagat authored
      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.
      8c078abd
  12. Dec 09, 2022
    • Indu Bhagat's avatar
      libsframe: rename API sframe_fde_func_info to sframe_fde_create_func_info · b659fb35
      Indu Bhagat authored
      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.
      b659fb35
    • Indu Bhagat's avatar
      sframe: gas: libsframe: define constants and remove magic numbers · 3f107464
      Indu Bhagat authored
      Define constants in sframe.h for the various limits associated with the
      range of offsets that can be encoded in the start address of an SFrame
      FRE. E.g., sframe_frame_row_entry_addr1 is used when start address
      offset can be encoded as 1-byte unsigned value.
      
      Update the code in gas to use these defined constants as it checks for
      these limits, and remove the usage of magic numbers.
      
      ChangeLog:
      
      	* gas/sframe-opt.c (sframe_estimate_size_before_relax):
      	(sframe_convert_frag): Do not use magic numbers.
      	* libsframe/sframe.c (sframe_calc_fre_type): Likewise.
      
      include/ChangeLog:
      
      	* sframe.h (SFRAME_FRE_TYPE_ADDR1_LIMIT): New constant.
      	(SFRAME_FRE_TYPE_ADDR2_LIMIT): Likewise.
      	(SFRAME_FRE_TYPE_ADDR4_LIMIT): Likewise.
      3f107464
    • Indu Bhagat's avatar
      libsframe: minor formatting nits · 1e2a61ef
      Indu Bhagat authored
      ChangeLog:
      
      	* libsframe/sframe.c: Fix formatting nits.
      1e2a61ef
  13. Nov 24, 2022
    • Indu Bhagat's avatar
      sframe/doc: remove usage of xrefautomaticsectiontitle · cbff1430
      Indu Bhagat authored
      xrefautomaticsectiontitle appears to be available from texinfo 5.0 or
      greater.  As such, it is not worthwhile to add requirement for a minimum
      necessary makeinfo version.  So remove the usage of it.
      
      Also align node name with section title where possible.
      
      ChangeLog:
      
      	* libsframe/doc/sframe-spec.texi: Remove usage of
      	xrefautomaticsectiontitle.
      cbff1430
  14. Nov 16, 2022
    • Indu Bhagat's avatar
      doc: add SFrame spec file · c1c57352
      Indu Bhagat authored
      ChangeLog:
      
      	* libsframe/Makefile.am: Add info-in-builddir to
      	  AUTOMAKE_OPTIONS. Include doc/local.mk.
      	* libsframe/Makefile.in: Regenerated.
      	* libsframe/configure: Likewise.
      	* libsframe/configure.ac: Check for makeinfo and set BUILD_INFO.
      	* libsframe/doc/local.mk: New file.
      	* libsframe/doc/sframe-spec.texi: Likewise.
      c1c57352
    • Indu Bhagat's avatar
      readelf/objdump: support for SFrame section · 42b6953b
      Indu Bhagat authored
      This patch adds support for SFrame in readelf and objdump. The arguments
      of --sframe are optional for both readelf and objdump.
      
      include/ChangeLog:
      
      	* sframe-api.h (dump_sframe): New function declaration.
      
      ChangeLog:
      
      	* binutils/Makefile.am: Add dependency on libsframe for
      	readelf and objdump.
      	* binutils/Makefile.in: Regenerate.
      	* binutils/doc/binutils.texi: Document --sframe=[section].
      	* binutils/doc/sframe.options.texi: New file.
      	* binutils/objdump.c: Add support for SFrame format.
      	* binutils/readelf.c: Likewise.
      	* include/sframe-api.h: Add new API for dumping .sframe
      	section.
      	* libsframe/Makefile.am: Add sframe-dump.c.
      	* libsframe/Makefile.in: Regenerate.
      	* libsframe/sframe-dump.c: New file.
      42b6953b
    • Indu Bhagat's avatar
      bfd: linker: merge .sframe sections · cf0e0a0b
      Indu Bhagat authored
      The linker merges all the input .sframe sections.  When merging, the
      linker verifies that all the input .sframe sections have the same
      abi/arch.
      
      The linker uses libsframe library to perform key actions on the
      .sframe sections - decode, read, and create output data.  This
      implies buildsystem changes to make and install libsframe before
      libbfd.
      
      The linker places the output .sframe section in a new segment of its
      own: PT_GNU_SFRAME.  A new segment is not added, however, if the
      generated .sframe section is empty.
      
      When a section is discarded from the final link, the corresponding
      entries in the .sframe section for those functions are also deleted.
      
      The linker sorts the SFrame FDEs on start address by default and sets
      the SFRAME_F_FDE_SORTED flag in the .sframe section.
      
      This patch also adds support for generation of SFrame unwind
      information for the .plt* sections on x86_64.  SFrame unwind info is
      generated for IBT enabled PLT, lazy/non-lazy PLT.
      
      The existing linker option --no-ld-generated-unwind-info has been
      adapted to include the control of whether .sframe unwind information
      will be generated for the linker generated sections like PLT.
      
      Changes to the linker script have been made as necessary.
      
      ChangeLog:
      
      	* Makefile.def: Add install dependency on libsframe for libbfd.
      	* Makefile.in: Regenerated.
      	* bfd/Makefile.am: Add elf-sframe.c
      	* bfd/Makefile.in: Regenerated.
      	* bfd/bfd-in2.h (SEC_INFO_TYPE_SFRAME): Regenerated.
      	* bfd/configure: Regenerate.
      	* bfd/configure.ac: Add elf-sframe.lo.
      	* bfd/elf-bfd.h (struct sframe_func_bfdinfo): New struct.
      	(struct sframe_dec_info): Likewise.
      	(struct sframe_enc_info): Likewise.
      	(struct elf_link_hash_table): New member for encoded .sframe
      	object.
      	(struct output_elf_obj_tdata): New member.
      	(elf_sframe): New access macro.
      	(_bfd_elf_set_section_sframe): New declaration.
      	* bfd/elf.c (get_segment_type): Handle new segment
      	PT_GNU_SFRAME.
      	(bfd_section_from_phdr): Likewise.
      	(get_program_header_size): Likewise.
      	(_bfd_elf_map_sections_to_segments): Likewise.
      	* bfd/elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties): Add
      	contents to the .sframe sections or .plt* entries.
      	* bfd/elflink.c (elf_section_ignore_discarded_relocs): Handle
      	SEC_INFO_TYPE_SFRAME.
      	(_bfd_elf_default_action_discarded): Handle .sframe section.
      	(elf_link_input_bfd): Merge .sframe section.
      	(bfd_elf_final_link): Write the output .sframe section.
      	(bfd_elf_discard_info): Handle discarding .sframe section.
      	* bfd/elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Create
      	.sframe section for .plt and .plt.sec.
      	(_bfd_x86_elf_finish_dynamic_sections): Handle .sframe from
      	.plt* sections.
      	* bfd/elfxx-x86.h (PLT_SFRAME_FDE_START_OFFSET): New
      	definition.
      	(SFRAME_PLT0_MAX_NUM_FRES): Likewise.
      	(SFRAME_PLTN_MAX_NUM_FRES): Likewise.
      	(struct elf_x86_sframe_plt): New structure.
      	(struct elf_x86_link_hash_table): New member.
      	(struct elf_x86_init_table): New members for .sframe
      	creation.
      	* bfd/section.c: Add new definition SEC_INFO_TYPE_SFRAME.
      	* binutils/readelf.c (get_segment_type): Handle new segment
      	PT_GNU_SFRAME.
      	* ld/ld.texi: Update documentation for
      	--no-ld-generated-unwind-info.
      	* ld/scripttempl/elf.sc: Support .sframe sections.
      	* ld/Makefile.am (TESTSFRAMELIB): Use it.
      	(check-DEJAGNU): Likewise.
      	* ld/Makefile.in: Regenerated.
      	* ld/configure.ac (TESTSFRAMELIB): Set to the .so or .a like TESTBFDLIB.
      	* ld/configure: Regenerated.
      	* bfd/elf-sframe.c: New file.
      
      include/ChangeLog:
      
      	* elf/common.h (PT_GNU_SFRAME): New definition.
      	* elf/internal.h (struct elf_segment_map): Handle new segment
      	type PT_GNU_SFRAME.
      
      ld/testsuite/ChangeLog:
      
      	* ld/testsuite/ld-bootstrap/bootstrap.exp: Add SFRAMELIB.
      	* ld/testsuite/ld-aarch64/aarch64-elf.exp: Add new test
      	  sframe-simple-1.
      	* ld/testsuite/ld-aarch64/sframe-bar.s: New file.
      	* ld/testsuite/ld-aarch64/sframe-foo.s: Likewise.
      	* ld/testsuite/ld-aarch64/sframe-simple-1.d: Likewise.
      	* ld/testsuite/ld-sframe/sframe-empty.d: New test.
      	* ld/testsuite/ld-sframe/sframe-empty.s: New file.
      	* ld/testsuite/ld-sframe/sframe.exp: New testsuite.
      	* ld/testsuite/ld-x86-64/sframe-bar.s: New file.
      	* ld/testsuite/ld-x86-64/sframe-foo.s: Likewise.
      	* ld/testsuite/ld-x86-64/sframe-simple-1.d: Likewise.
      	* ld/testsuite/ld-x86-64/sframe-plt-1.d: Likewise.
      	* ld/testsuite/ld-x86-64/sframe-simple-1.d: Likewise.
      	* ld/testsuite/ld-x86-64/x86-64.exp: Add new tests -
      	  sframe-simple-1, sframe-plt-1.
      	* ld/testsuite/lib/ld-lib.exp: Add new proc to check if
      	  assembler supports SFrame section.
      	* ld/testsuite/ld-sframe/discard.d: New file.
      	* ld/testsuite/ld-sframe/discard.ld: Likewise.
      	* ld/testsuite/ld-sframe/discard.s: Likewise.
      cf0e0a0b
    • Weimin Pan's avatar
      libsframe: add the SFrame library · 19e559f1
      Weimin Pan authored
      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.
      19e559f1
Loading