sframe_encoder_add_funcdesc () was added for SFRAME_VERSION_1. This has
since been obsoleted by introduction of SFRAME_VERSION_2 and its
corresponding sframe_decoder_add_funcdesc_v2 API.
Refactor the functionality into an internal-only API:
sframe_encoder_add_funcdesc_internal (). Ensure it returns the error
code for the caller to take necessary action or pass to user.
Keep only two args for sframe_encoder_add_funcdesc: function size and
function start addr. This simple barebone API will be used in a
subsequent commit to adjust the link-time behaviour of SFrame sections.
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
include/
* sframe-api.h (sframe_encoder_add_funcdesc): Remove args to
create the barebone API.
libsframe/
* sframe.c (sframe_encoder_add_funcdesc): Refactor out into
sframe_encoder_add_funcdesc_internal. Change args.
(sframe_encoder_add_funcdesc_v2): Use the new internal API.
* libsframe.ver: Move sframe_encoder_add_funcdesc to 2.1 node.
Currently, when SFrame sections are emitted after linking the input
SFrame sections, the SFrame FDEs are sorted on start PC. Doing so for
relocatable links has no effect (SFrame FDEs remain in place), because
the start PC is unrelocated data. For relocatable links, then, the
emitted SFrame FDEs in the output section remain in the same order as
that in the respective input BFD.
The assembler does not guarantee the emission of SFrame FDEs in the same
order as the placement of the associated .text* sections,
(SFRAME_F_FDE_SORTED is not set in the ET_REL objs generated by GAS).
This means setting SFRAME_F_FDE_SORTED by the linker was wrong when:
- doing relocatable link, and
- the input bfds contain multiple .text sections, say .text.hot,
.text.init, .text.unlikely etc.
For relocatable links, skip sorting the SFrame FDEs. Do not set
SFRAME_F_FDE_SORTED for relocatable links.
This is achieved by adding an explicit argument (bool sort_fde_p) to the
sframe_encoder_write API. Move the API from 2.0 to the 2.1 node as this
is an ABI-incompatible change. Skip bumping the "current" in
libsframe/libtool-version ATM, we will do so closer to release.
When writing of SFrame data for PLT entries, indicate sort_fde_p to
false: these sections are like the other SFrame sections for any other
ET_REL binary.
Add a test in ld/testsuite/ld-sframe/sframe.exp, these tests are run for
all ABIs supported for SFrame. In this test, for object file generated
for pr32789-1a.c:
- the emitted SFrame FDEs by GAS are in the order of the .text* in the
input assembly (i.e., .text.init, .text, .text.exit)
- the emitted .text* sections by GAS are placed in the following order
.text, .text.init, .text.exit.
- GAS does not set SFRAME_F_FDE_SORTED, as expected.
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
bfd/
PR ld/32789
* elf-sframe.c (_bfd_elf_write_section_sframe): Skip sorting the
SFrame FDEs for relocatable links.
* elf64-s390.c (_bfd_s390_elf_write_sframe_plt): Additional
argument to sframe_encoder_write.
* elfxx-x86.c (_bfd_x86_elf_write_sframe_plt): Likewise.
libsframe/
* libsframe.ver: Move from 2.0 node to 2.1.
* sframe.c (sframe_encoder_write_sframe): Conditionalize based
on argument sort_fde_p.
(sframe_encoder_write): New argument to indicate whether SFrame
FDEs are to be sorted in output.
include/
* sframe-api.h (sframe_encoder_write): New argument.
ld/testsuite/
PR ld/32789
* ld/testsuite/ld-sframe/sframe.exp: New test.
* ld/testsuite/ld-sframe/pr32789-1.rd: New test.
* ld/testsuite/ld-sframe/pr32789-1.sd: New test.
* ld/testsuite/ld-sframe/pr32789-1a.c: New test.
* ld/testsuite/ld-sframe/pr32789-1b.c: New test.
* ld/testsuite/ld-x86-64/sframe-reloc-1.d: Remove
SFRAME_F_FDE_SORTED.
SFrame FREs without any offsets will later be used to represent an
undefined return address (RA) in SFrame. This API can then be used,
for instance by libsframe when dumping SFrame stack trace information
(e.g. in objdump and readelf), to test for RA undefined. Other users
of libsframe need the same capability.
include/
* sframe-api.h (sframe_fre_get_ra_undefined_p): New declaration.
libsframe/
* libsframe.ver (sframe_fre_get_ra_undefined_p): List new API.
* sframe.c (sframe_fre_get_ra_undefined_p): New definition.
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Remove LIBSFRAME_1.1, LIBSFRAME_1.0 nodes and add a new LIBSFRAME_2.0
node (non-inheritance version) to create new global versioned symbols.
Also announce libsframe.so.2 in NEWS.
New APIs:
sframe_decoder_get_flags;
sframe_decoder_get_offsetof_fde_start_addr;
sframe_encoder_get_flags;
sframe_encoder_get_offsetof_fde_start_addr;
Removed APIs: (already deprecated since X-2 release)
sframe_get_funcdesc_with_addr;
APIs with changed semantics:
sframe_decoder_get_funcdesc_v2;
sframe_encoder_add_funcdesc_v2;
sframe_encoder_write;
lisbframe/
* libsframe.ver: Define new LIBSFRAME_2.0.
* libtool-version: Bump the 'current' numeral to indicate a binary
incompatible release.
include/
* sframe-api.h (sframe_get_funcdesc_with_addr): Remove
deprecated interface.
libsframe/
* sframe.c (sframe_get_funcdesc_with_addr): Likewise.
binutils/
* NEWS: Announce new versioned release of libsframe.
These APIs will be later used by the linker to arrange SFrame FDEs in
the output SFrame section.
include/
* sframe-api.h (sframe_decoder_get_offsetof_fde_start_addr): New
declaration.
(sframe_encoder_get_offsetof_fde_start_addr): Likewise.
libsframe/
* libsframe.ver: List the new APIs.
* sframe.c (sframe_decoder_get_offsetof_fde_start_addr): New
definition.
(sframe_encoder_get_offsetof_fde_start_addr): Likewise.
Add new APIs, one each for getting flags from the SFrame decoder and
SFrame encoder context objects respectively.
These will later be used by the linker to uniformly access the flags,
given the SFrame decoder and SFrame encoder objects.
Use the new API, where applicable, within libsframe.
include/
* sframe-api.h (sframe_decoder_get_flags): New declaration.
(sframe_encoder_get_flags): Likewise.
libsframe/
* libsframe.ver: List new APIs.
* sframe.c (sframe_decoder_get_flags): New definition.
(sframe_encoder_get_flags): Likewise.
(sframe_get_funcdesc_with_addr_internal): Use the new API.
(sframe_encoder_get_flags): Likewise.
(sframe_encoder_write_sframe): Likewise.
SFrame version 2 encodes the size of repetitive insn block explicitly
in the format. Add information in the SFrame FDE to convey the size
of the block of repeating instructions. This information is used only
for SFrame FDEs of type SFRAME_FDE_TYPE_PCMASK.
Introduce two extra bytes for padding: this ensures that the memory
accesses to the members of the SFrame Frame Descriptor Entry (FDE) are
naturally aligned.
gas generates SFrame section with version SFRAME_VERSION_2 by default.
libsframe provides two new APIs to:
- get an SFrame FDE data from the decoder context, and
- add an SFrame FDE to the encoder context.
The additional argument (for rep_block_size) is useful for SFrame FDEs
where FDE type is SFRAME_FDE_TYPE_PCMASK.
The linker will generate the output SFrame sections in the
SFRAME_VERSION_2 format. If the input sections offered to the linker
are not all in the SFRAME_VERSION_2 format, the linker issues an error
to the user.
objdump/readelf will show the following message to the user if .sframe
section in SFRAME_VERSION_1 format is seen:
"No further information can be displayed. SFrame version not
supported."
In other words, like the rest of the binutils, only the current SFrame
format version, i.e., SFRAME_VERSION_2 is supported by the textual dump
facilities.
bfd/
* elf-sframe.c (_bfd_elf_merge_section_sframe): Generate an
output SFrame section with version SFRAME_VERSION_2. Also,
error out if the SFrame sections do not all have
SFRAME_VERSION_2.
* elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Generate SFrame
section for plt entries with version SFRAME_VERSION_2.
gas/
* gen-sframe.c (sframe_set_version): Update to SFRAME_VERSION_2.
(output_sframe): Likewise.
gas/testsuite/
* gas/cfi-sframe/cfi-sframe-aarch64-1.d: Use SFRAME_VERSION_2.
* gas/cfi-sframe/cfi-sframe-aarch64-2.d: Likewise.
* gas/cfi-sframe/cfi-sframe-aarch64-pac-ab-key-1.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-1.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-x86_64-1.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.
ld/testsuite/
* ld-aarch64/sframe-simple-1.d: Adjust for SFRAME_VERSION_2.
* ld-x86-64/sframe-plt-1.d: Likewise.
* ld-x86-64/sframe-simple-1.d: Likewise.
libsframe/
* libsframe.ver: Add the new APIs.
* sframe.c (sframe_decoder_get_funcdesc_v2): New definition.
(sframe_encoder_add_funcdesc_v2): Likewise.
(sframe_header_sanity_check_p): Include SFRAME_VERSION_2.
(sframe_fre_check_range_p): Get rep_block_size info from SFrame
FDE.
* sframe-dump.c (dump_sframe_header): Add support for
SFRAME_VERSION_2.
(dump_sframe): Inform user if SFrame section in SFRAME_VERSION_1
format is seen.
libsframe/testsuite/
* libsframe.decode/DATA-BE: Regenerated data file.
* libsframe.decode/DATA1: Likewise.
* libsframe.decode/DATA2: Likewise.
* libsframe.find/plt-findfre-1.c: Use new API in the testcase.
include/
* sframe.h: Add member to encode size of the code block of
repeating instructions. Add 2 bytes of padding.
* sframe-api.h (sframe_decoder_get_funcdesc_v2): New
declaration.
(sframe_encoder_add_funcdesc_v2): Likewise.
While the SFrame preamble is guaranteed to not change between versions,
providing these access APIs from the SFrame decoder and encoder APIs is
for convenience only. The linker may want to use these APIs as the
format evolves.
include/
* sframe-api.h (sframe_decoder_get_version): New declaration.
(sframe_encoder_get_version): Likewise.
libsframe/
* libsframe/libsframe.ver: Add new APIs.
* libsframe/sframe.c (sframe_decoder_get_version): New
definition.
(sframe_encoder_get_version): Likewise.
Define an empty base version LIBSFRAME_0.0 and add all symbols to
version LIBSFRAME_1.0.
The previous release of libsframe (libsframe.so.0) did not have
versioned symbols. Adding a libsframe.ver file so that future releases
of the library (and its consumers) can manage the changes better.
For Solaris ld, use -M mapfile command line option. libsframe does not
restrict the set of exported symbols, so at this time there is no need
to fall back on the libtool's -export-symbols option for platforms where
some other linker (with a different command line option for symbol
versioning) may be used.
libsframe/
* Makefile.am: Use symbol versioning for libsframe.
* Makefile.in: Regenerated.
* configure: Check for Solaris ld.
* configure.ac: Regenerated.
* libsframe.ver: New file.