Closed xiangzhai closed 6 years ago
I will run regression testcase, and at present it works well for very simple testcase:
#!/bin/bash
rm -f *.o
LLVM_BUILD=/data/project/xiangzhai/llvm/build
GCC=/opt/mips64el-gcc-8.1.0/bin/mips64el-redhat-linux-gcc
OBJDUMP=/opt/mips64el-gcc-8.1.0/bin/mips64el-redhat-linux-objdump
$LLVM_BUILD/bin/llvm-mc valid.s -triple=mips64el-redhat-linux -show-encoding -show-inst -mcpu=loongson3a
$GCC -c valid.s -o valid-gnu.o
$OBJDUMP -d valid-gnu.o
.text
gs:
.set noat
gslble $2, $3, $4 # encoding: [0x10,0x20,0x62,0xc8]
# <MCInst #1546 GSLBLE
# <MCOperand Reg:321>
# <MCOperand Reg:322>
# <MCOperand Reg:22>>
gslbgt $5, $6, $7 # encoding: [0x11,0x38,0xc5,0xc8]
# <MCInst #1545 GSLBGT
# <MCOperand Reg:23>
# <MCOperand Reg:24>
# <MCOperand Reg:25>>
gslhle $8, $9, $10 # encoding: [0x12,0x50,0x28,0xc9]
# <MCInst #1552 GSLHLE
# <MCOperand Reg:311>
# <MCOperand Reg:312>
# <MCOperand Reg:313>>
gslhgt $11, $12, $13 # encoding: [0x13,0x68,0x8b,0xc9]
# <MCInst #1551 GSLHGT
# <MCOperand Reg:314>
# <MCOperand Reg:315>
# <MCOperand Reg:316>>
gslwle $14, $15, $16 # encoding: [0x14,0x80,0xee,0xc9]
# <MCInst #1556 GSLWLE
# <MCOperand Reg:317>
# <MCOperand Reg:318>
# <MCOperand Reg:302>>
gslwgt $17, $18, $19 # encoding: [0x15,0x98,0x51,0xca]
# <MCInst #1554 GSLWGT
# <MCOperand Reg:303>
# <MCOperand Reg:304>
# <MCOperand Reg:305>>
gsldle $20, $21, $22 # encoding: [0x16,0xb0,0xb4,0xca]
# <MCInst #1549 GSLDLE
# <MCOperand Reg:402>
# <MCOperand Reg:403>
# <MCOperand Reg:404>>
gsldgt $23, $24, $25 # encoding: [0x17,0xc8,0x17,0xcb]
# <MCInst #1547 GSLDGT
# <MCOperand Reg:405>
# <MCOperand Reg:414>
# <MCOperand Reg:415>>
gslwlec1 $f0, $2, $3 # encoding: [0x1c,0x18,0x40,0xc8]
# <MCInst #1557 GSLWLEC1
# <MCOperand Reg:147>
# <MCOperand Reg:321>
# <MCOperand Reg:322>>
gslwgtc1 $f1, $4, $5 # encoding: [0x1d,0x28,0x81,0xc8]
# <MCInst #1555 GSLWGTC1
# <MCOperand Reg:148>
# <MCOperand Reg:22>
# <MCOperand Reg:23>>
gsldlec1 $f2, $6, $7 # encoding: [0x1e,0x38,0xc2,0xc8]
# <MCInst #1550 GSLDLEC1
# <MCOperand Reg:363>
# <MCOperand Reg:358>
# <MCOperand Reg:359>>
gsldgtc1 $f3, $8, $9 # encoding: [0x1f,0x48,0x03,0xc9]
# <MCInst #1548 GSLDGTC1
# <MCOperand Reg:364>
# <MCOperand Reg:406>
# <MCOperand Reg:407>>
gslq $10, $11, 4080($12) # encoding: [0xe0,0x02,0x4b,0xc9]
# <MCInst #1553 GSLQ
# <MCOperand Reg:408>
# <MCOperand Reg:409>
# <MCOperand Reg:410>
# <MCOperand Imm:4080>>
----- 8< -------- 8< -------- 8< -------- 8< -------- 8< -------- 8< ---
valid-gnu.o: file format elf64-tradlittlemips
Disassembly of section .text:
0000000000000000 <gs>:
0: c8622010 gslble v0,v1,a0
4: c8c53811 gslbgt a1,a2,a3
8: c9285012 gslhle a4,a5,a6
c: 00000000 nop
10: c98b6813 gslhgt a7,t0,t1
14: c9ee8014 gslwle t2,t3,s0
18: ca519815 gslwgt s1,s2,s3
1c: 00000000 nop
20: cab4b016 gsldle s4,s5,s6
24: cb17c817 gsldgt s7,t8,t9
28: c8401818 gslwlec1 $f0,v0,v1
2c: 00000000 nop
30: c8812819 gslwgtc1 $f1,a0,a1
34: c8c2381a gsldlec1 $f2,a2,a3
38: c903481b gsldgtc1 $f3,a4,a5
3c: 00000000 nop
40: c98b3fea gslq a6,a7,4080(t0)
...
Allmost all the testsuit of gas about MIPS faild on mips64el native build... Is it matter?
I've upload test logs to my own server since logs are too big that crashed the gist.
https://repo.flygoat.com/loongson/tmp/binutils-log/
Please have a check. Thanks.
Please drop the V1 patch and apply V2 patch.
Almost all the testsuit of gas about MIPS faild on mips64el native build...
I am learning how to use dejagnu for cross compiler, please teach me if experienced :)
Faild to apply patchv2 What should be the code base?
+ echo 'Patch #58 (0008-Backport-refactory-loongson-march-and-LoongISA-to-binutils-2.30.patch):'
Patch #58 (0008-Backport-refactory-loongson-march-and-LoongISA-to-binutils-2.30.patch):
+ /usr/bin/patch --no-backup-if-mismatch -p1 --fuzz=0
patching file bfd/archures.c
patching file bfd/bfd-in2.h
Hunk #1 succeeded at 2055 (offset 1 line).
patching file bfd/cpu-mips.c
patching file bfd/elfxx-mips.c
patching file binutils/MAINTAINERS
patching file binutils/readelf.c
Hunk #2 succeeded at 15480 (offset 23 lines).
Hunk #3 succeeded at 15514 (offset 23 lines).
patching file elfcpp/mips.h
patching file gas/config/tc-mips.c
patching file gas/doc/c-mips.texi
patching file gas/testsuite/gas/mips/loongson-2f-mmi.d
patching file gas/testsuite/gas/mips/loongson-2f-mmi.s
patching file gas/testsuite/gas/mips/loongson-2f.d
patching file gas/testsuite/gas/mips/loongson-2f.s
patching file gas/testsuite/gas/mips/loongson-3a-2.d
patching file gas/testsuite/gas/mips/loongson-3a-2.s
Hunk #1 FAILED at 1 (different line endings).
1 out of 1 hunk FAILED -- saving rejects to file gas/testsuite/gas/mips/loongson-3a-2.s.rej
patching file gas/testsuite/gas/mips/loongson-3a-mmi.d
patching file gas/testsuite/gas/mips/loongson-3a-mmi.s
patching file gas/testsuite/gas/mips/loongson-3a.d
Hunk #1 FAILED at 22 (different line endings).
1 out of 1 hunk FAILED -- saving rejects to file gas/testsuite/gas/mips/loongson-3a.d.rej
patching file gas/testsuite/gas/mips/loongson-3a.s
Hunk #1 FAILED at 18 (different line endings).
1 out of 1 hunk FAILED -- saving rejects to file gas/testsuite/gas/mips/loongson-3a.s.rej
patching file gas/testsuite/gas/mips/loongson-cam.d
patching file gas/testsuite/gas/mips/loongson-cam.s
patching file gas/testsuite/gas/mips/loongson-ext2.d
patching file gas/testsuite/gas/mips/loongson-ext2.s
patching file gas/testsuite/gas/mips/mips.exp
patching file gold/mips.cc
patching file include/elf/mips.h
patching file include/opcode/mips.h
patching file ld/testsuite/ld-mips-elf/mips-elf-flags.exp
patching file opcodes/mips-dis.c
patching file opcodes/mips-opc.c
Made an ugly workaround to pass the tests. https://github.com/FlyGoat/loongson-binutils-gdb/commit/c53644648d8e657e3e911f243fe5314f7192bd0d
Please help me find a better method to implement it. Thanks.
Please help me find a better method to implement it.
What about? https://gist.github.com/xiangzhai/8af6034c0a456b0f7727ddf96c6ff703
Something wrong with gold, I'm going to research on it later.
========================================
gold 0.1: testsuite/test-suite.log
========================================
# TOTAL: 5
# PASS: 4
# SKIP: 0
# XFAIL: 0
# FAIL: 1
# XPASS: 0
# ERROR: 0
.. contents:: :depth: 2
FAIL: script_test_10.sh
=======================
Did not find expected section in script_test_10.stdout:
.*\[ 2\] .sec0
Actual output below:
There are 17 section headers, starting at offset 0x1010c:
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .text PROGBITS 00000000 010000 000000 00 AX 0 0 16
[ 2] .MIPS.abiflags MIPS_ABIFLAGS 00000000 010000 000018 00 A 0 0 8
[ 3] .reginfo MIPS_REGINFO 00000018 010018 000018 00 A 0 0 4
[ 4] .sec0 PROGBITS 00000030 010030 000004 00 A 0 0 4
[ 5] .sec1 PROGBITS 00000034 010034 000004 00 A 0 0 4
[ 6] .sec2 PROGBITS 00000038 010038 000004 00 A 0 0 4
[ 7] .secz PROGBITS 0000003c 01003c 000000 00 A 0 0 1
[ 8] .sec3 PROGBITS 0000003c 01003c 000004 00 A 0 0 4
[ 9] .data PROGBITS 00000040 010040 000000 00 WA 0 0 16
[10] .bss NOBITS 00000040 010040 000000 00 WA 0 0 16
[11] .pdr PROGBITS 00000000 010040 000000 00 0 0 4
[12] .note.gnu.gold-version NOTE 00000000 010040 00001c 00 0 0 4
[13] .gnu.attributes GNU_ATTRIBUTES 00000000 01005c 000010 00 0 0 1
[14] .symtab SYMTAB 00000000 01006c 000010 10 15 1 4
[15] .strtab STRTAB 00000000 01007c 000001 00 0 0 1
[16] .shstrtab STRTAB 00000000 01007d 00008e 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
L (link order), O (extra OS processing required), G (group), T (TLS),
C (compressed), x (unknown), o (OS specific), E (exclude),
p (processor specific)
FAIL script_test_10.sh (exit status: 1)
FAIL: script_test_10.sh
Is it able to reproduce the issue with the script for LD?
Is it able to reproduce the issue with the script for LD?
That's a gold specific test. And personally, I think it's caused by ABI difference of MIPS. MIPS needs the .abiflags and .reginfo section just after .text in order to recognize the elf while other platforms will do it in other sections. We should not blame on gold. It seemed like upstream had not run these tests on MIPS platform.
What about LLD :) http://lld.llvm.org/#performance
Tried on ld.bfd The result:
There are 11 section headers, starting at offset 0x284:
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .MIPS.abiflags MIPS_ABIFLAGS 10000098 000098 000018 18 A 0 0 8
[ 2] .reginfo MIPS_REGINFO 100000b0 0000b0 000018 18 A 0 0 8
[ 3] .sec0 PROGBITS 100000d0 0000d0 000004 00 A 0 0 4
[ 4] .sec2 PROGBITS 100000d4 0000d4 000004 00 A 0 0 4
[ 5] .sec1 PROGBITS 100000d8 0000d8 000004 00 A 0 0 4
[ 6] .sec3 PROGBITS 100000dc 0000dc 000004 00 A 0 0 4
[ 7] .gnu.attributes GNU_ATTRIBUTES 00000000 0000e0 000010 00 0 0 1
[ 8] .symtab SYMTAB 00000000 0000f0 000100 10 9 9 4
[ 9] .strtab STRTAB 00000000 0001f0 000039 00 0 0 1
[10] .shstrtab STRTAB 00000000 000229 00005b 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
L (link order), O (extra OS processing required), G (group), T (TLS),
C (compressed), x (unknown), o (OS specific), E (exclude),
p (processor specific)
So that's not a issue related to gold itself but the testsuit....
I think we should report it to upstream later.
I think we should report it to upstream later.
+1
The issue can be closed now since we solved all the problems related to it.
Hi @FlyGoat
I would like backport the refactory loongson march and LoongISA to binutils-2.30.
The backport is mostly the same as the version that had been merged by upstream, congratulations Xu Chenghua :)
Please review the patch, thanks a lot!
Regards, Leslie Zhai