mirror of
https://github.com/MiyooCFW/buildroot.git
synced 2025-09-27 22:24:19 +03:00
Merge from bittboy/buildroot@db180c0
This commit is contained in:
48
package/binutils/2.32/0001-sh-conf.patch
Normal file
48
package/binutils/2.32/0001-sh-conf.patch
Normal file
@@ -0,0 +1,48 @@
|
||||
From 98b2acf2bd3a527d114a9f8931083c2617a2daa9 Mon Sep 17 00:00:00 2001
|
||||
From: Romain Naour <romain.naour@gmail.com>
|
||||
Date: Fri, 25 Dec 2015 11:38:13 +0100
|
||||
Subject: [PATCH] sh-conf
|
||||
|
||||
Likewise, binutils has no idea about any of these new targets either, so we
|
||||
fix that up too.. now we're able to actually build a real toolchain for
|
||||
sh2a_nofpu- and other more ineptly named toolchains (and yes, there are more
|
||||
inept targets than that one, really. Go look, I promise).
|
||||
|
||||
[Romain: rebase on top of 2.32]
|
||||
Signed-off-by: Romain Naour <romain.naour@gmail.com>
|
||||
[Thomas: rebase on top of 2.29, in which sh64 support was removed.]
|
||||
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
|
||||
---
|
||||
configure | 2 +-
|
||||
configure.ac | 2 +-
|
||||
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/configure b/configure
|
||||
index 37476459612..66fbc19f9ff 100755
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -3861,7 +3861,7 @@ case "${target}" in
|
||||
nvptx*-*-*)
|
||||
noconfigdirs="$noconfigdirs target-libssp target-libstdc++-v3 target-libobjc"
|
||||
;;
|
||||
- sh-*-*)
|
||||
+ sh*-*-*)
|
||||
case "${target}" in
|
||||
sh*-*-elf)
|
||||
;;
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 46501c28826..6c731930884 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -1158,7 +1158,7 @@ case "${target}" in
|
||||
nvptx*-*-*)
|
||||
noconfigdirs="$noconfigdirs target-libssp target-libstdc++-v3 target-libobjc"
|
||||
;;
|
||||
- sh-*-*)
|
||||
+ sh*-*-*)
|
||||
case "${target}" in
|
||||
sh*-*-elf)
|
||||
;;
|
||||
--
|
||||
2.14.5
|
||||
|
||||
306
package/binutils/2.32/0002-poison-system-directories.patch
Normal file
306
package/binutils/2.32/0002-poison-system-directories.patch
Normal file
@@ -0,0 +1,306 @@
|
||||
From f559402ea868d370ddf25089c68cda2600db3bfa Mon Sep 17 00:00:00 2001
|
||||
From: Romain Naour <romain.naour@gmail.com>
|
||||
Date: Fri, 25 Dec 2015 11:45:38 +0100
|
||||
Subject: [PATCH] poison-system-directories
|
||||
|
||||
Patch adapted to binutils 2.23.2 and extended to use
|
||||
BR_COMPILER_PARANOID_UNSAFE_PATH by Thomas Petazzoni.
|
||||
|
||||
[Romain: rebase on top of 2.32]
|
||||
Signed-off-by: Romain Naour <romain.naour@gmail.com>
|
||||
[Gustavo: adapt to binutils 2.25]
|
||||
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
|
||||
Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
|
||||
|
||||
Upstream-Status: Inappropriate [distribution: codesourcery]
|
||||
|
||||
Patch originally created by Mark Hatle, forward-ported to
|
||||
binutils 2.21 by Scott Garman.
|
||||
|
||||
purpose: warn for uses of system directories when cross linking
|
||||
|
||||
Code Merged from Sourcery G++ binutils 2.19 - 4.4-277
|
||||
|
||||
2008-07-02 Joseph Myers <joseph@codesourcery.com>
|
||||
|
||||
ld/
|
||||
* ld.h (args_type): Add error_poison_system_directories.
|
||||
* ld.texinfo (--error-poison-system-directories): Document.
|
||||
* ldfile.c (ldfile_add_library_path): Check
|
||||
command_line.error_poison_system_directories.
|
||||
* ldmain.c (main): Initialize
|
||||
command_line.error_poison_system_directories.
|
||||
* lexsup.c (enum option_values): Add
|
||||
OPTION_ERROR_POISON_SYSTEM_DIRECTORIES.
|
||||
(ld_options): Add --error-poison-system-directories.
|
||||
(parse_args): Handle new option.
|
||||
|
||||
2007-06-13 Joseph Myers <joseph@codesourcery.com>
|
||||
|
||||
ld/
|
||||
* config.in: Regenerate.
|
||||
* ld.h (args_type): Add poison_system_directories.
|
||||
* ld.texinfo (--no-poison-system-directories): Document.
|
||||
* ldfile.c (ldfile_add_library_path): Check
|
||||
command_line.poison_system_directories.
|
||||
* ldmain.c (main): Initialize
|
||||
command_line.poison_system_directories.
|
||||
* lexsup.c (enum option_values): Add
|
||||
OPTION_NO_POISON_SYSTEM_DIRECTORIES.
|
||||
(ld_options): Add --no-poison-system-directories.
|
||||
(parse_args): Handle new option.
|
||||
|
||||
2007-04-20 Joseph Myers <joseph@codesourcery.com>
|
||||
|
||||
Merge from Sourcery G++ binutils 2.17:
|
||||
|
||||
2007-03-20 Joseph Myers <joseph@codesourcery.com>
|
||||
Based on patch by Mark Hatle <mark.hatle@windriver.com>.
|
||||
ld/
|
||||
* configure.ac (--enable-poison-system-directories): New option.
|
||||
* configure, config.in: Regenerate.
|
||||
* ldfile.c (ldfile_add_library_path): If
|
||||
ENABLE_POISON_SYSTEM_DIRECTORIES defined, warn for use of /lib,
|
||||
/usr/lib, /usr/local/lib or /usr/X11R6/lib.
|
||||
|
||||
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
|
||||
Signed-off-by: Scott Garman <scott.a.garman@intel.com>
|
||||
---
|
||||
ld/config.in | 3 +++
|
||||
ld/configure | 14 ++++++++++++++
|
||||
ld/configure.ac | 10 ++++++++++
|
||||
ld/ld.h | 8 ++++++++
|
||||
ld/ld.texi | 12 ++++++++++++
|
||||
ld/ldfile.c | 17 +++++++++++++++++
|
||||
ld/ldlex.h | 2 ++
|
||||
ld/ldmain.c | 2 ++
|
||||
ld/lexsup.c | 21 +++++++++++++++++++++
|
||||
9 files changed, 89 insertions(+)
|
||||
|
||||
diff --git a/ld/config.in b/ld/config.in
|
||||
index d93c9b08300..5da2742beac 100644
|
||||
--- a/ld/config.in
|
||||
+++ b/ld/config.in
|
||||
@@ -31,6 +31,9 @@
|
||||
language is requested. */
|
||||
#undef ENABLE_NLS
|
||||
|
||||
+/* Define to warn for use of native system library directories */
|
||||
+#undef ENABLE_POISON_SYSTEM_DIRECTORIES
|
||||
+
|
||||
/* Additional extension a shared object might have. */
|
||||
#undef EXTRA_SHLIB_EXTENSION
|
||||
|
||||
diff --git a/ld/configure b/ld/configure
|
||||
index 18ada7808f5..7e7d2f97809 100755
|
||||
--- a/ld/configure
|
||||
+++ b/ld/configure
|
||||
@@ -822,6 +822,7 @@ with_lib_path
|
||||
enable_targets
|
||||
enable_64_bit_bfd
|
||||
with_sysroot
|
||||
+enable_poison_system_directories
|
||||
enable_gold
|
||||
enable_got
|
||||
enable_compressed_debug_sections
|
||||
@@ -1486,6 +1487,8 @@ Optional Features:
|
||||
--disable-largefile omit support for large files
|
||||
--enable-targets alternative target configurations
|
||||
--enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes)
|
||||
+ --enable-poison-system-directories
|
||||
+ warn for use of native system library directories
|
||||
--enable-gold[=ARG] build gold [ARG={default,yes,no}]
|
||||
--enable-got=<type> GOT handling scheme (target, single, negative,
|
||||
multigot)
|
||||
@@ -15803,7 +15806,18 @@ else
|
||||
fi
|
||||
|
||||
|
||||
+# Check whether --enable-poison-system-directories was given.
|
||||
+if test "${enable_poison_system_directories+set}" = set; then :
|
||||
+ enableval=$enable_poison_system_directories;
|
||||
+else
|
||||
+ enable_poison_system_directories=no
|
||||
+fi
|
||||
+
|
||||
+if test "x${enable_poison_system_directories}" = "xyes"; then
|
||||
|
||||
+$as_echo "#define ENABLE_POISON_SYSTEM_DIRECTORIES 1" >>confdefs.h
|
||||
+
|
||||
+fi
|
||||
|
||||
# Check whether --enable-got was given.
|
||||
if test "${enable_got+set}" = set; then :
|
||||
diff --git a/ld/configure.ac b/ld/configure.ac
|
||||
index d335f210917..7f692d93873 100644
|
||||
--- a/ld/configure.ac
|
||||
+++ b/ld/configure.ac
|
||||
@@ -94,6 +94,16 @@ AC_SUBST(use_sysroot)
|
||||
AC_SUBST(TARGET_SYSTEM_ROOT)
|
||||
AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
|
||||
|
||||
+AC_ARG_ENABLE([poison-system-directories],
|
||||
+ AS_HELP_STRING([--enable-poison-system-directories],
|
||||
+ [warn for use of native system library directories]),,
|
||||
+ [enable_poison_system_directories=no])
|
||||
+if test "x${enable_poison_system_directories}" = "xyes"; then
|
||||
+ AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES],
|
||||
+ [1],
|
||||
+ [Define to warn for use of native system library directories])
|
||||
+fi
|
||||
+
|
||||
dnl Use --enable-gold to decide if this linker should be the default.
|
||||
dnl "install_as_default" is set to false if gold is the default linker.
|
||||
dnl "installed_linker" is the installed BFD linker name.
|
||||
diff --git a/ld/ld.h b/ld/ld.h
|
||||
index b97d977f37b..f3bbd2d55d4 100644
|
||||
--- a/ld/ld.h
|
||||
+++ b/ld/ld.h
|
||||
@@ -180,6 +180,14 @@ typedef struct
|
||||
in the linker script. */
|
||||
bfd_boolean force_group_allocation;
|
||||
|
||||
+ /* If TRUE (the default) warn for uses of system directories when
|
||||
+ cross linking. */
|
||||
+ bfd_boolean poison_system_directories;
|
||||
+
|
||||
+ /* If TRUE (default FALSE) give an error for uses of system
|
||||
+ directories when cross linking instead of a warning. */
|
||||
+ bfd_boolean error_poison_system_directories;
|
||||
+
|
||||
/* Big or little endian as set on command line. */
|
||||
enum endian_enum endian;
|
||||
|
||||
diff --git a/ld/ld.texi b/ld/ld.texi
|
||||
index 5179af3e0e1..f78bf746822 100644
|
||||
--- a/ld/ld.texi
|
||||
+++ b/ld/ld.texi
|
||||
@@ -2524,6 +2524,18 @@ string identifying the original linked file does not change.
|
||||
|
||||
Passing @code{none} for @var{style} disables the setting from any
|
||||
@code{--build-id} options earlier on the command line.
|
||||
+
|
||||
+@kindex --no-poison-system-directories
|
||||
+@item --no-poison-system-directories
|
||||
+Do not warn for @option{-L} options using system directories such as
|
||||
+@file{/usr/lib} when cross linking. This option is intended for use
|
||||
+in chroot environments when such directories contain the correct
|
||||
+libraries for the target system rather than the host.
|
||||
+
|
||||
+@kindex --error-poison-system-directories
|
||||
+@item --error-poison-system-directories
|
||||
+Give an error instead of a warning for @option{-L} options using
|
||||
+system directories when cross linking.
|
||||
@end table
|
||||
|
||||
@c man end
|
||||
diff --git a/ld/ldfile.c b/ld/ldfile.c
|
||||
index fcadc08c73f..63e295ce8ae 100644
|
||||
--- a/ld/ldfile.c
|
||||
+++ b/ld/ldfile.c
|
||||
@@ -116,6 +116,23 @@ ldfile_add_library_path (const char *name, bfd_boolean cmdline)
|
||||
new_dirs->name = concat (ld_sysroot, name + strlen ("$SYSROOT"), (const char *) NULL);
|
||||
else
|
||||
new_dirs->name = xstrdup (name);
|
||||
+
|
||||
+#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES
|
||||
+ if (command_line.poison_system_directories
|
||||
+ && ((!strncmp (name, "/lib", 4))
|
||||
+ || (!strncmp (name, "/usr/lib", 8))
|
||||
+ || (!strncmp (name, "/usr/local/lib", 14))
|
||||
+ || (!strncmp (name, "/usr/X11R6/lib", 14))))
|
||||
+ {
|
||||
+ if (command_line.error_poison_system_directories)
|
||||
+ einfo (_("%X%P: error: library search path \"%s\" is unsafe for "
|
||||
+ "cross-compilation\n"), name);
|
||||
+ else
|
||||
+ einfo (_("%P: warning: library search path \"%s\" is unsafe for "
|
||||
+ "cross-compilation\n"), name);
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
}
|
||||
|
||||
/* Try to open a BFD for a lang_input_statement. */
|
||||
diff --git a/ld/ldlex.h b/ld/ldlex.h
|
||||
index 32853debe45..8135361c498 100644
|
||||
--- a/ld/ldlex.h
|
||||
+++ b/ld/ldlex.h
|
||||
@@ -148,6 +148,8 @@ enum option_values
|
||||
OPTION_REQUIRE_DEFINED_SYMBOL,
|
||||
OPTION_ORPHAN_HANDLING,
|
||||
OPTION_FORCE_GROUP_ALLOCATION,
|
||||
+ OPTION_NO_POISON_SYSTEM_DIRECTORIES,
|
||||
+ OPTION_ERROR_POISON_SYSTEM_DIRECTORIES,
|
||||
};
|
||||
|
||||
/* The initial parser states. */
|
||||
diff --git a/ld/ldmain.c b/ld/ldmain.c
|
||||
index 77cdbd0dd29..725512f1260 100644
|
||||
--- a/ld/ldmain.c
|
||||
+++ b/ld/ldmain.c
|
||||
@@ -269,6 +269,8 @@ main (int argc, char **argv)
|
||||
command_line.warn_mismatch = TRUE;
|
||||
command_line.warn_search_mismatch = TRUE;
|
||||
command_line.check_section_addresses = -1;
|
||||
+ command_line.poison_system_directories = TRUE;
|
||||
+ command_line.error_poison_system_directories = FALSE;
|
||||
|
||||
/* We initialize DEMANGLING based on the environment variable
|
||||
COLLECT_NO_DEMANGLE. The gcc collect2 program will demangle the
|
||||
diff --git a/ld/lexsup.c b/ld/lexsup.c
|
||||
index 88e85c73f49..be4cd492d14 100644
|
||||
--- a/ld/lexsup.c
|
||||
+++ b/ld/lexsup.c
|
||||
@@ -543,6 +543,14 @@ static const struct ld_option ld_options[] =
|
||||
{ {"orphan-handling", required_argument, NULL, OPTION_ORPHAN_HANDLING},
|
||||
'\0', N_("=MODE"), N_("Control how orphan sections are handled."),
|
||||
TWO_DASHES },
|
||||
+ { {"no-poison-system-directories", no_argument, NULL,
|
||||
+ OPTION_NO_POISON_SYSTEM_DIRECTORIES},
|
||||
+ '\0', NULL, N_("Do not warn for -L options using system directories"),
|
||||
+ TWO_DASHES },
|
||||
+ { {"error-poison-system-directories", no_argument, NULL,
|
||||
+ OPTION_ERROR_POISON_SYSTEM_DIRECTORIES},
|
||||
+ '\0', NULL, N_("Give an error for -L options using system directories"),
|
||||
+ TWO_DASHES },
|
||||
};
|
||||
|
||||
#define OPTION_COUNT ARRAY_SIZE (ld_options)
|
||||
@@ -555,6 +563,7 @@ parse_args (unsigned argc, char **argv)
|
||||
int ingroup = 0;
|
||||
char *default_dirlist = NULL;
|
||||
char *shortopts;
|
||||
+ char *BR_paranoid_env;
|
||||
struct option *longopts;
|
||||
struct option *really_longopts;
|
||||
int last_optind;
|
||||
@@ -1543,6 +1552,14 @@ parse_args (unsigned argc, char **argv)
|
||||
}
|
||||
break;
|
||||
|
||||
+ case OPTION_NO_POISON_SYSTEM_DIRECTORIES:
|
||||
+ command_line.poison_system_directories = FALSE;
|
||||
+ break;
|
||||
+
|
||||
+ case OPTION_ERROR_POISON_SYSTEM_DIRECTORIES:
|
||||
+ command_line.error_poison_system_directories = TRUE;
|
||||
+ break;
|
||||
+
|
||||
case OPTION_PUSH_STATE:
|
||||
input_flags.pushed = xmemdup (&input_flags,
|
||||
sizeof (input_flags),
|
||||
@@ -1586,6 +1603,10 @@ parse_args (unsigned argc, char **argv)
|
||||
command_line.soname = NULL;
|
||||
}
|
||||
|
||||
+ BR_paranoid_env = getenv("BR_COMPILER_PARANOID_UNSAFE_PATH");
|
||||
+ if (BR_paranoid_env && strlen(BR_paranoid_env) > 0)
|
||||
+ command_line.error_poison_system_directories = TRUE;
|
||||
+
|
||||
while (ingroup)
|
||||
{
|
||||
lang_leave_group ();
|
||||
--
|
||||
2.14.5
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
From 278989f23735aa501be1052e085540c75c126dbb Mon Sep 17 00:00:00 2001
|
||||
From: Max Filippov <jcmvbkbc@gmail.com>
|
||||
Date: Thu, 28 Mar 2019 17:03:57 -0700
|
||||
Subject: [PATCH] bfd: xtensa: fix shrink_dynamic_reloc_sections for
|
||||
export-dynamic
|
||||
|
||||
shrink_dynamic_reloc_sections must remove PLT entry that was created for
|
||||
an undefined weak symbol in the presence of --export-dynamic option when
|
||||
relaxation coalesces literals pointing to that symbol. This fixes the
|
||||
following assertion:
|
||||
|
||||
ld: BFD (GNU Binutils) 2.31.1 internal error, aborting at
|
||||
elf32-xtensa.c:3292 in elf_xtensa_finish_dynamic_sections
|
||||
|
||||
2019-03-28 Max Filippov <jcmvbkbc@gmail.com>
|
||||
bfd/
|
||||
* elf32-xtensa.c (shrink_dynamic_reloc_sections): Add
|
||||
info->export_dynamic to the conditional.
|
||||
|
||||
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
|
||||
---
|
||||
bfd/elf32-xtensa.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
|
||||
index c3df3d6db756..37ea200eea74 100644
|
||||
--- a/bfd/elf32-xtensa.c
|
||||
+++ b/bfd/elf32-xtensa.c
|
||||
@@ -10083,7 +10083,8 @@ shrink_dynamic_reloc_sections (struct bfd_link_info *info,
|
||||
&& (input_section->flags & SEC_ALLOC) != 0
|
||||
&& (dynamic_symbol || bfd_link_pic (info))
|
||||
&& (!h || h->root.type != bfd_link_hash_undefweak
|
||||
- || (dynamic_symbol && bfd_link_dll (info))))
|
||||
+ || (dynamic_symbol
|
||||
+ && (bfd_link_dll (info) || info->export_dynamic))))
|
||||
{
|
||||
asection *srel;
|
||||
bfd_boolean is_plt = FALSE;
|
||||
--
|
||||
2.11.0
|
||||
|
||||
@@ -0,0 +1,294 @@
|
||||
From 0dbdfb7918d0b0cfcb8883b24c1291574bf5bb7c Mon Sep 17 00:00:00 2001
|
||||
From: Max Filippov <jcmvbkbc@gmail.com>
|
||||
Date: Tue, 2 Apr 2019 14:32:42 -0700
|
||||
Subject: [PATCH] gas: use literals/const16 for xtensa loop relaxation
|
||||
|
||||
Loop opcode relaxation that uses addi/addmi doesn't work well with other
|
||||
relaxations that may cause code movement. Instead of encoding fixed loop
|
||||
end offset in the relaxed sequence use l32r or a pair of const16 to load
|
||||
loop end address. This way the address of the loop end gets a relocation
|
||||
record and it gets updated appropriately.
|
||||
|
||||
gas/
|
||||
2019-04-02 Max Filippov <jcmvbkbc@gmail.com>
|
||||
|
||||
* config/tc-xtensa.c (convert_frag_immed): Drop
|
||||
convert_frag_immed_finish_loop invocation.
|
||||
(convert_frag_immed_finish_loop): Drop declaration and
|
||||
definition.
|
||||
* config/xtensa-relax.c (widen_spec_list): Replace loop
|
||||
widening that uses addi/addmi with widening that uses l32r
|
||||
and const16.
|
||||
|
||||
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
|
||||
---
|
||||
gas/config/tc-xtensa.c | 120 ----------------------------------------------
|
||||
gas/config/xtensa-relax.c | 77 ++++++++++++++++++++---------
|
||||
2 files changed, 55 insertions(+), 142 deletions(-)
|
||||
|
||||
diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
|
||||
index 3bdbbc931cfc..0cc06361cf6f 100644
|
||||
--- a/gas/config/tc-xtensa.c
|
||||
+++ b/gas/config/tc-xtensa.c
|
||||
@@ -10668,7 +10668,6 @@ convert_frag_fill_nop (fragS *fragP)
|
||||
static fixS *fix_new_exp_in_seg
|
||||
(segT, subsegT, fragS *, int, int, expressionS *, int,
|
||||
bfd_reloc_code_real_type);
|
||||
-static void convert_frag_immed_finish_loop (segT, fragS *, TInsn *);
|
||||
|
||||
static void
|
||||
convert_frag_immed (segT segP,
|
||||
@@ -10910,9 +10909,6 @@ convert_frag_immed (segT segP,
|
||||
}
|
||||
}
|
||||
|
||||
- if (expanded && xtensa_opcode_is_loop (isa, orig_tinsn.opcode) == 1)
|
||||
- convert_frag_immed_finish_loop (segP, fragP, &orig_tinsn);
|
||||
-
|
||||
if (expanded && is_direct_call_opcode (orig_tinsn.opcode))
|
||||
{
|
||||
/* Add an expansion note on the expanded instruction. */
|
||||
@@ -10949,122 +10945,6 @@ fix_new_exp_in_seg (segT new_seg,
|
||||
}
|
||||
|
||||
|
||||
-/* Relax a loop instruction so that it can span loop >256 bytes.
|
||||
-
|
||||
- loop as, .L1
|
||||
- .L0:
|
||||
- rsr as, LEND
|
||||
- wsr as, LBEG
|
||||
- addi as, as, lo8 (label-.L1)
|
||||
- addmi as, as, mid8 (label-.L1)
|
||||
- wsr as, LEND
|
||||
- isync
|
||||
- rsr as, LCOUNT
|
||||
- addi as, as, 1
|
||||
- .L1:
|
||||
- <<body>>
|
||||
- label:
|
||||
-*/
|
||||
-
|
||||
-static void
|
||||
-convert_frag_immed_finish_loop (segT segP, fragS *fragP, TInsn *tinsn)
|
||||
-{
|
||||
- TInsn loop_insn;
|
||||
- TInsn addi_insn;
|
||||
- TInsn addmi_insn;
|
||||
- unsigned long target;
|
||||
- static xtensa_insnbuf insnbuf = NULL;
|
||||
- unsigned int loop_length, loop_length_hi, loop_length_lo;
|
||||
- xtensa_isa isa = xtensa_default_isa;
|
||||
- addressT loop_offset;
|
||||
- addressT addi_offset = 9;
|
||||
- addressT addmi_offset = 12;
|
||||
- fragS *next_fragP;
|
||||
- int target_count;
|
||||
-
|
||||
- if (!insnbuf)
|
||||
- insnbuf = xtensa_insnbuf_alloc (isa);
|
||||
-
|
||||
- /* Get the loop offset. */
|
||||
- loop_offset = get_expanded_loop_offset (tinsn->opcode);
|
||||
-
|
||||
- /* Validate that there really is a LOOP at the loop_offset. Because
|
||||
- loops are not bundleable, we can assume that the instruction will be
|
||||
- in slot 0. */
|
||||
- tinsn_from_chars (&loop_insn, fragP->fr_opcode + loop_offset, 0);
|
||||
- tinsn_immed_from_frag (&loop_insn, fragP, 0);
|
||||
-
|
||||
- gas_assert (xtensa_opcode_is_loop (isa, loop_insn.opcode) == 1);
|
||||
- addi_offset += loop_offset;
|
||||
- addmi_offset += loop_offset;
|
||||
-
|
||||
- gas_assert (tinsn->ntok == 2);
|
||||
- if (tinsn->tok[1].X_op == O_constant)
|
||||
- target = tinsn->tok[1].X_add_number;
|
||||
- else if (tinsn->tok[1].X_op == O_symbol)
|
||||
- {
|
||||
- /* Find the fragment. */
|
||||
- symbolS *sym = tinsn->tok[1].X_add_symbol;
|
||||
- gas_assert (S_GET_SEGMENT (sym) == segP
|
||||
- || S_GET_SEGMENT (sym) == absolute_section);
|
||||
- target = (S_GET_VALUE (sym) + tinsn->tok[1].X_add_number);
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- as_bad (_("invalid expression evaluation type %d"), tinsn->tok[1].X_op);
|
||||
- target = 0;
|
||||
- }
|
||||
-
|
||||
- loop_length = target - (fragP->fr_address + fragP->fr_fix);
|
||||
- loop_length_hi = loop_length & ~0x0ff;
|
||||
- loop_length_lo = loop_length & 0x0ff;
|
||||
- if (loop_length_lo >= 128)
|
||||
- {
|
||||
- loop_length_lo -= 256;
|
||||
- loop_length_hi += 256;
|
||||
- }
|
||||
-
|
||||
- /* Because addmi sign-extends the immediate, 'loop_length_hi' can be at most
|
||||
- 32512. If the loop is larger than that, then we just fail. */
|
||||
- if (loop_length_hi > 32512)
|
||||
- as_bad_where (fragP->fr_file, fragP->fr_line,
|
||||
- _("loop too long for LOOP instruction"));
|
||||
-
|
||||
- tinsn_from_chars (&addi_insn, fragP->fr_opcode + addi_offset, 0);
|
||||
- gas_assert (addi_insn.opcode == xtensa_addi_opcode);
|
||||
-
|
||||
- tinsn_from_chars (&addmi_insn, fragP->fr_opcode + addmi_offset, 0);
|
||||
- gas_assert (addmi_insn.opcode == xtensa_addmi_opcode);
|
||||
-
|
||||
- set_expr_const (&addi_insn.tok[2], loop_length_lo);
|
||||
- tinsn_to_insnbuf (&addi_insn, insnbuf);
|
||||
-
|
||||
- fragP->tc_frag_data.is_insn = TRUE;
|
||||
- xtensa_insnbuf_to_chars
|
||||
- (isa, insnbuf, (unsigned char *) fragP->fr_opcode + addi_offset, 0);
|
||||
-
|
||||
- set_expr_const (&addmi_insn.tok[2], loop_length_hi);
|
||||
- tinsn_to_insnbuf (&addmi_insn, insnbuf);
|
||||
- xtensa_insnbuf_to_chars
|
||||
- (isa, insnbuf, (unsigned char *) fragP->fr_opcode + addmi_offset, 0);
|
||||
-
|
||||
- /* Walk through all of the frags from here to the loop end
|
||||
- and mark them as no_transform to keep them from being modified
|
||||
- by the linker. If we ever have a relocation for the
|
||||
- addi/addmi of the difference of two symbols we can remove this. */
|
||||
-
|
||||
- target_count = 0;
|
||||
- for (next_fragP = fragP; next_fragP != NULL;
|
||||
- next_fragP = next_fragP->fr_next)
|
||||
- {
|
||||
- next_fragP->tc_frag_data.is_no_transform = TRUE;
|
||||
- if (next_fragP->tc_frag_data.is_loop_target)
|
||||
- target_count++;
|
||||
- if (target_count == 2)
|
||||
- break;
|
||||
- }
|
||||
-}
|
||||
-
|
||||
|
||||
/* A map that keeps information on a per-subsegment basis. This is
|
||||
maintained during initial assembly, but is invalid once the
|
||||
diff --git a/gas/config/xtensa-relax.c b/gas/config/xtensa-relax.c
|
||||
index cb296ed85ed2..daf15d52c259 100644
|
||||
--- a/gas/config/xtensa-relax.c
|
||||
+++ b/gas/config/xtensa-relax.c
|
||||
@@ -87,13 +87,7 @@
|
||||
when the first and second operands are not the same as specified
|
||||
by the "| %at!=%as" precondition clause.
|
||||
{"l32i %at,%as,%imm | %at!=%as",
|
||||
- "LITERAL %imm; l32r %at,%LITERAL; add %at,%at,%as; l32i %at,%at,0"}
|
||||
-
|
||||
- There is special case for loop instructions here, but because we do
|
||||
- not currently have the ability to represent the difference of two
|
||||
- symbols, the conversion requires special code in the assembler to
|
||||
- write the operands of the addi/addmi pair representing the
|
||||
- difference of the old and new loop end label. */
|
||||
+ "LITERAL %imm; l32r %at,%LITERAL; add %at,%at,%as; l32i %at,%at,0"} */
|
||||
|
||||
#include "as.h"
|
||||
#include "xtensa-isa.h"
|
||||
@@ -306,44 +300,83 @@ static string_pattern_pair widen_spec_list[] =
|
||||
{"l32i %at,%as,%imm | %at!=%as ? IsaUseConst16",
|
||||
"const16 %at,HI16U(%imm); const16 %at,LOW16U(%imm); add %at,%at,%as; l32i %at,%at,0"},
|
||||
|
||||
- /* This is only PART of the loop instruction. In addition,
|
||||
- hardcoded into its use is a modification of the final operand in
|
||||
- the instruction in bytes 9 and 12. */
|
||||
- {"loop %as,%label | %as!=1 ? IsaUseLoops",
|
||||
+ /* Widening loops with literals. */
|
||||
+ {"loop %as,%label | %as!=1 ? IsaUseLoops ? IsaUseL32R",
|
||||
+ "loop %as,%LABEL;"
|
||||
+ "rsr.lend %as;" /* LEND */
|
||||
+ "wsr.lbeg %as;" /* LBEG */
|
||||
+ "LITERAL %label;"
|
||||
+ "l32r %as, %LITERAL;"
|
||||
+ "nop;"
|
||||
+ "wsr.lend %as;"
|
||||
+ "isync;"
|
||||
+ "rsr.lcount %as;" /* LCOUNT */
|
||||
+ "addi %as, %as, 1;"
|
||||
+ "LABEL"},
|
||||
+ {"loopgtz %as,%label | %as!=1 ? IsaUseLoops ? IsaUseL32R",
|
||||
+ "beqz %as,%label;"
|
||||
+ "bltz %as,%label;"
|
||||
+ "loopgtz %as,%LABEL;"
|
||||
+ "rsr.lend %as;" /* LEND */
|
||||
+ "wsr.lbeg %as;" /* LBEG */
|
||||
+ "LITERAL %label;"
|
||||
+ "l32r %as, %LITERAL;"
|
||||
+ "nop;"
|
||||
+ "wsr.lend %as;"
|
||||
+ "isync;"
|
||||
+ "rsr.lcount %as;" /* LCOUNT */
|
||||
+ "addi %as, %as, 1;"
|
||||
+ "LABEL"},
|
||||
+ {"loopnez %as,%label | %as!=1 ? IsaUseLoops ? IsaUseL32R",
|
||||
+ "beqz %as,%label;"
|
||||
+ "loopnez %as,%LABEL;"
|
||||
+ "rsr.lend %as;" /* LEND */
|
||||
+ "wsr.lbeg %as;" /* LBEG */
|
||||
+ "LITERAL %label;"
|
||||
+ "l32r %as, %LITERAL;"
|
||||
+ "nop;"
|
||||
+ "wsr.lend %as;"
|
||||
+ "isync;"
|
||||
+ "rsr.lcount %as;" /* LCOUNT */
|
||||
+ "addi %as, %as, 1;"
|
||||
+ "LABEL"},
|
||||
+
|
||||
+ /* Widening loops with const16. */
|
||||
+ {"loop %as,%label | %as!=1 ? IsaUseLoops ? IsaUseConst16",
|
||||
"loop %as,%LABEL;"
|
||||
"rsr.lend %as;" /* LEND */
|
||||
"wsr.lbeg %as;" /* LBEG */
|
||||
- "addi %as, %as, 0;" /* lo8(%label-%LABEL1) */
|
||||
- "addmi %as, %as, 0;" /* mid8(%label-%LABEL1) */
|
||||
+ "const16 %as,HI16U(%label);"
|
||||
+ "const16 %as,LOW16U(%label);"
|
||||
"wsr.lend %as;"
|
||||
"isync;"
|
||||
"rsr.lcount %as;" /* LCOUNT */
|
||||
- "addi %as, %as, 1;" /* density -> addi.n %as, %as, 1 */
|
||||
+ "addi %as, %as, 1;"
|
||||
"LABEL"},
|
||||
- {"loopgtz %as,%label | %as!=1 ? IsaUseLoops",
|
||||
+ {"loopgtz %as,%label | %as!=1 ? IsaUseLoops ? IsaUseConst16",
|
||||
"beqz %as,%label;"
|
||||
"bltz %as,%label;"
|
||||
"loopgtz %as,%LABEL;"
|
||||
"rsr.lend %as;" /* LEND */
|
||||
"wsr.lbeg %as;" /* LBEG */
|
||||
- "addi %as, %as, 0;" /* lo8(%label-%LABEL1) */
|
||||
- "addmi %as, %as, 0;" /* mid8(%label-%LABEL1) */
|
||||
+ "const16 %as,HI16U(%label);"
|
||||
+ "const16 %as,LOW16U(%label);"
|
||||
"wsr.lend %as;"
|
||||
"isync;"
|
||||
"rsr.lcount %as;" /* LCOUNT */
|
||||
- "addi %as, %as, 1;" /* density -> addi.n %as, %as, 1 */
|
||||
+ "addi %as, %as, 1;"
|
||||
"LABEL"},
|
||||
- {"loopnez %as,%label | %as!=1 ? IsaUseLoops",
|
||||
+ {"loopnez %as,%label | %as!=1 ? IsaUseLoops ? IsaUseConst16",
|
||||
"beqz %as,%label;"
|
||||
"loopnez %as,%LABEL;"
|
||||
"rsr.lend %as;" /* LEND */
|
||||
"wsr.lbeg %as;" /* LBEG */
|
||||
- "addi %as, %as, 0;" /* lo8(%label-%LABEL1) */
|
||||
- "addmi %as, %as, 0;" /* mid8(%label-%LABEL1) */
|
||||
+ "const16 %as,HI16U(%label);"
|
||||
+ "const16 %as,LOW16U(%label);"
|
||||
"wsr.lend %as;"
|
||||
"isync;"
|
||||
"rsr.lcount %as;" /* LCOUNT */
|
||||
- "addi %as, %as, 1;" /* density -> addi.n %as, %as, 1 */
|
||||
+ "addi %as, %as, 1;"
|
||||
"LABEL"},
|
||||
|
||||
/* Relaxing to wide branches. Order is important here. With wide
|
||||
--
|
||||
2.11.0
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
From 471702ac4a57878a06e8167f063274cf413e548d Mon Sep 17 00:00:00 2001
|
||||
From: Max Filippov <jcmvbkbc@gmail.com>
|
||||
Date: Mon, 8 Apr 2019 13:47:18 -0700
|
||||
Subject: [PATCH] xtensa: gas: put .literal_position at section start
|
||||
|
||||
Provide literal position at the beginning of each section for literal
|
||||
space reserved by relaxations when text-section-literals or
|
||||
auto-litpools options are used. Remove code that adds fill frag to the
|
||||
literal section for every .literal_position directive to avoid creation
|
||||
of empty literal sections.
|
||||
|
||||
Fix auto-litpools tests that got literal pool address changes.
|
||||
|
||||
gas/
|
||||
2019-04-11 Max Filippov <jcmvbkbc@gmail.com>
|
||||
|
||||
* config/tc-xtensa.c (xtensa_is_init_fini): Add declaration.
|
||||
(xtensa_mark_literal_pool_location): Don't add fill frag to literal
|
||||
section that records literal pool location.
|
||||
(md_begin): Call xtensa_mark_literal_pool_location when text
|
||||
section literals or auto litpools are used.
|
||||
(xtensa_elf_section_change_hook): Call
|
||||
xtensa_mark_literal_pool_location when text section literals or
|
||||
auto litpools are used, there's no literal pool location defined
|
||||
for the current section and it's not .init or .fini.
|
||||
|
||||
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
|
||||
---
|
||||
gas/config/tc-xtensa.c | 22 +++++++++-------------
|
||||
1 file changed, 9 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
|
||||
index 0cc06361cf6f..6a80e76fed8c 100644
|
||||
--- a/gas/config/tc-xtensa.c
|
||||
+++ b/gas/config/tc-xtensa.c
|
||||
@@ -497,6 +497,7 @@ static fixS *xg_append_jump (fragS *fragP, symbolS *sym, offsetT offset);
|
||||
static void xtensa_maybe_create_literal_pool_frag (bfd_boolean, bfd_boolean);
|
||||
static bfd_boolean auto_litpools = FALSE;
|
||||
static int auto_litpool_limit = 0;
|
||||
+static bfd_boolean xtensa_is_init_fini (segT seg);
|
||||
|
||||
/* Alignment Functions. */
|
||||
|
||||
@@ -4797,7 +4798,6 @@ xtensa_mark_literal_pool_location (void)
|
||||
{
|
||||
/* Any labels pointing to the current location need
|
||||
to be adjusted to after the literal pool. */
|
||||
- emit_state s;
|
||||
fragS *pool_location;
|
||||
|
||||
if (use_literal_section)
|
||||
@@ -4818,19 +4818,7 @@ xtensa_mark_literal_pool_location (void)
|
||||
RELAX_LITERAL_POOL_END, NULL, 0, NULL);
|
||||
xtensa_set_frag_assembly_state (frag_now);
|
||||
|
||||
- /* Now put a frag into the literal pool that points to this location. */
|
||||
set_literal_pool_location (now_seg, pool_location);
|
||||
- xtensa_switch_to_non_abs_literal_fragment (&s);
|
||||
- frag_align (2, 0, 0);
|
||||
- record_alignment (now_seg, 2);
|
||||
-
|
||||
- /* Close whatever frag is there. */
|
||||
- frag_variant (rs_fill, 0, 0, 0, NULL, 0, NULL);
|
||||
- xtensa_set_frag_assembly_state (frag_now);
|
||||
- frag_now->tc_frag_data.literal_frag = pool_location;
|
||||
- frag_variant (rs_fill, 0, 0, 0, NULL, 0, NULL);
|
||||
- xtensa_restore_emit_state (&s);
|
||||
- xtensa_set_frag_assembly_state (frag_now);
|
||||
}
|
||||
|
||||
|
||||
@@ -5334,6 +5322,9 @@ md_begin (void)
|
||||
/* Set up the assembly state. */
|
||||
if (!frag_now->tc_frag_data.is_assembly_state_set)
|
||||
xtensa_set_frag_assembly_state (frag_now);
|
||||
+
|
||||
+ if (!use_literal_section)
|
||||
+ xtensa_mark_literal_pool_location ();
|
||||
}
|
||||
|
||||
|
||||
@@ -5933,6 +5924,11 @@ xtensa_elf_section_change_hook (void)
|
||||
/* Set up the assembly state. */
|
||||
if (!frag_now->tc_frag_data.is_assembly_state_set)
|
||||
xtensa_set_frag_assembly_state (frag_now);
|
||||
+
|
||||
+ if (!use_literal_section
|
||||
+ && seg_info (now_seg)->tc_segment_info_data.literal_pool_loc == NULL
|
||||
+ && !xtensa_is_init_fini (now_seg))
|
||||
+ xtensa_mark_literal_pool_location ();
|
||||
}
|
||||
|
||||
|
||||
--
|
||||
2.11.0
|
||||
|
||||
Reference in New Issue
Block a user