Implement BE8 support for ARM.
authorUmesh Kalappa <ukalappa@cisco.com>
Fri, 20 Oct 2017 03:53:14 +0000 (20:53 -0700)
committerCary Coutant <ccoutant@gmail.com>
Fri, 20 Oct 2017 03:53:14 +0000 (20:53 -0700)
gold/
* arm.cc (Stub::do_fixed_endian_write):Far call stubs support for arm
in the be8 mode.
* testsuite/Makefile.am: New test cases.
* testsuite/Makefile.in: Regenerate.
* testsuite/arm_farcall_arm_arm_be8.sh: New script for arm to arm far
call stubs.
* testsuite/arm_farcall_thumb_thumb_be8.sh: New script for thumb to
thumb far call stubs.

gold/ChangeLog
gold/arm.cc
gold/options.h
gold/testsuite/Makefile.am
gold/testsuite/Makefile.in
gold/testsuite/arm_farcall_arm_arm_be8.sh [new file with mode: 0755]
gold/testsuite/arm_farcall_thumb_thumb_be8.sh [new file with mode: 0755]

index a47ae9677870b980bac049cc38b1dacf2d8a2a90..c12214b1849c970d0e81d7988b986ee0e8e26501 100644 (file)
@@ -1,3 +1,14 @@
+2017-10-19  Umesh Kalappa  <ukalappa@cisco.com>
+
+       * arm.cc (Stub::do_fixed_endian_write):Far call stubs support for arm
+       in the be8 mode.
+       * testsuite/Makefile.am: New test cases.
+       * testsuite/Makefile.in: Regenerate.
+       * testsuite/arm_farcall_arm_arm_be8.sh: New script for arm to arm far
+       call stubs.
+       * testsuite/arm_farcall_thumb_thumb_be8.sh: New script for thumb to
+       thumb far call stubs.
+
 2017-10-18  Kyle Butt  <iteratee@google.com>
            Alan Modra  <amodra@gmail.com>
 
index f887fe558b8de05755ef44f355aabb8e07a92c39..982c46de8bb682d7a749f7ad5ab5adad35f230b3 100644 (file)
@@ -4516,30 +4516,49 @@ Stub::do_fixed_endian_write(unsigned char* view, section_size_type view_size)
 {
   const Stub_template* stub_template = this->stub_template();
   const Insn_template* insns = stub_template->insns();
+  const bool enable_be8 = parameters->options().be8();
 
-  // FIXME:  We do not handle BE8 encoding yet.
   unsigned char* pov = view;
   for (size_t i = 0; i < stub_template->insn_count(); i++)
     {
       switch (insns[i].type())
        {
        case Insn_template::THUMB16_TYPE:
-         elfcpp::Swap<16, big_endian>::writeval(pov, insns[i].data() & 0xffff);
+         if (enable_be8)
+           elfcpp::Swap<16, false>::writeval(pov, insns[i].data() & 0xffff);
+         else
+           elfcpp::Swap<16, big_endian>::writeval(pov,
+                                                  insns[i].data() & 0xffff);
          break;
        case Insn_template::THUMB16_SPECIAL_TYPE:
-         elfcpp::Swap<16, big_endian>::writeval(
-             pov,
-             this->thumb16_special(i));
+         if (enable_be8)
+           elfcpp::Swap<16, false>::writeval(pov, this->thumb16_special(i));
+         else
+           elfcpp::Swap<16, big_endian>::writeval(pov,
+                                                  this->thumb16_special(i));
          break;
        case Insn_template::THUMB32_TYPE:
          {
            uint32_t hi = (insns[i].data() >> 16) & 0xffff;
            uint32_t lo = insns[i].data() & 0xffff;
-           elfcpp::Swap<16, big_endian>::writeval(pov, hi);
-           elfcpp::Swap<16, big_endian>::writeval(pov + 2, lo);
+           if (enable_be8)
+             {
+               elfcpp::Swap<16, false>::writeval(pov, hi);
+               elfcpp::Swap<16, false>::writeval(pov + 2, lo);
+             }
+           else
+             {
+               elfcpp::Swap<16, big_endian>::writeval(pov, hi);
+               elfcpp::Swap<16, big_endian>::writeval(pov + 2, lo);
+             }
          }
          break;
        case Insn_template::ARM_TYPE:
+         if (enable_be8)
+           elfcpp::Swap<32, false>::writeval(pov, insns[i].data());
+         else
+           elfcpp::Swap<32, big_endian>::writeval(pov, insns[i].data());
+         break;
        case Insn_template::DATA_TYPE:
          elfcpp::Swap<32, big_endian>::writeval(pov, insns[i].data());
          break;
index 93f81b29afcc803edf9f1f5ba574cf8a410ea0e9..678ca8208ec8ec1745f2e05b2c8c7e8823cb9051 100644 (file)
@@ -711,7 +711,7 @@ class General_options
   DEFINE_string(format, options::TWO_DASHES, 'b', "elf",
                N_("Set input format"), ("[elf,binary]"));
 
-  DEFINE_bool(be8,options::TWO_DASHES, '\0', false,
+  DEFINE_bool(be8, options::TWO_DASHES, '\0', false,
              N_("Output BE8 format image"), NULL);
 
   DEFINE_optional_string(build_id, options::TWO_DASHES, '\0', "tree",
index cae47f1e0972768ef6e92403b5c74b47f62d966d..8eca3d8e0726b74fc9c4f15ad93a9571863d42e6 100644 (file)
@@ -3722,6 +3722,38 @@ arm_farcall_thumb_thumb_6m.o: arm_farcall_thumb_thumb.s
 MOSTLYCLEANFILES += arm_farcall_thumb_thumb arm_farcall_thumb_thumb_5t \
                    arm_farcall_thumb_thumb_7m arm_farcall_thumb_thumb_6m
 
+#Check ARM to ARM farcall veneers in the be8 mode addressing
+
+check_SCRIPTS += arm_farcall_arm_arm_be8.sh
+check_DATA += arm_farcall_arm_arm_be8.stdout
+
+arm_farcall_arm_arm_be8.stdout: arm_farcall_arm_arm_be8
+       $(TEST_OBJDUMP) -D $< > $@
+
+arm_farcall_arm_arm_be8: arm_farcall_arm_arm_be8.o ../ld-new
+       ../ld-new --no-fix-arm1176 --section-start .text=0x1000 --section-start .foo=0x2001020 -EB --be8 -o $@ $<
+
+arm_farcall_arm_arm_be8.o: arm_farcall_arm_arm.s
+       $(TEST_AS) -EB -o $@ $<
+
+MOSTLYCLEANFILES += arm_farcall_arm_arm_be8
+
+#Check THUMB  to  THUMB farcall veneers in the be8 mode addressing
+
+check_SCRIPTS += arm_farcall_thumb_thumb_be8.sh
+check_DATA += arm_farcall_thumb_thumb_be8.stdout
+
+arm_farcall_thumb_thumb_be8.stdout: arm_farcall_thumb_thumb_be8
+       $(TEST_OBJDUMP) -D $< > $@
+
+arm_farcall_thumb_thumb_be8: arm_farcall_thumb_thumb_be8.o ../ld-new
+       ../ld-new --section-start .text=0x1000 --section-start .foo=0x2001014 -EB --be8 -o $@ $<
+
+arm_farcall_thumb_thumb_be8.o: arm_farcall_thumb_thumb.s
+       $(TEST_AS) -march=armv7-m -EB -o $@ $<
+
+MOSTLYCLEANFILES += arm_farcall_thumb_thumb_be8
+
 # Check Thumb to ARM farcall veneers
 
 check_SCRIPTS += arm_farcall_thumb_arm.sh
index 0169fce141f21691f99c178ab1fa78ff190c459b..10f9493abe3378c21bf89aeab6347fc18432320e 100644 (file)
@@ -856,6 +856,10 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
 
 # Check Thumb to Thumb farcall veneers
 
+#Check ARM to ARM farcall veneers in the be8 mode addressing
+
+#Check THUMB  to  THUMB farcall veneers in the be8 mode addressing
+
 # Check Thumb to ARM farcall veneers
 
 # Check handling of --target1-abs, --target1-rel and --target2 options
@@ -872,6 +876,8 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_arm_arm.sh \
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_arm_thumb.sh \
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_thumb_thumb.sh \
+@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_arm_arm_be8.sh \
+@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_thumb_thumb_be8.sh \
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_thumb_arm.sh \
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target1_abs.sh \
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target1_rel.sh \
@@ -923,6 +929,8 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_thumb_thumb_5t.stdout \
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_thumb_thumb_7m.stdout \
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_thumb_thumb_6m.stdout \
+@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_arm_arm_be8.stdout \
+@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_thumb_thumb_be8.stdout \
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_thumb_arm.stdout \
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_thumb_arm_5t.stdout \
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target1_abs.stdout \
@@ -972,6 +980,8 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_thumb_thumb_5t \
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_thumb_thumb_7m \
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_thumb_thumb_6m \
+@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_arm_arm_be8 \
+@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_thumb_thumb_be8 \
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_thumb_arm \
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_thumb_arm_5t \
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target1_abs \
@@ -5320,6 +5330,10 @@ arm_farcall_arm_thumb.sh.log: arm_farcall_arm_thumb.sh
        @p='arm_farcall_arm_thumb.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
 arm_farcall_thumb_thumb.sh.log: arm_farcall_thumb_thumb.sh
        @p='arm_farcall_thumb_thumb.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+arm_farcall_arm_arm_be8.sh.log: arm_farcall_arm_arm_be8.sh
+       @p='arm_farcall_arm_arm_be8.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+arm_farcall_thumb_thumb_be8.sh.log: arm_farcall_thumb_thumb_be8.sh
+       @p='arm_farcall_thumb_thumb_be8.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
 arm_farcall_thumb_arm.sh.log: arm_farcall_thumb_arm.sh
        @p='arm_farcall_thumb_arm.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
 arm_target1_abs.sh.log: arm_target1_abs.sh
@@ -7846,6 +7860,24 @@ uninstall-am:
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@arm_farcall_thumb_thumb_6m.o: arm_farcall_thumb_thumb.s
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_AS) -march=armv6-m -o $@ $<
 
+@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@arm_farcall_arm_arm_be8.stdout: arm_farcall_arm_arm_be8
+@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_OBJDUMP) -D $< > $@
+
+@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@arm_farcall_arm_arm_be8: arm_farcall_arm_arm_be8.o ../ld-new
+@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ ../ld-new --no-fix-arm1176 --section-start .text=0x1000 --section-start .foo=0x2001020 -EB --be8 -o $@ $<
+
+@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@arm_farcall_arm_arm_be8.o: arm_farcall_arm_arm.s
+@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_AS) -EB -o $@ $<
+
+@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@arm_farcall_thumb_thumb_be8.stdout: arm_farcall_thumb_thumb_be8
+@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_OBJDUMP) -D $< > $@
+
+@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@arm_farcall_thumb_thumb_be8: arm_farcall_thumb_thumb_be8.o ../ld-new
+@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ ../ld-new --section-start .text=0x1000 --section-start .foo=0x2001014 -EB --be8 -o $@ $<
+
+@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@arm_farcall_thumb_thumb_be8.o: arm_farcall_thumb_thumb.s
+@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_AS) -march=armv7-m -EB -o $@ $<
+
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@arm_farcall_thumb_arm.stdout: arm_farcall_thumb_arm
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_OBJDUMP) -D $< > $@
 
diff --git a/gold/testsuite/arm_farcall_arm_arm_be8.sh b/gold/testsuite/arm_farcall_arm_arm_be8.sh
new file mode 100755 (executable)
index 0000000..e21a16d
--- /dev/null
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+# arm_farcall_arm_arm_be8.sh -- a test case for ARM->ARM farcall veneers
+
+# Copyright (C) 2010-2017 Free Software Foundation, Inc.
+# This file is part of gold.
+# Based on arm_farcall_arm_arm.s file.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+check()
+{
+    if ! grep -q "$2" "$1"
+    then
+       echo "Did not find expected instruction in $1:"
+       echo "   $2"
+       echo ""
+       echo "Actual instructions below:"
+       cat "$1"
+       exit 1
+    fi
+}
+
+# Check for ARM->ARM default
+check arm_farcall_arm_arm_be8.stdout "1004:    .*      ldr     pc, \[pc, #-4\] .*"
+check arm_farcall_arm_arm_be8.stdout "1008:    20100002"
+
+exit 0
diff --git a/gold/testsuite/arm_farcall_thumb_thumb_be8.sh b/gold/testsuite/arm_farcall_thumb_thumb_be8.sh
new file mode 100755 (executable)
index 0000000..c772a93
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+# arm_farcall_thumb_thumb_be8.sh -- a test case for Thumb->Thumb farcall veneers.
+
+# Copyright (C) 2010-2017 Free Software Foundation, Inc.
+# This file is part of gold.
+# Based on arm_farcall_thumb_thumb.s file
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+check()
+{
+    if ! grep -q "$2" "$1"
+    then
+       echo "Did not find expected instruction in $1:"
+       echo "   $2"
+       echo ""
+       echo "Actual instructions below:"
+       cat "$1"
+       exit 1
+    fi
+}
+
+# Thumb->Thumb
+check arm_farcall_thumb_thumb_be8.stdout "1004:\sb401"
+check arm_farcall_thumb_thumb_be8.stdout "1006:\s4802"
+check arm_farcall_thumb_thumb_be8.stdout "1008:\s4684"
+check arm_farcall_thumb_thumb_be8.stdout "100a:\sbc01"
+check arm_farcall_thumb_thumb_be8.stdout "100c:\s4760"
+check arm_farcall_thumb_thumb_be8.stdout "100e:\sbf00"
+check arm_farcall_thumb_thumb_be8.stdout "1010:\s0002"
+check arm_farcall_thumb_thumb_be8.stdout "1012:\s1510"
+
+exit 0
This page took 0.03447 seconds and 4 git commands to generate.