[PATCH][GOLD] Fix bug in handling ARM arch attribute
Doug Kwan (關振德)
dougkwan@google.com
Wed Jun 1 19:31:00 GMT 2011
Hi Ian,
This fixes the problem in bug 12826. I leave out Asier's e-mail in
the ChangeLog since I have not heard from him whether it is okay to
put it there.
-Doug
2011-05-31 Doug Kwan <dougkwan@google.com>
Asier Llano
PR gold/12826
* arm.cc (Target_arm::tag_cpu_arch_combine): Fix handling of
arch value that equals to elfcpp::MAX_TAG_CPU_ARCH.
* testsuite/Makefile.am: (MOSTLYCLEANFILES): Clean up. Remove redudant
arm_exidx_test.so.
* testsuite/Makefile.in: Regenerate.
(check_SCRIPTS): Add pr12826.sh
(check_DATA): Add pr12826.stdout
(pr12826.stdout, pr12826.so, pr12826_1.o, pr12826_2.o): New rules.
* testsuite/pr12826.sh: New file.
* testsuite/pr12826_1.s: Ditto.
* testsuite/pr12826_1.s: Ditto.
-------------- next part --------------
Index: gold/arm.cc
===================================================================
RCS file: /cvs/src/src/gold/arm.cc,v
retrieving revision 1.132
diff -u -u -p -r1.132 arm.cc
--- gold/arm.cc 24 May 2011 21:41:10 -0000 1.132
+++ gold/arm.cc 1 Jun 2011 19:18:51 -0000
@@ -10202,7 +10202,7 @@ Target_arm<big_endian>::tag_cpu_arch_com
// Check we've not got a higher architecture than we know about.
- if (oldtag >= elfcpp::MAX_TAG_CPU_ARCH || newtag >= elfcpp::MAX_TAG_CPU_ARCH)
+ if (oldtag > elfcpp::MAX_TAG_CPU_ARCH || newtag > elfcpp::MAX_TAG_CPU_ARCH)
{
gold_error(_("%s: unknown CPU architecture"), name);
return -1;
Index: gold/testsuite/Makefile.am
===================================================================
RCS file: /cvs/src/src/gold/testsuite/Makefile.am,v
retrieving revision 1.161
diff -u -u -p -r1.161 Makefile.am
--- gold/testsuite/Makefile.am 29 May 2011 17:24:05 -0000 1.161
+++ gold/testsuite/Makefile.am 1 Jun 2011 19:18:51 -0000
@@ -2214,7 +2214,20 @@ arm_exidx_test.so: arm_exidx_test.o ../l
arm_exidx_test.o: arm_exidx_test.s
$(TEST_AS) -o $@ $<
-MOSTLYCLEANFILES += arm_exidx_test.so
+check_SCRIPTS += pr12826.sh
+check_DATA += pr12826.stdout
+
+pr12826.stdout: pr12826.so
+ $(TEST_READELF) -A $< > $@
+
+pr12826.so: pr12826_1.o pr12826_2.o ../ld-new
+ ../ld-new -shared -o $@ $<
+
+pr12826_1.o: pr12826_1.s
+ $(TEST_AS) -o $@ $<
+
+pr12826_2.o: pr12826_2.s
+ $(TEST_AS) -o $@ $<
endif DEFAULT_TARGET_ARM
Index: gold/testsuite/pr12826.sh
===================================================================
RCS file: gold/testsuite/pr12826.sh
diff -N gold/testsuite/pr12826.sh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gold/testsuite/pr12826.sh 1 Jun 2011 19:18:51 -0000
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+# pr12826.sh -- a test case for combining ARM arch attributes.
+
+# Copyright 2011 Free Software Foundation, Inc.
+# Written by Doug Kwan <dougkwan@google.com>.
+
+# This file is part of gold.
+
+# 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.
+
+# This file goes with pr12826_1.s and pr12826_2.s, two ARM assembly source
+# files constructed to test handling of arch attributes.
+
+check()
+{
+ if ! grep -q "$2" "$1"
+ then
+ echo "Did not find attribute in $1:"
+ echo " $2"
+ echo ""
+ echo "Actual attribute below:"
+ cat "$1"
+ exit 1
+ fi
+}
+
+# Check that arch is armv7e-m.
+check pr12826.stdout "Tag_CPU_arch: v7E-M"
+
+exit 0
Index: gold/testsuite/pr12826_1.s
===================================================================
RCS file: gold/testsuite/pr12826_1.s
diff -N gold/testsuite/pr12826_1.s
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gold/testsuite/pr12826_1.s 1 Jun 2011 19:18:51 -0000
@@ -0,0 +1,13 @@
+ .syntax unified
+ .arch armv7e-m
+ .thumb
+ .text
+ .align 2
+ .global f1
+ .thumb
+ .thumb_func
+ .type f1, %function
+f1:
+ movs r0, #0
+ bx lr
+ .size f1, .-f1
Index: gold/testsuite/pr12826_2.s
===================================================================
RCS file: gold/testsuite/pr12826_2.s
diff -N gold/testsuite/pr12826_2.s
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gold/testsuite/pr12826_2.s 1 Jun 2011 19:18:51 -0000
@@ -0,0 +1,13 @@
+ .syntax unified
+ .arch armv7e-m
+ .thumb
+ .text
+ .align 2
+ .global f2
+ .thumb
+ .thumb_func
+ .type f2, %function
+f2:
+ movs r0, #0
+ bx lr
+ .size f2, .-f2
More information about the Binutils
mailing list