summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Kudrin <ikudrin@accesssoftek.com>2016-06-28 15:43:43 -0700
committerCary Coutant <ccoutant@gmail.com>2016-06-28 15:50:29 -0700
commit5627d875bc059b5c008b408470dcb869b0a8ebd6 (patch)
treeb3aa9131bd572288c1be0d44406953d1da836a85
parent3a4f096e5ff41e2a3b832cf6c815ad1f28437c63 (diff)
downloadbinutils-gdb-5627d875bc059b5c008b408470dcb869b0a8ebd6.tar.gz
Implement the R_AARCH64_NONE relocation.
According to "ELF for the ARM(r) 64-bit Architecture (AArch64)", this relocation can be used "to prevent removal of sections that might otherwise appear to be unused." gold/ * aarch64-reloc.def (NONE): New relocation. * aarch64.cc (Target_aarch64::Scan::local): Handle R_AARCH64_NONE. (Target_aarch64::Scan::global): Likewise. * testsuite/Makefile.am (aarch64_reloc_none): New test. * testsuite/Makefile.in: Regenerate. * testsuite/aarch64_reloc_none.s: New test source file. * testsuite/aarch64_reloc_none.sh: New test script.
-rw-r--r--gold/ChangeLog10
-rw-r--r--gold/aarch64-reloc.def3
-rw-r--r--gold/aarch64.cc6
-rw-r--r--gold/testsuite/Makefile.am15
-rw-r--r--gold/testsuite/Makefile.in31
-rw-r--r--gold/testsuite/aarch64_reloc_none.s16
-rwxr-xr-xgold/testsuite/aarch64_reloc_none.sh57
7 files changed, 129 insertions, 9 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 8b293cd160b..a5f6898d7cf 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,13 @@
+2016-06-28 Igor Kudrin <ikudrin@accesssoftek.com>
+
+ * aarch64-reloc.def (NONE): New relocation.
+ * aarch64.cc (Target_aarch64::Scan::local): Handle R_AARCH64_NONE.
+ (Target_aarch64::Scan::global): Likewise.
+ * testsuite/Makefile.am (aarch64_reloc_none): New test.
+ * testsuite/Makefile.in: Regenerate.
+ * testsuite/aarch64_reloc_none.s: New test source file.
+ * testsuite/aarch64_reloc_none.sh: New test script.
+
2016-06-28 Sriraman Tallam <tmsriram@google.com>
* x86_64.cc (Lazy_view): New class.
diff --git a/gold/aarch64-reloc.def b/gold/aarch64-reloc.def
index f33929b4e85..763d372c67e 100644
--- a/gold/aarch64-reloc.def
+++ b/gold/aarch64-reloc.def
@@ -32,6 +32,9 @@
// Type----------------------------+ | | | | | | |
// Name | | | | | | | |
// | | | | | | | | |
+ARD(NONE , STATIC , NONE , Y, -1, 0,0 , 0,0 , 0 , DATA )
+// Above is from Table 4-5, Null relocation codes
+
ARD(ABS64 , STATIC , DATA , Y, -1, 0,0 , 0,0 , Symbol::ABSOLUTE_REF , DATA )
ARD(ABS32 , STATIC , DATA , Y, -1, 31,32 , 0,0 , Symbol::ABSOLUTE_REF , DATA )
ARD(ABS16 , STATIC , DATA , Y, -1, 15,16 , 0,0 , Symbol::ABSOLUTE_REF , DATA )
diff --git a/gold/aarch64.cc b/gold/aarch64.cc
index 3d03c11ce5a..db9f06c1c67 100644
--- a/gold/aarch64.cc
+++ b/gold/aarch64.cc
@@ -5967,6 +5967,9 @@ Target_aarch64<size, big_endian>::Scan::local(
switch (r_type)
{
+ case elfcpp::R_AARCH64_NONE:
+ break;
+
case elfcpp::R_AARCH64_ABS32:
case elfcpp::R_AARCH64_ABS16:
if (parameters->options().output_is_position_independent())
@@ -6226,6 +6229,9 @@ Target_aarch64<size, big_endian>::Scan::global(
switch (r_type)
{
+ case elfcpp::R_AARCH64_NONE:
+ break;
+
case elfcpp::R_AARCH64_ABS16:
case elfcpp::R_AARCH64_ABS32:
case elfcpp::R_AARCH64_ABS64:
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index 9d4326b3d69..3b0dcc6b438 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -3502,6 +3502,21 @@ MOSTLYCLEANFILES += arm_farcall_thumb_arm arm_farcall_thumb_arm_5t
endif DEFAULT_TARGET_ARM
+if DEFAULT_TARGET_AARCH64
+
+check_SCRIPTS += aarch64_reloc_none.sh
+check_DATA += aarch64_reloc_none.stdout
+aarch64_reloc_none.o: aarch64_reloc_none.s
+ $(TEST_AS) -o $@ $<
+aarch64_reloc_none: aarch64_reloc_none.o ../ld-new
+ ../ld-new -o $@ aarch64_reloc_none.o --gc-sections
+aarch64_reloc_none.stdout: aarch64_reloc_none
+ $(TEST_NM) $< > $@
+
+MOSTLYCLEANFILES += aarch64_reloc_none
+
+endif DEFAULT_TARGET_AARCH64
+
if DEFAULT_TARGET_S390
check_SCRIPTS += split_s390.sh
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index 894e6dd0df8..b398ee93432 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -892,8 +892,11 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
@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_thumb_arm \
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_farcall_thumb_arm_5t
-@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_89 = split_s390.sh
-@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_90 = split_s390_z1.stdout split_s390_z2.stdout split_s390_z3.stdout \
+@DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_89 = aarch64_reloc_none.sh
+@DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_90 = aarch64_reloc_none.stdout
+@DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_91 = aarch64_reloc_none
+@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_92 = split_s390.sh
+@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_93 = split_s390_z1.stdout split_s390_z2.stdout split_s390_z3.stdout \
@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_s390_z4.stdout split_s390_n1.stdout split_s390_n2.stdout \
@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_s390_a1.stdout split_s390_a2.stdout split_s390_z1_ns.stdout \
@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_s390_z2_ns.stdout split_s390_z3_ns.stdout split_s390_z4_ns.stdout \
@@ -905,7 +908,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_s390x_z4_ns.stdout split_s390x_n1_ns.stdout \
@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_s390x_n2_ns.stdout split_s390x_r.stdout
-@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_91 = split_s390_z1 split_s390_z2 split_s390_z3 \
+@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_94 = split_s390_z1 split_s390_z2 split_s390_z3 \
@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_s390_z4 split_s390_n1 split_s390_n2 split_s390_a1 \
@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_s390_a2 split_s390_z1_ns split_s390_z2_ns split_s390_z3_ns \
@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_s390_z4_ns split_s390_n1_ns split_s390_n2_ns split_s390_r \
@@ -914,10 +917,10 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_s390x_z1_ns split_s390x_z2_ns split_s390x_z3_ns \
@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_s390x_z4_ns split_s390x_n1_ns split_s390x_n2_ns split_s390x_r
-@DEFAULT_TARGET_X86_64_TRUE@am__append_92 = *.dwo *.dwp
-@DEFAULT_TARGET_X86_64_TRUE@am__append_93 = dwp_test_1.sh \
+@DEFAULT_TARGET_X86_64_TRUE@am__append_95 = *.dwo *.dwp
+@DEFAULT_TARGET_X86_64_TRUE@am__append_96 = dwp_test_1.sh \
@DEFAULT_TARGET_X86_64_TRUE@ dwp_test_2.sh
-@DEFAULT_TARGET_X86_64_TRUE@am__append_94 = dwp_test_1.stdout \
+@DEFAULT_TARGET_X86_64_TRUE@am__append_97 = dwp_test_1.stdout \
@DEFAULT_TARGET_X86_64_TRUE@ dwp_test_2.stdout
subdir = testsuite
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
@@ -2626,7 +2629,7 @@ MOSTLYCLEANFILES = *.so *.syms *.stdout $(am__append_4) \
$(am__append_68) $(am__append_71) $(am__append_73) \
$(am__append_76) $(am__append_79) $(am__append_82) \
$(am__append_85) $(am__append_88) $(am__append_91) \
- $(am__append_92)
+ $(am__append_94) $(am__append_95)
# We will add to these later, for each individual test. Note
# that we add each test under check_SCRIPTS or check_PROGRAMS;
@@ -2636,13 +2639,15 @@ check_SCRIPTS = $(am__append_2) $(am__append_21) $(am__append_27) \
$(am__append_43) $(am__append_47) $(am__append_50) \
$(am__append_66) $(am__append_69) $(am__append_74) \
$(am__append_77) $(am__append_80) $(am__append_83) \
- $(am__append_86) $(am__append_89) $(am__append_93)
+ $(am__append_86) $(am__append_89) $(am__append_92) \
+ $(am__append_96)
check_DATA = $(am__append_3) $(am__append_22) $(am__append_28) \
$(am__append_31) $(am__append_37) $(am__append_40) \
$(am__append_44) $(am__append_48) $(am__append_51) \
$(am__append_67) $(am__append_70) $(am__append_75) \
$(am__append_78) $(am__append_81) $(am__append_84) \
- $(am__append_87) $(am__append_90) $(am__append_94)
+ $(am__append_87) $(am__append_90) $(am__append_93) \
+ $(am__append_97)
BUILT_SOURCES = $(am__append_34)
TESTS = $(check_SCRIPTS) $(check_PROGRAMS)
@@ -4711,6 +4716,8 @@ 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_thumb_arm.sh.log: arm_farcall_thumb_arm.sh
@p='arm_farcall_thumb_arm.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+aarch64_reloc_none.sh.log: aarch64_reloc_none.sh
+ @p='aarch64_reloc_none.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
split_s390.sh.log: split_s390.sh
@p='split_s390.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
dwp_test_1.sh.log: dwp_test_1.sh
@@ -7100,6 +7107,12 @@ uninstall-am:
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@arm_farcall_thumb_arm_5t.o: arm_farcall_thumb_arm.s
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_AS) -march=armv5t -o $@ $<
+@DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@aarch64_reloc_none.o: aarch64_reloc_none.s
+@DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_AS) -o $@ $<
+@DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@aarch64_reloc_none: aarch64_reloc_none.o ../ld-new
+@DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ ../ld-new -o $@ aarch64_reloc_none.o --gc-sections
+@DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@aarch64_reloc_none.stdout: aarch64_reloc_none
+@DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_NM) $< > $@
@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@split_s390_1_z1.o: split_s390_1_z1.s
@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_AS) -m31 -o $@ $<
@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@split_s390_1_z2.o: split_s390_1_z2.s
diff --git a/gold/testsuite/aarch64_reloc_none.s b/gold/testsuite/aarch64_reloc_none.s
new file mode 100644
index 00000000000..47b8a17a0b4
--- /dev/null
+++ b/gold/testsuite/aarch64_reloc_none.s
@@ -0,0 +1,16 @@
+.text
+.global _start
+.type _start, %function
+_start:
+ nop
+.reloc 0, R_AARCH64_NONE, foo
+
+.section .foo,"ax"
+.global foo
+foo:
+ nop
+
+.section .bar,"ax"
+.global bar
+bar:
+ nop
diff --git a/gold/testsuite/aarch64_reloc_none.sh b/gold/testsuite/aarch64_reloc_none.sh
new file mode 100755
index 00000000000..abf463dd765
--- /dev/null
+++ b/gold/testsuite/aarch64_reloc_none.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+# aarch64_reloc_none.sh -- test that R_AARCH64_NONE can be used
+# to prevent garbage collecting a section.
+
+# Copyright (C) 2010-2016 Free Software Foundation, Inc.
+# Written by Igor Kudrin <ikudrin@accesssoftek.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.
+
+# The goal of this test is to verify that support for the R_AARCH64_NONE
+# relocation is implemented and it can be used to inform a linker that
+# a section should be preserved during garbage collecting.
+# File aarch64_reloc_none.s describes two similar sections, .foo and .bar,
+# but .foo is referenced from .text using R_AARCH64_NONE against symbol foo.
+# When flag --gc-sections is used, .foo and its symbol foo have to be
+# preserved, whereas .bar and its symbol bar have to be discarded.
+
+check()
+{
+ file=$1
+
+ found_bar=`grep -e "\<bar\b" "$file"`
+ if test -n "$found_bar"; then
+ echo "Garbage collection failed to collect bar"
+ echo ""
+ echo "Actual output below:"
+ cat "$file"
+ exit 1
+ fi
+
+ found_foo=`grep -e "\<foo\b" "$file"`
+ if test -z "$found_foo"; then
+ echo "Garbage collection should not discard foo"
+ echo ""
+ echo "Actual output below:"
+ cat "$file"
+ exit 1
+ fi
+}
+
+check aarch64_reloc_none.stdout