[3/5] ld: xtensa: use default LD command line options for endianness

Message ID 34d2f747237aeeda595560cfded8096d9bd1c28c.camel@espressif.com
State Unresolved
Headers
Series Add Xtensa ESP chips support |

Checks

Context Check Description
snail/binutils-gdb-check warning Git am fail log

Commit Message

Alexey Lapshin Oct. 22, 2022, 12:56 p.m. UTC
  Use --EB, --EL ld options instead of hardcoded macro definition.

---
 ld/emultempl/xtensaelf.em | 27 +++------------------------
 1 file changed, 3 insertions(+), 24 deletions(-)

-- 
2.34.1
  

Patch

diff --git a/ld/emultempl/xtensaelf.em b/ld/emultempl/xtensaelf.em
index ed2945b850d..f06bcb97daa 100644
--- a/ld/emultempl/xtensaelf.em
+++ b/ld/emultempl/xtensaelf.em
@@ -66,7 +66,8 @@  static char *
 elf_xtensa_choose_target (int argc ATTRIBUTE_UNUSED,
 			  char **argv ATTRIBUTE_UNUSED)
 {
-  if (XCHAL_HAVE_BE)
+  if (command_line.endian == ENDIAN_BIG ||
+      (command_line.endian == ENDIAN_UNSET && XCHAL_HAVE_BE))
     return "${BIG_OUTPUT_FORMAT}";
   else
     return "${LITTLE_OUTPUT_FORMAT}";
@@ -343,27 +344,6 @@  elf_xtensa_before_allocation (void)
   xtensa_info_entries xtensa_info;
   asection *info_sec, *first_info_sec;
   bfd *first_bfd;
-  bool is_big_endian = XCHAL_HAVE_BE;
-
-  /* Check that the output endianness matches the Xtensa
-     configuration.  The BFD library always includes both big and
-     little endian target vectors for Xtensa, but it only supports the
-     detailed instruction encode/decode operations (such as are
-     required to process relocations) for the selected Xtensa
-     configuration.  */
-
-  if (is_big_endian
-      && link_info.output_bfd->xvec->byteorder == BFD_ENDIAN_LITTLE)
-    {
-      einfo (_("%F%P: little endian output does not match "
-	       "Xtensa configuration\n"));
-    }
-  if (!is_big_endian
-      && link_info.output_bfd->xvec->byteorder == BFD_ENDIAN_BIG)
-    {
-      einfo (_("%F%P: big endian output does not match "
-	       "Xtensa configuration\n"));
-    }
 
   /* Keep track of the first input .xtensa.info section, and as a fallback,
      the first input bfd where a .xtensa.info section could be created.
@@ -378,8 +358,7 @@  elf_xtensa_before_allocation (void)
 	 The merge_private_bfd_data hook has already reported any mismatches
 	 as errors, but those errors are not fatal.  At this point, we
 	 cannot go any further if there are any mismatches.  */
-      if ((is_big_endian && f->the_bfd->xvec->byteorder == BFD_ENDIAN_LITTLE)
-	  || (!is_big_endian && f->the_bfd->xvec->byteorder == BFD_ENDIAN_BIG))
+      if (link_info.output_bfd->xvec->byteorder != f->the_bfd->xvec->byteorder)
 	einfo (_("%F%P: cross-endian linking for %pB not supported\n"),
 	       f->the_bfd);