@@ -18,6 +18,10 @@
Changes in 2.47:
+* Add the RISC-V --relax-tbljal[=zcmt] and --no-relax-tbljal options for
+ opt-in Zcmt table-jump relaxation in non-position-independent executable
+ links. An omitted scheme selects zcmt; unsupported schemes are errors.
+
* Add a linker optimization level of zero. Using "-O 0" on the linker command
line will stop it from combining the contents of mergeable sections. This
can significantly speed up the link process at the cost of producing larger
@@ -26,7 +26,8 @@ fragment <<EOF
#include "elfxx-riscv.h"
static struct riscv_elf_params params = { .relax_gp = 1,
- .check_uleb128 = 0};
+ .check_uleb128 = 0,
+ .relax_zcmt = 0};
EOF
# Define some shell vars to insert bits of code into the standard elf
@@ -36,6 +37,8 @@ PARSE_AND_LIST_LONGOPTS=${PARSE_AND_LIST_LONGOPTS}'
{ "no-relax-gp", no_argument, NULL, OPTION_NO_RELAX_GP },
{ "check-uleb128", no_argument, NULL, OPTION_CHECK_ULEB128 },
{ "no-check-uleb128", no_argument, NULL, OPTION_NO_CHECK_ULEB128 },
+ { "relax-tbljal", optional_argument, NULL, OPTION_RELAX_TBLJAL },
+ { "no-relax-tbljal", no_argument, NULL, OPTION_NO_RELAX_TBLJAL },
'
PARSE_AND_LIST_OPTIONS=${PARSE_AND_LIST_OPTIONS}'
@@ -43,6 +46,8 @@ PARSE_AND_LIST_OPTIONS=${PARSE_AND_LIST_OPTIONS}'
fprintf (file, _(" --no-relax-gp Don'\''t perform GP relaxation\n"));
fprintf (file, _(" --check-uleb128 Check if SUB_ULEB128 has non-zero addend\n"));
fprintf (file, _(" --no-check-uleb128 Don'\''t check if SUB_ULEB128 has non-zero addend\n"));
+ fprintf (file, _(" --relax-tbljal[=zcmt] Enable RISC-V table-jump relaxation (scheme: zcmt)\n"));
+ fprintf (file, _(" --no-relax-tbljal Disable RISC-V table-jump relaxation (default)\n"));
'
PARSE_AND_LIST_ARGS_CASES=${PARSE_AND_LIST_ARGS_CASES}'
@@ -61,6 +66,16 @@ PARSE_AND_LIST_ARGS_CASES=${PARSE_AND_LIST_ARGS_CASES}'
case OPTION_NO_CHECK_ULEB128:
params.check_uleb128 = 0;
break;
+
+ case OPTION_RELAX_TBLJAL:
+ if (optarg != NULL && strcmp (optarg, "zcmt") != 0)
+ fatal (_("%P: unsupported table-jump relaxation scheme: %s\n"), optarg);
+ params.relax_zcmt = 1;
+ break;
+
+ case OPTION_NO_RELAX_TBLJAL:
+ params.relax_zcmt = 0;
+ break;
'
fragment <<EOF
@@ -21,6 +21,7 @@
@set PDP11
@set POWERPC
@set POWERPC64
+@set RISCV
@set Renesas
@set S/390
@set SPU
@@ -32,4 +33,3 @@
@clear SingleFormat
@set UsesEnvVars
@c ------------------------------ end CONFIGURATION VARS
-
@@ -33,6 +33,7 @@
@set PDP11
@set POWERPC
@set POWERPC64
+@set RISCV
@set Renesas
@set S/390
@set SPU
@@ -4129,6 +4130,51 @@ in the PLT entries for MIPS R6.
@c man end
@end ifset
+@ifset RISCV
+@subsection Options specific to RISC-V targets
+
+@c man begin OPTIONS
+
+@table @gcctabopt
+
+@kindex --relax-tbljal
+@item --relax-tbljal
+@itemx --relax-tbljal=@var{scheme}
+Enable RISC-V table-jump relaxation using @var{scheme}. The only supported
+scheme is currently @samp{zcmt}; omitting the argument is equivalent to
+@samp{--relax-tbljal=zcmt}. An explicit scheme must follow @samp{=} with
+no intervening space. Empty or unsupported scheme names are errors.
+
+Zcmt table-jump relaxation is performed only when the input architecture
+attributes permit the Zcmt extension. The extension requires Zca and
+Zicsr, and is not compatible with Zcd. This relaxation is disabled by
+default and is initially supported only for non-position-independent
+executable links. It is conservatively disabled for PIC, PIE and shared
+links.
+
+The last @samp{--relax-tbljal} or @samp{--no-relax-tbljal} option determines
+whether table-jump relaxation is requested. Disabling relaxation with
+@samp{--no-relax} also disables table-jump relaxation, regardless of where
+the table-jump option appears.
+
+When a non-empty @code{.riscv.jvt} section is emitted, the linker defines
+a local @code{__jvt_base$} symbol at the table base. Programs using this
+relaxation must initialize the @code{jvt} CSR to @code{__jvt_base$}
+before executing @code{cm.jt} or @code{cm.jalt}. The symbol is not
+defined when no profitable table is emitted; generic startup code that
+unconditionally references @code{__jvt_base$} is therefore unsupported
+unless it arranges an optional reference or is linked only when a JVT is
+emitted.
+
+@kindex --no-relax-tbljal
+@item --no-relax-tbljal
+Disable RISC-V table-jump relaxation. This is the default.
+
+@end table
+
+@c man end
+@end ifset
+
@ifset PDP11
@subsection Options specific to PDP11 targets
@@ -430,6 +430,8 @@ enum option_values
OPTION_NO_RELAX_GP,
OPTION_CHECK_ULEB128,
OPTION_NO_CHECK_ULEB128,
+ OPTION_RELAX_TBLJAL,
+ OPTION_NO_RELAX_TBLJAL,
/* Used by emultempl/rxelf.em. */
OPTION_NO_FLAG_MISMATCH_WARNINGS,
OPTION_IGNORE_LMA,