Skip to content

Commit cbf54cf

Browse files
motokultivatorDjordje Todorovic
authored andcommitted
Add testcase for --relax-balc-trampolines
1 parent cb92962 commit cbf54cf

File tree

4 files changed

+120
-3
lines changed

4 files changed

+120
-3
lines changed

gold/testsuite/Makefile.am

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4875,6 +4875,22 @@ nanomips_emit_relocs.o: nanomips_emit_relocs.s
48754875

48764876
MOSTLYCLEANFILES += nanomips_emit_relocs
48774877

4878+
# Test that the balc instructions are relaxed to their 16-bit variants.
4879+
4880+
check_SCRIPTS += nanomips_balc_relax.sh
4881+
check_DATA += nanomips_balc_relax.stdout
4882+
4883+
nanomips_balc_relax.stdout: nanomips_balc_relax
4884+
$(TEST_OBJDUMP) -d $< > $@
4885+
4886+
nanomips_balc_relax: nanomips_balc_relax.o ../ld-new
4887+
../ld-new nanomips_balc_relax.o --relax -o $@
4888+
4889+
nanomips_balc_relax.o: nanomips_balc_relax.s
4890+
$(TEST_AS) -EL -march=32r6 -m32 -o $@ $<
4891+
4892+
MOSTLYCLEANFILES += nanomips_balc_relax
4893+
48784894
endif DEFAULT_TARGET_NANOMIPS
48794895

48804896
endif NATIVE_OR_CROSS_LINKER

gold/testsuite/Makefile.in

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,8 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
11241124
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ nanomips_wrap.sh \
11251125
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ nanomips_saverestore_relax.sh \
11261126
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ nanomips_bxxzc32_relax.sh \
1127-
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ nanomips_emit_relocs.sh
1127+
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ nanomips_emit_relocs.sh \
1128+
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ nanomips_balc_relax.sh
11281129
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_107 = nanomips_b_out_of_range_pcrel.stdout \
11291130
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ nanomips_b_out_of_range_insn32_pcrel.stdout \
11301131
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ nanomips_b_out_of_range_nmf_pcrel.stdout \
@@ -1182,7 +1183,8 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
11821183
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ nanomips_wrap.stdout \
11831184
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ nanomips_saverestore_relax.stdout \
11841185
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ nanomips_bxxzc32_relax.stdout \
1185-
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ nanomips_emit_relocs.stdout
1186+
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ nanomips_emit_relocs.stdout \
1187+
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ nanomips_balc_relax.stdout
11861188
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_108 = nanomips_b_out_of_range_pcrel \
11871189
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ nanomips_b_out_of_range_insn32_pcrel \
11881190
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ nanomips_b_out_of_range_nmf_pcrel \
@@ -1234,7 +1236,8 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
12341236
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ nanomips_wrap \
12351237
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ nanomips_saverestore_relax \
12361238
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ nanomips_bxxzc32_relax \
1237-
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ nanomips_emit_relocs
1239+
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ nanomips_emit_relocs \
1240+
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ nanomips_balc_relax
12381241
@DEFAULT_TARGET_X86_64_TRUE@am__append_109 = *.dwo *.dwp
12391242
@DEFAULT_TARGET_X86_64_TRUE@am__append_110 = dwp_test_1.sh \
12401243
@DEFAULT_TARGET_X86_64_TRUE@ dwp_test_2.sh
@@ -5668,6 +5671,8 @@ nanomips_bxxzc32_relax.sh.log: nanomips_bxxzc32_relax.sh
56685671
@p='nanomips_bxxzc32_relax.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
56695672
nanomips_emit_relocs.sh.log: nanomips_emit_relocs.sh
56705673
@p='nanomips_emit_relocs.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
5674+
nanomips_balc_relax.sh.log: nanomips_balc_relax.sh
5675+
@p='nanomips_balc_relax.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
56715676
dwp_test_1.sh.log: dwp_test_1.sh
56725677
@p='dwp_test_1.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
56735678
dwp_test_2.sh.log: dwp_test_2.sh
@@ -9028,6 +9033,15 @@ uninstall-am:
90289033
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@nanomips_emit_relocs.o: nanomips_emit_relocs.s
90299034
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_AS) -EL -march=32r6 -m32 -o $@ $<
90309035

9036+
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@nanomips_balc_relax.stdout: nanomips_balc_relax
9037+
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_OBJDUMP) -d $< > $@
9038+
9039+
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@nanomips_balc_relax: nanomips_balc_relax.o ../ld-new
9040+
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ ../ld-new nanomips_balc_relax.o --relax -o $@
9041+
9042+
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@nanomips_balc_relax.o: nanomips_balc_relax.s
9043+
@DEFAULT_TARGET_NANOMIPS_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_AS) -EL -march=32r6 -m32 -o $@ $<
9044+
90319045
# Tests for the dwp tool.
90329046
# We don't want to rely yet on GCC support for -gsplit-dwarf,
90339047
# so we use (for now) test cases in x86 assembly language,
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.linkrelax
2+
.module pcrel
3+
.section .text.startup,"ax",@progbits
4+
.align 1
5+
6+
.globl test
7+
.ent test
8+
test:
9+
balc subroutine
10+
balc subroutine
11+
balc subroutine
12+
balc subroutine
13+
balc subroutine
14+
balc subroutine
15+
.rept 250
16+
nop[32]
17+
.endr
18+
balc subroutine
19+
balc subroutine
20+
balc subroutine
21+
balc subroutine
22+
balc subroutine
23+
balc subroutine
24+
.rept 512
25+
nop[32]
26+
.endr
27+
jrc $ra
28+
.end test
29+
.size test, .-test
30+
31+
.globl subroutine
32+
.ent subroutine
33+
subroutine:
34+
nop
35+
jrc $ra
36+
.end subroutine
37+
.size subroutine, .-subroutine
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/sh
2+
3+
# nanomips_balc_relax.sh - Test that the 32-bit balc
4+
# instructions are relaxed to their 16-bit variants.
5+
6+
# Copyright (C) 2023 Free Software Foundation, Inc.
7+
# Written by Aleksandar Rikalo <[email protected]>.
8+
9+
# This file is part of gold.
10+
11+
# This program is free software; you can redistribute it and/or modify
12+
# it under the terms of the GNU General Public License as published by
13+
# the Free Software Foundation; either version 3 of the License, or
14+
# (at your option) any later version.
15+
16+
# This program is distributed in the hope that it will be useful,
17+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
# GNU General Public License for more details.
20+
21+
# You should have received a copy of the GNU General Public License
22+
# along with this program; if not, write to the Free Software
23+
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
24+
# MA 02110-1301, USA.
25+
26+
check()
27+
{
28+
file=$1
29+
pattern=$2
30+
31+
found=`grep "$pattern" $file`
32+
if test -z "$found"; then
33+
echo "pattern \"$pattern\" not found in file $file."
34+
exit 1
35+
fi
36+
}
37+
38+
check nanomips_balc_relax.stdout "380c "
39+
check nanomips_balc_relax.stdout "380a "
40+
check nanomips_balc_relax.stdout "3808 "
41+
check nanomips_balc_relax.stdout "3806 "
42+
check nanomips_balc_relax.stdout "3804 "
43+
check nanomips_balc_relax.stdout "3802 "
44+
check nanomips_balc_relax.stdout "1804 "
45+
check nanomips_balc_relax.stdout "3813 "
46+
check nanomips_balc_relax.stdout "3811 "
47+
check nanomips_balc_relax.stdout "380f "
48+
check nanomips_balc_relax.stdout "380d "
49+
check nanomips_balc_relax.stdout "380b "
50+
check nanomips_balc_relax.stdout "3809 "

0 commit comments

Comments
 (0)