aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
Diffstat (limited to 'ld')
-rw-r--r--ld/testsuite/ChangeLog17
-rw-r--r--ld/testsuite/ld-mips-elf/jalx-1.d16
-rw-r--r--ld/testsuite/ld-mips-elf/jalx-1.ld8
-rw-r--r--ld/testsuite/ld-mips-elf/jalx-1.s15
-rw-r--r--ld/testsuite/ld-mips-elf/jalx-2-ex.s34
-rw-r--r--ld/testsuite/ld-mips-elf/jalx-2-main.s74
-rw-r--r--ld/testsuite/ld-mips-elf/jalx-2-printf.s35
-rw-r--r--ld/testsuite/ld-mips-elf/jalx-2.dd58
-rw-r--r--ld/testsuite/ld-mips-elf/jalx-2.ld8
-rw-r--r--ld/testsuite/ld-mips-elf/mips-elf.exp28
-rw-r--r--ld/testsuite/ld-mips-elf/mips16-and-micromips.d5
-rw-r--r--ld/testsuite/lib/ld-lib.exp13
12 files changed, 304 insertions, 7 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 28b9a83..e42e167 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,20 @@
+2011-07-24 Catherine Moore <clm@codesourcery.com>
+ Chao-ying Fu <fu@mips.com>
+ Maciej W. Rozycki <macro@codesourcery.com>
+
+ * lib/ld-lib.exp (run_dump_test): Support distinct assembler
+ flags for the same source named multiple times.
+ * ld-mips-elf/jalx-1.s: New test source.
+ * ld-mips-elf/jalx-1.d: New test output.
+ * ld-mips-elf/jalx-1.ld: New test linker script.
+ * ld-mips-elf/jalx-2-main.s: New test source.
+ * ld-mips-elf/jalx-2-ex.s: Likewise.
+ * ld-mips-elf/jalx-2-printf.s: Likewise.
+ * ld-mips-elf/jalx-2.dd: New test output.
+ * ld-mips-elf/jalx-2.ld: New test linker script.
+ * ld-mips-elf/mips16-and-micromips.d: New test.
+ * ld-mips-elf/mips-elf.exp: Run the new tests
+
2011-07-22 H.J. Lu <hongjiu.lu@intel.com>
* ld-x86-64/abs-k1om.d: New.
diff --git a/ld/testsuite/ld-mips-elf/jalx-1.d b/ld/testsuite/ld-mips-elf/jalx-1.d
new file mode 100644
index 0000000..f082628
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/jalx-1.d
@@ -0,0 +1,16 @@
+#name: MIPS jalx-1
+#source: jalx-1.s
+#ld: -T jalx-1.ld
+#objdump: -d
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+
+88000000 <test>:
+88000000: f200 0002 jalx 88000008 <test1>
+88000004: 0000 0000 nop
+
+88000008 <test1>:
+88000008: 00851821 addu v1,a0,a1
+ \.\.\.
diff --git a/ld/testsuite/ld-mips-elf/jalx-1.ld b/ld/testsuite/ld-mips-elf/jalx-1.ld
new file mode 100644
index 0000000..3ee8e31
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/jalx-1.ld
@@ -0,0 +1,8 @@
+ENTRY (test)
+_start_text_phys = 0x88000000;
+_start_text = _start_text_phys;
+
+SECTIONS
+{
+ .text _start_text : AT (ADDR (.text)) { *(.text) }
+}
diff --git a/ld/testsuite/ld-mips-elf/jalx-1.s b/ld/testsuite/ld-mips-elf/jalx-1.s
new file mode 100644
index 0000000..96bf01b
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/jalx-1.s
@@ -0,0 +1,15 @@
+ .set noreorder
+ .set micromips
+ .ent test
+ .globl test
+test:
+ jalx test1
+ nop
+
+ .set nomicromips
+test1:
+ addu $3, $4, $5
+ .end test
+
+# Force at least 8 (non-delay-slot) zero bytes, to make 'objdump' print ...
+ .space 8
diff --git a/ld/testsuite/ld-mips-elf/jalx-2-ex.s b/ld/testsuite/ld-mips-elf/jalx-2-ex.s
new file mode 100644
index 0000000..f42925c
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/jalx-2-ex.s
@@ -0,0 +1,34 @@
+ .file 1 "jalx-2-ex.c"
+ .section .mdebug.abi32
+ .previous
+ .gnu_attribute 4, 1
+ .abicalls
+ .option pic0
+ .text
+ .align 2
+ .globl external_function
+ .set nomips16
+ .set nomicromips
+ .ent external_function
+ .type external_function, @function
+external_function:
+ .frame $fp,8,$31 # vars= 0, regs= 1/0, args= 0, gp= 0
+ .mask 0x40000000,-4
+ .fmask 0x00000000,0
+ .set noreorder
+ .set nomacro
+
+ addiu $sp,$sp,-8
+ sw $fp,4($sp)
+ move $fp,$sp
+ move $sp,$fp
+ lw $fp,4($sp)
+ addiu $sp,$sp,8
+ j $31
+ nop
+
+ .set macro
+ .set reorder
+ .end external_function
+ .size external_function, .-external_function
+ .ident "GCC: (Sourcery G++ Lite 4.4-999999 - Preview) 4.4.1"
diff --git a/ld/testsuite/ld-mips-elf/jalx-2-main.s b/ld/testsuite/ld-mips-elf/jalx-2-main.s
new file mode 100644
index 0000000..86e365f
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/jalx-2-main.s
@@ -0,0 +1,74 @@
+ .file 1 "jalx-2-main.c"
+ .section .mdebug.abi32
+ .previous
+ .gnu_attribute 4, 1
+ .abicalls
+ .option pic0
+ .text
+ .align 2
+ .globl internal_function
+ .set nomips16
+ .set micromips
+ .ent internal_function
+ .type internal_function, @function
+internal_function:
+ .frame $fp,8,$31 # vars= 0, regs= 1/0, args= 0, gp= 0
+ .mask 0x40000000,-4
+ .fmask 0x00000000,0
+ .set noreorder
+ .set nomacro
+
+ addiu $sp,$sp,-8
+ sw $fp,4($sp)
+ move $fp,$sp
+ move $sp,$fp
+ lw $fp,4($sp)
+ jraddiusp 8
+ .set macro
+ .set reorder
+ .end internal_function
+ .size internal_function, .-internal_function
+ .rdata
+ .align 2
+$LC0:
+ .ascii "hello world\012\000"
+ .text
+ .align 2
+ .globl main
+ .set nomips16
+ .set micromips
+ .ent main
+ .type main, @function
+main:
+ .frame $fp,32,$31 # vars= 0, regs= 2/0, args= 16, gp= 8
+ .mask 0xc0000000,-4
+ .fmask 0x00000000,0
+ .set noreorder
+ .set nomacro
+
+ addiu $sp,$sp,-32
+ sw $31,28($sp)
+ sw $fp,24($sp)
+ move $fp,$sp
+ sw $4,32($fp)
+ sw $5,36($fp)
+ lui $2,%hi($LC0)
+ addiu $4,$2,%lo($LC0)
+ jal printf
+ nop
+
+ jal internal_function
+ nop
+
+ jal external_function
+ nop
+
+ move $sp,$fp
+ lw $31,28($sp)
+ lw $fp,24($sp)
+ jraddiusp 32
+ .set macro
+ .set reorder
+ .end main
+ .size main, .-main
+ .ident "GCC: (Sourcery G++ Lite 4.4-999999 - Preview) 4.4.1"
diff --git a/ld/testsuite/ld-mips-elf/jalx-2-printf.s b/ld/testsuite/ld-mips-elf/jalx-2-printf.s
new file mode 100644
index 0000000..5ba2566
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/jalx-2-printf.s
@@ -0,0 +1,35 @@
+ .file 1 "jalx-2-printf.c"
+ .section .mdebug.abi32
+ .previous
+ .gnu_attribute 4, 1
+ .abicalls
+ .text
+ .align 2
+ .globl printf
+ .set nomips16
+ .set micromips
+ .ent printf
+ .type printf, @function
+printf:
+ .frame $fp,8,$31 # vars= 0, regs= 1/0, args= 0, gp= 0
+ .mask 0x40000000,-4
+ .fmask 0x00000000,0
+ .set noreorder
+ .set nomacro
+
+ addiu $sp,$sp,-8
+ sw $fp,4($sp)
+ move $fp,$sp
+ sw $5,12($fp)
+ sw $6,16($fp)
+ sw $7,20($fp)
+ sw $4,8($fp)
+ move $2,$0
+ move $sp,$fp
+ lw $fp,4($sp)
+ jraddiusp 8
+ .set macro
+ .set reorder
+ .end printf
+ .size printf, .-printf
+ .ident "GCC: (Sourcery G++ Lite 4.4-999999 - Preview) 4.4.1"
diff --git a/ld/testsuite/ld-mips-elf/jalx-2.dd b/ld/testsuite/ld-mips-elf/jalx-2.dd
new file mode 100644
index 0000000..c08d954
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/jalx-2.dd
@@ -0,0 +1,58 @@
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+
+04400000 <external_function>:
+ 4400000: 27bdfff8 addiu sp,sp,-8
+ 4400004: afbe0004 sw s8,4\(sp\)
+ 4400008: 03a0f021 move s8,sp
+ 440000c: 03c0e821 move sp,s8
+ 4400010: 8fbe0004 lw s8,4\(sp\)
+ 4400014: 27bd0008 addiu sp,sp,8
+ 4400018: 03e00008 jr ra
+ 440001c: 00000000 nop
+
+04400020 <internal_function>:
+ 4400020: 4fb0 addiu sp,sp,-8
+ 4400022: cbc1 sw s8,4\(sp\)
+ 4400024: 0fdd move s8,sp
+ 4400026: 0fbe move sp,s8
+ 4400028: 4bc1 lw s8,4\(sp\)
+ 440002a: 4702 jraddiusp 8
+
+0440002c <main>:
+ 440002c: 4ff1 addiu sp,sp,-32
+ 440002e: cbe7 sw ra,28\(sp\)
+ 4400030: cbc6 sw s8,24\(sp\)
+ 4400032: 0fdd move s8,sp
+ 4400034: f89e 0020 sw a0,32\(s8\)
+ 4400038: f8be 0024 sw a1,36\(s8\)
+ 440003c: 41a2 0440 lui v0,0x440
+ 4400040: 3082 02a0 addiu a0,v0,672
+ 4400044: f110 0028 jalx 44000a0 <_PROCEDURE_LINKAGE_TABLE_\+0x20>
+ 4400048: 0000 0000 nop
+ 440004c: f620 0010 jal 4400020 <internal_function>
+ 4400050: 0000 0000 nop
+ 4400054: f110 0000 jalx 4400000 <external_function>
+ 4400058: 0000 0000 nop
+ 440005c: 0fbe move sp,s8
+ 440005e: 4be7 lw ra,28\(sp\)
+ 4400060: 4bc6 lw s8,24\(sp\)
+ 4400062: 4708 jraddiusp 32
+ \.\.\.
+
+Disassembly of section \.plt:
+
+04400080 <_PROCEDURE_LINKAGE_TABLE_>:
+ 4400080: 3c1c0440 lui gp,0x440
+ 4400084: 8f9900d8 lw t9,216\(gp\)
+ 4400088: 279c00d8 addiu gp,gp,216
+ 440008c: 031cc023 subu t8,t8,gp
+ 4400090: 03e07821 move t7,ra
+ 4400094: 0018c082 srl t8,t8,0x2
+ 4400098: 0320f809 jalr t9
+ 440009c: 2718fffe addiu t8,t8,-2
+ 44000a0: 3c0f0440 lui t7,0x440
+ 44000a4: 8df900e0 lw t9,224\(t7\)
+ 44000a8: 03200008 jr t9
+ 44000ac: 25f800e0 addiu t8,t7,224
diff --git a/ld/testsuite/ld-mips-elf/jalx-2.ld b/ld/testsuite/ld-mips-elf/jalx-2.ld
new file mode 100644
index 0000000..1c5562b
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/jalx-2.ld
@@ -0,0 +1,8 @@
+ENTRY (internal_function)
+_start_text_phys = 0x4400000;
+_start_text = _start_text_phys;
+
+SECTIONS
+{
+ .text _start_text : AT (ADDR (.text)) { *(.text) }
+}
diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp
index 372f454..ce448cf 100644
--- a/ld/testsuite/ld-mips-elf/mips-elf.exp
+++ b/ld/testsuite/ld-mips-elf/mips-elf.exp
@@ -123,6 +123,31 @@ run_dump_test "mips16-1"
# MIPS branch offset final link checking.
run_dump_test "branch-misc-1"
+# Jalx test
+run_dump_test "jalx-1"
+
+if { $linux_gnu } {
+ run_ld_link_tests [list \
+ [list "Dummy shared library for JALX test 2" \
+ "-shared -nostdlib -melf32btsmip" \
+ "-G0 -EB -mmicromips -no-mdebug -mabi=32 -march=mips32r2 -KPIC" \
+ { jalx-2-printf.s } \
+ {} \
+ "libjalx-2.so"] \
+ [list "Dummy external function for JALX test 2" \
+ "-r -melf32btsmip" \
+ "-G0 -EB -no-mdebug -mabi=32 -march=mips32r2 -mno-shared -call_nonpic" \
+ { jalx-2-ex.s } \
+ {} \
+ "jalx-2-ex.o.r"] \
+ [list "MIPS JALX test 2" \
+ "-nostdlib -T jalx-2.ld tmpdir/libjalx-2.so tmpdir/jalx-2-ex.o.r -melf32btsmip" \
+ "-G0 -EB -mmicromips -no-mdebug -mabi=32 -march=mips32r2 -mno-shared -call_nonpic" \
+ { jalx-2-main.s } \
+ { { objdump -d jalx-2.dd } } \
+ "jalx-2"]]
+}
+
# Test multi-got link. We only do this on GNU/Linux because it requires
# the "traditional" emulations.
if { $linux_gnu } {
@@ -549,3 +574,6 @@ if { $linux_gnu } {
run_dump_test "jr-to-b-1"
run_dump_test "jr-to-b-2"
}
+
+# MIPS16 and microMIPS interlinking test.
+run_dump_test "mips16-and-micromips"
diff --git a/ld/testsuite/ld-mips-elf/mips16-and-micromips.d b/ld/testsuite/ld-mips-elf/mips16-and-micromips.d
new file mode 100644
index 0000000..6d740fe
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/mips16-and-micromips.d
@@ -0,0 +1,5 @@
+#name: MIPS16 and microMIPS interlink
+#source: ../../../gas/testsuite/gas/mips/nop.s -mips16
+#source: ../../../gas/testsuite/gas/mips/nop.s -mmicromips
+#ld: -e0
+#error: \A.*: .*\.o: ASE mismatch: linking microMIPS module with previous MIPS16 modules[\n\r]+.*: failed to merge target specific data of file .*\.o\Z
diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
index 2020372..3e77a5a 100644
--- a/ld/testsuite/lib/ld-lib.exp
+++ b/ld/testsuite/lib/ld-lib.exp
@@ -552,7 +552,6 @@ proc run_dump_test { name } {
set opts(error) {}
set opts(warning) {}
set opts(objcopy_linked_file) {}
- set asflags(${file}.s) {}
foreach i $opt_array {
set opt_name [lindex $i 0]
@@ -570,13 +569,13 @@ proc run_dump_test { name } {
warning {}
error {}
source {
- # Move any source-specific as-flags to a separate array to
+ # Move any source-specific as-flags to a separate list to
# simplify processing.
if { [llength $opt_val] > 1 } {
- set asflags([lindex $opt_val 0]) [lrange $opt_val 1 end]
+ lappend asflags [lrange $opt_val 1 end]
set opt_val [lindex $opt_val 0]
} else {
- set asflags($opt_val) {}
+ lappend asflags {}
}
}
default {
@@ -669,6 +668,7 @@ proc run_dump_test { name } {
if { $opts(source) == "" } {
set sourcefiles [list ${file}.s]
+ set asflags [list ""]
} else {
set sourcefiles {}
foreach sf $opts(source) {
@@ -677,8 +677,6 @@ proc run_dump_test { name } {
} else {
lappend sourcefiles "$srcdir/$subdir/$sf"
}
- # Must have asflags indexed on source name.
- set asflags($srcdir/$subdir/$sf) $asflags($sf)
}
}
@@ -691,11 +689,12 @@ proc run_dump_test { name } {
set objfiles {}
for { set i 0 } { $i < [llength $sourcefiles] } { incr i } {
set sourcefile [lindex $sourcefiles $i]
+ set sourceasflags [lindex $asflags $i]
set objfile "tmpdir/dump$i.o"
catch "exec rm -f $objfile" exec_output
lappend objfiles $objfile
- set cmd "$AS $ASFLAGS $opts(as) $asflags($sourcefile) -o $objfile $sourcefile"
+ set cmd "$AS $ASFLAGS $opts(as) $sourceasflags -o $objfile $sourcefile"
send_log "$cmd\n"
set cmdret [remote_exec host [concat sh -c [list "$cmd 2>&1"]] "" "/dev/null" "ld.tmp"]