From e4782e838130706e2d2d53a9e3c29f71419863ae Mon Sep 17 00:00:00 2001 From: Doug Kwan Date: Fri, 12 Feb 2010 05:51:32 +0000 Subject: 2010-02-11 Doug Kwan * arm.cc (Target_arm::Scan::local): Fix bugs in relocation handling. (Target_arm::Scan::global): Ditto. Also remove a comment before the beginning of function. (Target_arm::Relocate::relocate): Remove error messages for MOVW_ABS and MOVT_ABS relocations. Those are non issued in scanning. Fix parameter is_32bit in calls to should_apply_static_reloc. * testsuite/Makefile.am (check_SCRIPTS): Add arm_abs_global.sh. (check_DATA): Add arm_abs_global.stdout. (arm_abs_lib.o, libarm_abs.so, arm_abs_global.o, arm_abs_global, arm_abs_global.stdout): New rules. (MOSTLLYCLEANFILES): Add arm_abs_global * Makefile.in: Regenerate. * testsuite/arm_abs_global.s: New file. * testsuite/arm_abs_global.sh: Ditto. * testsuite/arm_abs_lib.s: Ditto. --- gold/testsuite/Makefile.am | 19 ++++++++++++++ gold/testsuite/Makefile.in | 20 +++++++++++--- gold/testsuite/arm_abs_global.s | 31 ++++++++++++++++++++++ gold/testsuite/arm_abs_global.sh | 57 ++++++++++++++++++++++++++++++++++++++++ gold/testsuite/arm_abs_lib.s | 37 ++++++++++++++++++++++++++ 5 files changed, 161 insertions(+), 3 deletions(-) create mode 100644 gold/testsuite/arm_abs_global.s create mode 100755 gold/testsuite/arm_abs_global.sh create mode 100644 gold/testsuite/arm_abs_lib.s (limited to 'gold/testsuite') diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am index 1ffb7b0..a1889bb 100644 --- a/gold/testsuite/Makefile.am +++ b/gold/testsuite/Makefile.am @@ -1435,3 +1435,22 @@ MOSTLYCLEANFILES += split_x86_64_1 split_x86_64_2 split_x86_64_3 \ split_x86_64_4 split_x86_64_r endif DEFAULT_TARGET_X86_64 + +if DEFAULT_TARGET_ARM + +check_SCRIPTS += arm_abs_global.sh +check_DATA += arm_abs_global.stdout +arm_abs_lib.o: arm_abs_lib.s + $(TEST_AS) -march=armv7-a -o $@ $< +libarm_abs.so: arm_abs_lib.o + ../ld-new -shared -o $@ arm_abs_lib.o +arm_abs_global.o: arm_abs_global.s + $(TEST_AS) -march=armv7-a -o $@ $< +arm_abs_global: arm_abs_global.o libarm_abs.so + ../ld-new -o $@ arm_abs_global.o -L. -larm_abs +arm_abs_global.stdout: arm_abs_global + $(TEST_READELF) -r $< > $@ + +MOSTLYCLEANFILES += arm_abs_global + +endif DEFAULT_TARGET_ARM diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in index a806b34..e5fd65f 100644 --- a/gold/testsuite/Makefile.in +++ b/gold/testsuite/Makefile.in @@ -318,6 +318,9 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \ @DEFAULT_TARGET_X86_64_TRUE@am__append_37 = split_x86_64_1 split_x86_64_2 split_x86_64_3 \ @DEFAULT_TARGET_X86_64_TRUE@ split_x86_64_4 split_x86_64_r +@DEFAULT_TARGET_ARM_TRUE@am__append_38 = arm_abs_global.sh +@DEFAULT_TARGET_ARM_TRUE@am__append_39 = arm_abs_global.stdout +@DEFAULT_TARGET_ARM_TRUE@am__append_40 = arm_abs_global subdir = testsuite DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -1378,15 +1381,16 @@ TEST_AS = $(top_builddir)/../gas/as-new # the right choice for files 'make' builds that people rebuild. MOSTLYCLEANFILES = *.so *.syms *.stdout $(am__append_3) \ $(am__append_8) $(am__append_17) $(am__append_25) \ - $(am__append_29) $(am__append_34) $(am__append_37) + $(am__append_29) $(am__append_34) $(am__append_37) \ + $(am__append_40) # We will add to these later, for each individual test. Note # that we add each test under check_SCRIPTS or check_PROGRAMS; # the TESTS variable is automatically populated from these. check_SCRIPTS = $(am__append_1) $(am__append_23) $(am__append_27) \ - $(am__append_32) $(am__append_35) + $(am__append_32) $(am__append_35) $(am__append_38) check_DATA = $(am__append_2) $(am__append_24) $(am__append_28) \ - $(am__append_33) $(am__append_36) + $(am__append_33) $(am__append_36) $(am__append_39) BUILT_SOURCES = $(am__append_16) TESTS = $(check_SCRIPTS) $(check_PROGRAMS) @@ -3193,6 +3197,16 @@ uninstall-am: @DEFAULT_TARGET_X86_64_TRUE@ $(TEST_OBJDUMP) -d $< > $@ @DEFAULT_TARGET_X86_64_TRUE@split_x86_64_r.stdout: split_x86_64_1.o split_x86_64_n.o ../ld-new @DEFAULT_TARGET_X86_64_TRUE@ ../ld-new -r split_x86_64_1.o split_x86_64_n.o -o split_x86_64_r > $@ 2>&1 || exit 0 +@DEFAULT_TARGET_ARM_TRUE@arm_abs_lib.o: arm_abs_lib.s +@DEFAULT_TARGET_ARM_TRUE@ $(TEST_AS) -march=armv7-a -o $@ $< +@DEFAULT_TARGET_ARM_TRUE@libarm_abs.so: arm_abs_lib.o +@DEFAULT_TARGET_ARM_TRUE@ ../ld-new -shared -o $@ arm_abs_lib.o +@DEFAULT_TARGET_ARM_TRUE@arm_abs_global.o: arm_abs_global.s +@DEFAULT_TARGET_ARM_TRUE@ $(TEST_AS) -march=armv7-a -o $@ $< +@DEFAULT_TARGET_ARM_TRUE@arm_abs_global: arm_abs_global.o libarm_abs.so +@DEFAULT_TARGET_ARM_TRUE@ ../ld-new -o $@ arm_abs_global.o -L. -larm_abs +@DEFAULT_TARGET_ARM_TRUE@arm_abs_global.stdout: arm_abs_global +@DEFAULT_TARGET_ARM_TRUE@ $(TEST_READELF) -r $< > $@ # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/gold/testsuite/arm_abs_global.s b/gold/testsuite/arm_abs_global.s new file mode 100644 index 0000000..65cb309 --- /dev/null +++ b/gold/testsuite/arm_abs_global.s @@ -0,0 +1,31 @@ + .syntax unified + + .text + .align 2 + + .global _start + .type _start, %function +_start: + bx lr + .size _start, .-_start + + .global _arm_test + .type _arm_test, %function +_arm_test: + movt r0, #:upper16:_movt_abs_global + movw r0, #:lower16:_movw_abs_global + bx lr + .size _arm_test, .-_arm_test + + .thumb + .global _thumb_test +_thumb_test: + movt r0, #:upper16:_thm_movt_abs_global + movw r0, #:lower16:_thm_movw_abs_global + bx lr + .size _thumb_test, .-_thumb_test + + .data +_data_test: + .word _abs32_global + .word _abs32_global_plt diff --git a/gold/testsuite/arm_abs_global.sh b/gold/testsuite/arm_abs_global.sh new file mode 100755 index 0000000..26abc24 --- /dev/null +++ b/gold/testsuite/arm_abs_global.sh @@ -0,0 +1,57 @@ +#!/bin/sh + +# arm_abs_global.sh -- test ARM absolute relocations against global symbols. + +# Copyright 2010 Free Software Foundation, Inc. +# Written by Doug Kwan + +# 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 the assembler source file arm_abs_global.s, +# that is assembled and linked with a shared object libarm_abs.so. We +# want to check that a MOV[TW] instruction referencing an external function +# causes a PLT to be created. + +check() +{ + file=$1 + sym=$2 + reloc=$3 + + found=`grep " $sym\$" $file` + if test -z "$found"; then + echo "Symbol $sym not found." + exit 1 + fi + + match_reloc=`grep " $sym\$" $file | grep " $reloc "` + if test -z "$match_reloc"; then + echo "Expected symbol $sym to have relocation $reloc but found" + echo "$found" + exit 1 + fi +} + +check "arm_abs_global.stdout" "_movt_abs_global" "R_ARM_JUMP_SLOT" +check "arm_abs_global.stdout" "_movw_abs_global" "R_ARM_JUMP_SLOT" +check "arm_abs_global.stdout" "_thm_movt_abs_global" "R_ARM_JUMP_SLOT" +check "arm_abs_global.stdout" "_thm_movw_abs_global" "R_ARM_JUMP_SLOT" +check "arm_abs_global.stdout" "_abs32_global_plt" "R_ARM_JUMP_SLOT" +check "arm_abs_global.stdout" "_abs32_global" "R_ARM_ABS32" + +exit 0 diff --git a/gold/testsuite/arm_abs_lib.s b/gold/testsuite/arm_abs_lib.s new file mode 100644 index 0000000..a2d7207 --- /dev/null +++ b/gold/testsuite/arm_abs_lib.s @@ -0,0 +1,37 @@ + .syntax unified + + .text + .align 2 + .global _movt_abs_global + .type _movt_abs_global, %function +_movt_abs_global: + bx lr + .size _movt_abs_global, .-_movt_abs_global + + .global _movw_abs_global + .type _movw_abs_global, %function +_movw_abs_global: + bx lr + .size _movw_abs_global, .-_movw_abs_global + + .thumb + .align 2 + .global _thm_movt_abs_global + .type _thm_movt_abs_global, %function +_thm_movt_abs_global: + bx lr + .size _thm_movt_abs_global, .-_thm_movt_abs_global + + .global _thm_movw_abs_global + .type _thm_movw_abs_global, %function +_thm_movw_abs_global: + bx lr + .size _thm_movw_abs_global, .-_thm_movw_abs_global + + .global _abs32_global_plt + .type _abs32_global_plt, %function +_abs32_global_plt: + bx lr + .size _abs32_global_plt, .-_abs32_global_plt + + .comm _abs32_global,4,4 -- cgit v1.1