Handle ARM-specific --target1-abs, --target1-rel and --target2 options

This commit is contained in:
Doug Kwan
2016-09-02 15:51:59 -07:00
parent 4aa4e28bdc
commit bc99685c73
12 changed files with 484 additions and 16 deletions
+18
View File
@@ -1,3 +1,21 @@
2016-09-02 Doug Kwan <dougkwan@google.com>
* arm.cc (Target_arm::Target_arm): Move method definition outside of
class definition. Add code to handle --target1-rel, --target1-abs
and --target2= options.
(Target_arm::get_reloc_reloc_type): Change method to be non-static
and const.
(Target_arm::target1_is_rel_, Target_arm::target2_reloc_): New data
member declaration.
(Target_arm::Scan::local, Target_arm::Scan::global,
Target_arm::Relocate::relocate,
Target_arm::Relocatable_size_for_reloc::get_size_for_reloc): Adjust
call to Target_arm::get_real_reloc_type.
(Target_arm::get_real_reloc_type): Use command line options to
determine real types of R_ARM_TARGET1 and R_ARM_TARGET2.
* options.h (--target1-rel, --target1-abs, --target2): New ARM-only
options.
2016-08-31 Alan Modra <amodra@gmail.com>
* powerpc.cc (class Stub_control): Delete stub14_group_size_
+46 -13
View File
@@ -2128,8 +2128,36 @@ class Target_arm : public Sized_target<32, big_endian>
stub_tables_(), stub_factory_(Stub_factory::get_instance()),
should_force_pic_veneer_(false),
arm_input_section_map_(), attributes_section_data_(NULL),
fix_cortex_a8_(false), cortex_a8_relocs_info_()
{ }
fix_cortex_a8_(false), cortex_a8_relocs_info_(),
target1_reloc_(elfcpp::R_ARM_ABS32),
// This can be any reloc type but usually is R_ARM_GOT_PREL.
target2_reloc_(elfcpp::R_ARM_GOT_PREL)
{
if (parameters->options().user_set_target1_rel())
{
// FIXME: This is not strictly compatible with ld, which allows both
// --target1-abs and --target-rel to be given.
if (parameters->options().user_set_target1_abs())
gold_error(_("Cannot use both --target1-abs and --target1-rel."));
else
this->target1_reloc_ = elfcpp::R_ARM_REL32;
}
// We don't need to handle --target1-abs because target1_reloc_ is set
// to elfcpp::R_ARM_ABS32 in the member initializer list.
if (parameters->options().user_set_target2())
{
const char* target2 = parameters->options().target2();
if (strcmp(target2, "rel") == 0)
this->target2_reloc_ = elfcpp::R_ARM_REL32;
else if (strcmp(target2, "abs") == 0)
this->target2_reloc_ = elfcpp::R_ARM_ABS32;
else if (strcmp(target2, "got-rel") == 0)
this->target2_reloc_ = elfcpp::R_ARM_GOT_PREL;
else
gold_unreachable();
}
}
// Whether we force PCI branch veneers.
bool
@@ -2391,8 +2419,8 @@ class Target_arm : public Sized_target<32, big_endian>
rel_irelative_section(Layout*);
// Map platform-specific reloc types
static unsigned int
get_real_reloc_type(unsigned int r_type);
unsigned int
get_real_reloc_type(unsigned int r_type) const;
//
// Methods to support stub-generations.
@@ -3002,6 +3030,11 @@ class Target_arm : public Sized_target<32, big_endian>
bool fix_cortex_a8_;
// Map addresses to relocs for Cortex-A8 erratum.
Cortex_a8_relocs_info cortex_a8_relocs_info_;
// What R_ARM_TARGET1 maps to. It can be R_ARM_REL32 or R_ARM_ABS32.
unsigned int target1_reloc_;
// What R_ARM_TARGET2 maps to. It should be one of R_ARM_REL32, R_ARM_ABS32
// and R_ARM_GOT_PREL.
unsigned int target2_reloc_;
};
template<bool big_endian>
@@ -8520,7 +8553,7 @@ Target_arm<big_endian>::Scan::local(Symbol_table* symtab,
if (is_discarded)
return;
r_type = get_real_reloc_type(r_type);
r_type = target->get_real_reloc_type(r_type);
// A local STT_GNU_IFUNC symbol may require a PLT entry.
bool is_ifunc = lsym.get_st_type() == elfcpp::STT_GNU_IFUNC;
@@ -8926,7 +8959,7 @@ Target_arm<big_endian>::Scan::global(Symbol_table* symtab,
&& this->reloc_needs_plt_for_ifunc(object, r_type))
target->make_plt_entry(symtab, layout, gsym);
r_type = get_real_reloc_type(r_type);
r_type = target->get_real_reloc_type(r_type);
switch (r_type)
{
case elfcpp::R_ARM_NONE:
@@ -9552,7 +9585,7 @@ Target_arm<big_endian>::Relocate::relocate(
const elfcpp::Rel<32, big_endian> rel(preloc);
unsigned int r_type = elfcpp::elf_r_type<32>(rel.get_r_info());
r_type = get_real_reloc_type(r_type);
r_type = target->get_real_reloc_type(r_type);
const Arm_reloc_property* reloc_property =
arm_reloc_property_table->get_implemented_static_reloc_property(r_type);
if (reloc_property == NULL)
@@ -10262,7 +10295,9 @@ Target_arm<big_endian>::Classify_reloc::get_size_for_reloc(
unsigned int r_type,
Relobj* object)
{
r_type = get_real_reloc_type(r_type);
Target_arm<big_endian>* arm_target =
Target_arm<big_endian>::default_target();
r_type = arm_target->get_real_reloc_type(r_type);
const Arm_reloc_property* arp =
arm_reloc_property_table->get_implemented_static_reloc_property(r_type);
if (arp != NULL)
@@ -10686,17 +10721,15 @@ Target_arm<big_endian>::do_dynsym_value(const Symbol* gsym) const
//
template<bool big_endian>
unsigned int
Target_arm<big_endian>::get_real_reloc_type(unsigned int r_type)
Target_arm<big_endian>::get_real_reloc_type(unsigned int r_type) const
{
switch (r_type)
{
case elfcpp::R_ARM_TARGET1:
// This is either R_ARM_ABS32 or R_ARM_REL32;
return elfcpp::R_ARM_ABS32;
return this->target1_reloc_;
case elfcpp::R_ARM_TARGET2:
// This can be any reloc type but usually is R_ARM_GOT_PREL
return elfcpp::R_ARM_GOT_PREL;
return this->target2_reloc_;
default:
return r_type;
+11
View File
@@ -1155,6 +1155,17 @@ class General_options
DEFINE_string(sysroot, options::TWO_DASHES, '\0', "",
N_("Set target system root directory"), N_("DIR"));
DEFINE_bool(target1_rel, options::TWO_DASHES, '\0', false,
N_("(ARM only) Force R_ARM_TARGET1 type to R_ARM_REL32"),
NULL);
DEFINE_bool(target1_abs, options::TWO_DASHES, '\0', false,
N_("(ARM only) Force R_ARM_TARGET1 type to R_ARM_ABS32"),
NULL);
DEFINE_enum(target2, options::TWO_DASHES, '\0', NULL,
N_("(ARM only) Set R_ARM_TARGET2 relocation type"),
N_("[rel, abs, got-rel"),
{"rel", "abs", "got-rel"});
DEFINE_bool(trace, options::TWO_DASHES, 't', false,
N_("Print the name of each input file"), NULL);
+46
View File
@@ -3604,6 +3604,52 @@ arm_farcall_thumb_arm_5t.o: arm_farcall_thumb_arm.s
MOSTLYCLEANFILES += arm_farcall_thumb_arm arm_farcall_thumb_arm_5t
# Check handling of --target1-abs, --target1-rel and --target2 options
check_SCRIPTS += arm_target1_abs.sh arm_target1_rel.sh \
arm_target2_rel.sh arm_target2_abs.sh arm_target2_got_rel.sh
check_DATA += arm_target1_abs.stdout arm_target1_rel.stdout \
arm_target2_rel.stdout arm_target2_abs.stdout arm_target2_got_rel.stdout
arm_target1_abs.stdout: arm_target1_abs
$(TEST_OBJDUMP) -s $< > $@
arm_target1_abs: arm_target1.o ../ld-new
../ld-new --target1-abs --section-start .text=0x8000 -o $@ $<
arm_target1_rel.stdout: arm_target1_rel
$(TEST_OBJDUMP) -s $< > $@
arm_target1_rel: arm_target1.o ../ld-new
../ld-new --target1-rel --section-start .text=0x8000 -o $@ $<
arm_target1.o: arm_target1.s
$(TEST_AS) -o $@ $<
arm_target2_rel.stdout: arm_target2_rel
$(TEST_OBJDUMP) -s $< > $@
arm_target2_rel: arm_target2.o ../ld-new
../ld-new --target2=rel --section-start .text=0x8000 -o $@ $<
arm_target2_abs.stdout: arm_target2_abs
$(TEST_OBJDUMP) -s $< > $@
arm_target2_abs: arm_target2.o ../ld-new
../ld-new --target2=abs --section-start .text=0x8000 -o $@ $<
arm_target2_got_rel.stdout: arm_target2_got_rel
$(TEST_OBJDUMP) -s $< > $@
arm_target2_got_rel: arm_target2.o ../ld-new
../ld-new --target2=got-rel --section-start .text=0x8000 --section-start .got=0x9000 -o $@ $<
arm_target2.o: arm_target2.s
$(TEST_AS) -o $@ $<
MOSTLYCLEANFILES += arm_target1_abs arm_target1_rel \
arm_target2_rel arm_target2_abs arm_target2_got_rel
endif DEFAULT_TARGET_ARM
if DEFAULT_TARGET_AARCH64
+66 -3
View File
@@ -807,6 +807,8 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
# Check Thumb to Thumb farcall veneers
# Check Thumb to ARM farcall veneers
# Check handling of --target1-abs, --target1-rel and --target2 options
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_91 = arm_abs_global.sh \
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_branch_in_range.sh \
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_branch_out_of_range.sh \
@@ -820,7 +822,12 @@ 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_thumb_arm.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 \
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target2_rel.sh \
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target2_abs.sh \
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target2_got_rel.sh
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_92 = arm_abs_global.stdout \
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_bl_in_range.stdout \
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_bl_out_of_range.stdout \
@@ -865,7 +872,12 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
@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_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_farcall_thumb_arm_5t.stdout \
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target1_abs.stdout \
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target1_rel.stdout \
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target2_rel.stdout \
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target2_abs.stdout \
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target2_got_rel.stdout
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_93 = arm_abs_global \
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_bl_in_range \
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_bl_out_of_range \
@@ -908,7 +920,12 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
@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_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_farcall_thumb_arm_5t \
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target1_abs \
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target1_rel \
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target2_rel \
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target2_abs \
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target2_got_rel
@DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_94 = aarch64_reloc_none.sh \
@DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ aarch64_relocs.sh
@DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_95 = aarch64_reloc_none.stdout \
@@ -5149,6 +5166,16 @@ 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)
arm_target1_abs.sh.log: arm_target1_abs.sh
@p='arm_target1_abs.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
arm_target1_rel.sh.log: arm_target1_rel.sh
@p='arm_target1_rel.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
arm_target2_rel.sh.log: arm_target2_rel.sh
@p='arm_target2_rel.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
arm_target2_abs.sh.log: arm_target2_abs.sh
@p='arm_target2_abs.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
arm_target2_got_rel.sh.log: arm_target2_got_rel.sh
@p='arm_target2_got_rel.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)
aarch64_relocs.sh.log: aarch64_relocs.sh
@@ -7586,6 +7613,42 @@ 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_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@arm_target1_abs.stdout: arm_target1_abs
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_OBJDUMP) -s $< > $@
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@arm_target1_abs: arm_target1.o ../ld-new
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ ../ld-new --target1-abs --section-start .text=0x8000 -o $@ $<
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@arm_target1_rel.stdout: arm_target1_rel
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_OBJDUMP) -s $< > $@
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@arm_target1_rel: arm_target1.o ../ld-new
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ ../ld-new --target1-rel --section-start .text=0x8000 -o $@ $<
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@arm_target1.o: arm_target1.s
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_AS) -o $@ $<
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@arm_target2_rel.stdout: arm_target2_rel
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_OBJDUMP) -s $< > $@
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@arm_target2_rel: arm_target2.o ../ld-new
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ ../ld-new --target2=rel --section-start .text=0x8000 -o $@ $<
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@arm_target2_abs.stdout: arm_target2_abs
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_OBJDUMP) -s $< > $@
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@arm_target2_abs: arm_target2.o ../ld-new
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ ../ld-new --target2=abs --section-start .text=0x8000 -o $@ $<
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@arm_target2_got_rel.stdout: arm_target2_got_rel
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_OBJDUMP) -s $< > $@
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@arm_target2_got_rel: arm_target2.o ../ld-new
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ ../ld-new --target2=got-rel --section-start .text=0x8000 --section-start .got=0x9000 -o $@ $<
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@arm_target2.o: arm_target2.s
@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_AS) -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
+7
View File
@@ -0,0 +1,7 @@
# Test the R_ARM_TARGET1 relocation
# Copied from ld/testsuite/ld-arm/arm-target1.s
.text
.global _start
_start:
.word foo(target1)
foo:
+53
View File
@@ -0,0 +1,53 @@
#!/bin/sh
# arm_target1_abs.sh -- test --target1-abs option.
# This test is based on ld/testsuite/ld-arm/arm-target1-abs.d.
# Copyright (C) 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.
check()
{
file=$1
section=$2
pattern=$3
found=`fgrep "Contents of section $section:" -A1 $file | tail -n 1`
if test -z "$found"; then
echo "Section \"$section\" not found in file $file"
echo ""
echo "Actual output below:"
cat "$file"
exit 1
fi
match_pattern=`echo "$found" | grep -e "$pattern"`
if test -z "$match_pattern"; then
echo "Expected pattern was not found in section \"$section\":"
echo " $pattern"
echo ""
echo "Actual output below:"
cat "$file"
exit 1
fi
}
# foo = 0x8004
check "arm_target1_abs.stdout" ".text" "\<8000[[:space:]]\+\(04800000\|00008004\)\b"
exit 0
+54
View File
@@ -0,0 +1,54 @@
#!/bin/sh
# arm_target1_rel.sh -- test --target1-rel option.
# This test is based on ld/testsuite/ld-arm/arm-target1-rel.d.
# Copyright (C) 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.
check()
{
file=$1
section=$2
pattern=$3
found=`fgrep "Contents of section $section:" -A1 $file | tail -n 1`
if test -z "$found"; then
echo "Section \"$section\" not found in file $file"
echo ""
echo "Actual output below:"
cat "$file"
exit 1
fi
match_pattern=`echo "$found" | grep -e "$pattern"`
if test -z "$match_pattern"; then
echo "Expected pattern was not found in section \"$section\":"
echo " $pattern"
echo ""
echo "Actual output below:"
cat "$file"
exit 1
fi
}
# foo = 0x8004
# foo - 0x8000 = 4
check "arm_target1_rel.stdout" ".text" "\<8000[[:space:]]\+\(04000000\|00000004\)\b"
exit 0
+10
View File
@@ -0,0 +1,10 @@
# Test the R_ARM_TARGET2 relocation
# Copied from ld/testsuite/ld-arm/arm-target2.s
.text
.global _start
_start:
.word foo(target2)
.word foo+0x1234(target2)
.word foo+0xcdef0000(target2)
.word foo+0x76543210(target2)
foo:
+56
View File
@@ -0,0 +1,56 @@
#!/bin/sh
# arm_target2_abs.sh -- test --target2=abs option.
# This test is based on ld/testsuite/ld-arm/arm-target2-abs.d.
# Copyright (C) 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.
check()
{
file=$1
section=$2
pattern=$3
found=`fgrep "Contents of section $section:" -A1 $file | tail -n 1`
if test -z "$found"; then
echo "Section \"$section\" not found in file $file"
echo ""
echo "Actual output below:"
cat "$file"
exit 1
fi
match_pattern=`echo "$found" | grep -e "$pattern"`
if test -z "$match_pattern"; then
echo "Expected pattern was not found in section \"$section\":"
echo " $pattern"
echo ""
echo "Actual output below:"
cat "$file"
exit 1
fi
}
# foo = 0x8010
# foo + 0x1234 = 0x9244
# foo + 0xcdef0000 = 0xcdef8010
# foo + 0x76543210 = 0x7654b220
check "arm_target2_abs.stdout" ".text" "\<8000[[:space:]]\+\(10800000\|00008010\)[[:space:]]\+\(44920000\|00009244\)[[:space:]]\+\(1080efcd\|cdef8010\)[[:space:]]\+\(20b25476\|7654b220\)\b"
exit 0
+60
View File
@@ -0,0 +1,60 @@
#!/bin/sh
# arm_target2_got_rel.sh -- test --target2=got-rel options.
# This test is based on ld/testsuite/ld-arm/arm-target2-got-rel.d.
# Copyright (C) 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.
check()
{
file=$1
section=$2
pattern=$3
found=`fgrep "Contents of section $section:" -A1 $file | tail -n 1`
if test -z "$found"; then
echo "Section \"$section\" not found in file $file"
echo ""
echo "Actual output below:"
cat "$file"
exit 1
fi
match_pattern=`echo "$found" | grep -e "$pattern"`
if test -z "$match_pattern"; then
echo "Expected pattern was not found in section \"$section\":"
echo " $pattern"
echo ""
echo "Actual output below:"
cat "$file"
exit 1
fi
}
# .got=0x9000
# .got - 0x8000 = 0x1000
# .got - 0x8004 + 0x1234 = 0x2230
# .got - 0x8008 + 0xcdef0000 = 0xcdef0ff8
# .got - 0x800c + 0x76543210 = 0x76544204
check "arm_target2_got_rel.stdout" ".text" "\<8000[[:space:]]\+\(00100000\|00001000\)[[:space:]]\+\(30220000\|00002230\)[[:space:]]\+\(f80fefcd\|cdef0ff8\)[[:space:]]\+\(04425476\|76544204\)\b"
# foo = 0x8010
check "arm_target2_got_rel.stdout" ".got" "\<9000[[:space:]]\+\(10800000\|00008010\)\b"
exit 0
+57
View File
@@ -0,0 +1,57 @@
#!/bin/sh
# arm_target2_rel.sh -- test --target2=rel option.
# This test is based on ld/testsuite/ld-arm/arm-target2-rel.d.
# Copyright (C) 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.
check()
{
file=$1
section=$2
pattern=$3
found=`fgrep "Contents of section $section:" -A1 $file | tail -n 1`
if test -z "$found"; then
echo "Section \"$section\" not found in file $file"
echo ""
echo "Actual output below:"
cat "$file"
exit 1
fi
match_pattern=`echo "$found" | grep -e "$pattern"`
if test -z "$match_pattern"; then
echo "Expected pattern was not found in section \"$section\":"
echo " $pattern"
echo ""
echo "Actual output below:"
cat "$file"
exit 1
fi
}
# foo = 0x8010
# foo - 0x8000 = 0x10
# foo - 0x8004 + 0x1234 = 0x1240
# foo - 0x8008 + 0xcdef0000 = 0xcdef0008
# foo - 0x800c + 0x76543210 = 0x76543214
check "arm_target2_rel.stdout" ".text" "\<8000[[:space:]]\+\(10000000\|00000010\)[[:space:]]\+\(40120000\|00001240\)[[:space:]]\+\(0800efcd\|cdef0008\)[[:space:]]\+\(14325476\|76543214\)\b"
exit 0