From a2c0aab6fb7bb35134a7d404add3301cc99569d0 Mon Sep 17 00:00:00 2001 From: Faraz Shahbazker Date: Tue, 21 Jul 2015 04:15:25 -0700 Subject: [PATCH 2/2] [RFC] Add IFUNC tests for MIPS ld/testsuite/ChangeLog: * ld-mips-elf/mips-ifunc.exp: Ifunc test script * ifunc-3-n32.r, ifunc-3-n32.sym, ifunc-3-n32.t, ifunc-3-n64.r, ifunc-3-n64.sym, ifunc-3-n64.t, ifunc-3-o32.r, ifunc-3-o32.sym, ifunc-3-o32.t, ifunc-4-n32.r, ifunc-4-n32.sym, ifunc-4-n32.t, ifunc-4-n64.r, ifunc-4-n64.sym, ifunc-4-n64.t, ifunc-4-o32.r, ifunc-4-o32.sym, ifunc-4-o32.t, ifunc-5-n32.g, ifunc-5-n32.r, ifunc-5-n32.sym, ifunc-5-n64.g, ifunc-5-n64.r, ifunc-5-n64.sym, ifunc-5-o32.g, ifunc-5-o32.r, ifunc-5-o32.sym, ifunc-6-n32.r, ifunc-6-n32.sym, ifunc-6-n64.r, ifunc-6-n64.sym, ifunc-6-o32.r, ifunc-6-o32.sym, ifunc-dyn-def.s, ifunc-dyn-main.s, ifunc-dyn-ref.s, ifunc-dyn.ld, ifunc-iplt.ld, ifunc-iplt-0x400000.t, ifunc-iplt-0x400000000.t, ifunc-iplt-0x4000000000000.t, ifunc-static-def.s, ifunc-static-main.s, ifunc-static-ref.s, ifunc-static.ld, libifunc-1-n32.sym, libifunc-1-n64.sym, libifunc-1-o32.sym, libifunc-2-n32.sym, libifunc-2-n64.sym, libifunc-2-o32.sym: New tests. --- ld/testsuite/ld-mips-elf/ifunc-3-n32.r | 4 + ld/testsuite/ld-mips-elf/ifunc-3-n32.sym | 6 + ld/testsuite/ld-mips-elf/ifunc-3-n32.t | 10 ++ ld/testsuite/ld-mips-elf/ifunc-3-n64.r | 8 + ld/testsuite/ld-mips-elf/ifunc-3-n64.sym | 6 + ld/testsuite/ld-mips-elf/ifunc-3-n64.t | 11 ++ ld/testsuite/ld-mips-elf/ifunc-3-o32.r | 4 + ld/testsuite/ld-mips-elf/ifunc-3-o32.sym | 6 + ld/testsuite/ld-mips-elf/ifunc-3-o32.t | 11 ++ ld/testsuite/ld-mips-elf/ifunc-4-n32.r | 3 + ld/testsuite/ld-mips-elf/ifunc-4-n32.sym | 29 ++++ ld/testsuite/ld-mips-elf/ifunc-4-n32.t | 10 ++ ld/testsuite/ld-mips-elf/ifunc-4-n64.r | 5 + ld/testsuite/ld-mips-elf/ifunc-4-n64.sym | 29 ++++ ld/testsuite/ld-mips-elf/ifunc-4-n64.t | 11 ++ ld/testsuite/ld-mips-elf/ifunc-4-o32.r | 3 + ld/testsuite/ld-mips-elf/ifunc-4-o32.sym | 24 +++ ld/testsuite/ld-mips-elf/ifunc-4-o32.t | 11 ++ ld/testsuite/ld-mips-elf/ifunc-5-n32.r | 4 + ld/testsuite/ld-mips-elf/ifunc-5-n32.sym | 5 + ld/testsuite/ld-mips-elf/ifunc-5-n64.r | 8 + ld/testsuite/ld-mips-elf/ifunc-5-n64.sym | 5 + ld/testsuite/ld-mips-elf/ifunc-5-o32.r | 4 + ld/testsuite/ld-mips-elf/ifunc-5-o32.sym | 6 + ld/testsuite/ld-mips-elf/ifunc-6-n32.r | 4 + ld/testsuite/ld-mips-elf/ifunc-6-n32.sym | 6 + ld/testsuite/ld-mips-elf/ifunc-6-n64.r | 8 + ld/testsuite/ld-mips-elf/ifunc-6-n64.sym | 6 + ld/testsuite/ld-mips-elf/ifunc-6-o32.r | 4 + ld/testsuite/ld-mips-elf/ifunc-6-o32.sym | 6 + ld/testsuite/ld-mips-elf/ifunc-dyn-def.s | 67 +++++++++ ld/testsuite/ld-mips-elf/ifunc-dyn-main.s | 39 +++++ ld/testsuite/ld-mips-elf/ifunc-dyn-ref.s | 43 ++++++ ld/testsuite/ld-mips-elf/ifunc-dyn.ld | 25 ++++ ld/testsuite/ld-mips-elf/ifunc-iplt-0x400000.t | 11 ++ ld/testsuite/ld-mips-elf/ifunc-iplt-0x400000000.t | 13 ++ .../ld-mips-elf/ifunc-iplt-0x4000000000000.t | 14 ++ ld/testsuite/ld-mips-elf/ifunc-iplt.ld | 26 ++++ ld/testsuite/ld-mips-elf/ifunc-static-def.s | 155 ++++++++++++++++++++ ld/testsuite/ld-mips-elf/ifunc-static-main.s | 39 +++++ ld/testsuite/ld-mips-elf/ifunc-static-ref.s | 39 +++++ ld/testsuite/ld-mips-elf/ifunc-static.ld | 27 ++++ ld/testsuite/ld-mips-elf/libifunc-1-n32.sym | 4 + ld/testsuite/ld-mips-elf/libifunc-1-n64.sym | 4 + ld/testsuite/ld-mips-elf/libifunc-1-o32.sym | 4 + ld/testsuite/ld-mips-elf/libifunc-2-n32.sym | 4 + ld/testsuite/ld-mips-elf/libifunc-2-n64.sym | 4 + ld/testsuite/ld-mips-elf/libifunc-2-o32.sym | 5 + ld/testsuite/ld-mips-elf/mips-ifunc.exp | 149 +++++++++++++++++++ 49 files changed, 929 insertions(+) create mode 100644 ld/testsuite/ld-mips-elf/ifunc-3-n32.r create mode 100644 ld/testsuite/ld-mips-elf/ifunc-3-n32.sym create mode 100644 ld/testsuite/ld-mips-elf/ifunc-3-n32.t create mode 100644 ld/testsuite/ld-mips-elf/ifunc-3-n64.r create mode 100644 ld/testsuite/ld-mips-elf/ifunc-3-n64.sym create mode 100644 ld/testsuite/ld-mips-elf/ifunc-3-n64.t create mode 100644 ld/testsuite/ld-mips-elf/ifunc-3-o32.r create mode 100644 ld/testsuite/ld-mips-elf/ifunc-3-o32.sym create mode 100644 ld/testsuite/ld-mips-elf/ifunc-3-o32.t create mode 100644 ld/testsuite/ld-mips-elf/ifunc-4-n32.r create mode 100644 ld/testsuite/ld-mips-elf/ifunc-4-n32.sym create mode 100644 ld/testsuite/ld-mips-elf/ifunc-4-n32.t create mode 100644 ld/testsuite/ld-mips-elf/ifunc-4-n64.r create mode 100644 ld/testsuite/ld-mips-elf/ifunc-4-n64.sym create mode 100644 ld/testsuite/ld-mips-elf/ifunc-4-n64.t create mode 100644 ld/testsuite/ld-mips-elf/ifunc-4-o32.r create mode 100644 ld/testsuite/ld-mips-elf/ifunc-4-o32.sym create mode 100644 ld/testsuite/ld-mips-elf/ifunc-4-o32.t create mode 100644 ld/testsuite/ld-mips-elf/ifunc-5-n32.r create mode 100644 ld/testsuite/ld-mips-elf/ifunc-5-n32.sym create mode 100644 ld/testsuite/ld-mips-elf/ifunc-5-n64.r create mode 100644 ld/testsuite/ld-mips-elf/ifunc-5-n64.sym create mode 100644 ld/testsuite/ld-mips-elf/ifunc-5-o32.r create mode 100644 ld/testsuite/ld-mips-elf/ifunc-5-o32.sym create mode 100644 ld/testsuite/ld-mips-elf/ifunc-6-n32.r create mode 100644 ld/testsuite/ld-mips-elf/ifunc-6-n32.sym create mode 100644 ld/testsuite/ld-mips-elf/ifunc-6-n64.r create mode 100644 ld/testsuite/ld-mips-elf/ifunc-6-n64.sym create mode 100644 ld/testsuite/ld-mips-elf/ifunc-6-o32.r create mode 100644 ld/testsuite/ld-mips-elf/ifunc-6-o32.sym create mode 100644 ld/testsuite/ld-mips-elf/ifunc-dyn-def.s create mode 100644 ld/testsuite/ld-mips-elf/ifunc-dyn-main.s create mode 100644 ld/testsuite/ld-mips-elf/ifunc-dyn-ref.s create mode 100644 ld/testsuite/ld-mips-elf/ifunc-dyn.ld create mode 100644 ld/testsuite/ld-mips-elf/ifunc-iplt-0x400000.t create mode 100644 ld/testsuite/ld-mips-elf/ifunc-iplt-0x400000000.t create mode 100644 ld/testsuite/ld-mips-elf/ifunc-iplt-0x4000000000000.t create mode 100644 ld/testsuite/ld-mips-elf/ifunc-iplt.ld create mode 100644 ld/testsuite/ld-mips-elf/ifunc-static-def.s create mode 100644 ld/testsuite/ld-mips-elf/ifunc-static-main.s create mode 100644 ld/testsuite/ld-mips-elf/ifunc-static-ref.s create mode 100644 ld/testsuite/ld-mips-elf/ifunc-static.ld create mode 100644 ld/testsuite/ld-mips-elf/libifunc-1-n32.sym create mode 100644 ld/testsuite/ld-mips-elf/libifunc-1-n64.sym create mode 100644 ld/testsuite/ld-mips-elf/libifunc-1-o32.sym create mode 100644 ld/testsuite/ld-mips-elf/libifunc-2-n32.sym create mode 100644 ld/testsuite/ld-mips-elf/libifunc-2-n64.sym create mode 100644 ld/testsuite/ld-mips-elf/libifunc-2-o32.sym create mode 100644 ld/testsuite/ld-mips-elf/mips-ifunc.exp diff --git a/ld/testsuite/ld-mips-elf/ifunc-3-n32.r b/ld/testsuite/ld-mips-elf/ifunc-3-n32.r new file mode 100644 index 0000000..b14c140 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-3-n32.r @@ -0,0 +1,4 @@ +Relocation section '.rel.dyn' at offset 0x12000 contains 2 entries: + Offset Info Type Sym.Value Sym. Name +00000000 00000000 R_MIPS_NONE +00000800 00000080 R_MIPS_IRELATIVE diff --git a/ld/testsuite/ld-mips-elf/ifunc-3-n32.sym b/ld/testsuite/ld-mips-elf/ifunc-3-n32.sym new file mode 100644 index 0000000..6068a87 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-3-n32.sym @@ -0,0 +1,6 @@ +Symbol table for image: + Num Buc: Value Size Type Bind Vis Ndx Name + 4 0: 00000000 0 FUNC GLOBAL DEFAULT UND ref1 + 2 0: 00000400 28 FUNC GLOBAL DEFAULT 1 func1 + 1 1: 00000001 0 SECTION GLOBAL DEFAULT ABS _DYNAMIC_LINKING + 3 2: 0000100c 0 OBJECT GLOBAL DEFAULT 14 __RLD_MAP diff --git a/ld/testsuite/ld-mips-elf/ifunc-3-n32.t b/ld/testsuite/ld-mips-elf/ifunc-3-n32.t new file mode 100644 index 0000000..edf2787 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-3-n32.t @@ -0,0 +1,10 @@ +tmpdir/ifunc-3-n32: file format elf32-ntradbigmips + + +Disassembly of section .iplt: + +00000400 <.iplt.func1>: + 400: 3c0f0000 lui t3,0x0 + 404: 8df90800 lw t9,2048\(t3\) + 408: 03200008 jr t9 + 40c: 00000000 nop diff --git a/ld/testsuite/ld-mips-elf/ifunc-3-n64.r b/ld/testsuite/ld-mips-elf/ifunc-3-n64.r new file mode 100644 index 0000000..53b6455 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-3-n64.r @@ -0,0 +1,8 @@ +Relocation section '.rel.dyn' at offset 0x12000 contains 2 entries: + Offset Info Type Sym. Value Sym. Name +000000000000 000000000000 R_MIPS_NONE + Type2: R_MIPS_NONE + Type3: R_MIPS_NONE +000000000800 000000000080 R_MIPS_IRELATIVE + Type2: R_MIPS_NONE + Type3: R_MIPS_NONE diff --git a/ld/testsuite/ld-mips-elf/ifunc-3-n64.sym b/ld/testsuite/ld-mips-elf/ifunc-3-n64.sym new file mode 100644 index 0000000..bc9c09f --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-3-n64.sym @@ -0,0 +1,6 @@ +Symbol table for image: + Num Buc: Value Size Type Bind Vis Ndx Name + 4 0: 0000000000000000 0 FUNC GLOBAL DEFAULT UND ref1 + 2 0: 0000000000000400 28 FUNC GLOBAL DEFAULT 1 func1 + 1 1: 0000000000000001 0 SECTION GLOBAL DEFAULT ABS _DYNAMIC_LINKING + 3 2: 0000000000001018 0 OBJECT GLOBAL DEFAULT 14 __RLD_MAP diff --git a/ld/testsuite/ld-mips-elf/ifunc-3-n64.t b/ld/testsuite/ld-mips-elf/ifunc-3-n64.t new file mode 100644 index 0000000..0df1db2 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-3-n64.t @@ -0,0 +1,11 @@ +tmpdir/ifunc-3-n64: file format elf64-tradbigmips + + +Disassembly of section .iplt: + +0000000000000400 <.iplt.func1>: + 400: 3c0f0000 lui t3,0x0 + 404: ddf90800 ld t9,2048\(t3\) + 408: 03200008 jr t9 + 40c: 00000000 nop + ... diff --git a/ld/testsuite/ld-mips-elf/ifunc-3-o32.r b/ld/testsuite/ld-mips-elf/ifunc-3-o32.r new file mode 100644 index 0000000..b14c140 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-3-o32.r @@ -0,0 +1,4 @@ +Relocation section '.rel.dyn' at offset 0x12000 contains 2 entries: + Offset Info Type Sym.Value Sym. Name +00000000 00000000 R_MIPS_NONE +00000800 00000080 R_MIPS_IRELATIVE diff --git a/ld/testsuite/ld-mips-elf/ifunc-3-o32.sym b/ld/testsuite/ld-mips-elf/ifunc-3-o32.sym new file mode 100644 index 0000000..a6c92d1 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-3-o32.sym @@ -0,0 +1,6 @@ +Symbol table for image: + Num Buc: Value Size Type Bind Vis Ndx Name + 4 0: 00000000 0 FUNC GLOBAL DEFAULT UND ref1 + 2 0: 00000400 40 FUNC GLOBAL DEFAULT 1 func1 + 1 1: 00000001 0 SECTION GLOBAL DEFAULT ABS _DYNAMIC_LINKING + 3 2: 0000100c 0 OBJECT GLOBAL DEFAULT 14 __RLD_MAP diff --git a/ld/testsuite/ld-mips-elf/ifunc-3-o32.t b/ld/testsuite/ld-mips-elf/ifunc-3-o32.t new file mode 100644 index 0000000..eba438f --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-3-o32.t @@ -0,0 +1,11 @@ +tmpdir/ifunc-3-o32: file format elf32-tradbigmips + + +Disassembly of section .iplt: + +00000400 <.iplt.func1>: + 400: 3c0f0000 lui t7,0x0 + 404: 8df90800 lw t9,2048\(t7\) + 408: 00000000 nop + 40c: 03200008 jr t9 + 410: 00000000 nop diff --git a/ld/testsuite/ld-mips-elf/ifunc-4-n32.r b/ld/testsuite/ld-mips-elf/ifunc-4-n32.r new file mode 100644 index 0000000..e899ffc --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-4-n32.r @@ -0,0 +1,3 @@ +Relocation section '.rel.dyn' at offset 0x11000 contains 1 entries: + Offset Info Type Sym.Value Sym. Name +00080800 00000080 R_MIPS_IRELATIVE diff --git a/ld/testsuite/ld-mips-elf/ifunc-4-n32.sym b/ld/testsuite/ld-mips-elf/ifunc-4-n32.sym new file mode 100644 index 0000000..4761ae5 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-4-n32.sym @@ -0,0 +1,29 @@ +Symbol table '.symtab' contains 27 entries: + Num: Value Size Type Bind Vis Ndx Name + 0: 00000000 0 NOTYPE LOCAL DEFAULT UND + 1: 00080000 0 SECTION LOCAL DEFAULT 1 + 2: 00080400 0 SECTION LOCAL DEFAULT 2 + 3: 00080800 0 SECTION LOCAL DEFAULT 3 + 4: 00081000 0 SECTION LOCAL DEFAULT 4 + 5: 00081008 0 SECTION LOCAL DEFAULT 5 + 6: 00081020 0 SECTION LOCAL DEFAULT 6 + 7: 00000000 0 SECTION LOCAL DEFAULT 7 + 8: 00000000 0 SECTION LOCAL DEFAULT 8 + 9: 00000000 0 SECTION LOCAL DEFAULT 9 + 10: 00000000 0 FILE LOCAL DEFAULT ABS ifunc_ref_main_1.c + 11: 00000000 0 FILE LOCAL DEFAULT ABS ifunc.c + 12: 00080430 36 FUNC LOCAL DEFAULT 2 f1_a + 13: 00080454 36 FUNC LOCAL DEFAULT 2 f1_b + 14: 00080478 36 FUNC LOCAL DEFAULT 2 f1_c + 15: 000804d0 0 NOTYPE LOCAL DEFAULT 2 \$L8 + 16: 000804d8 0 NOTYPE LOCAL DEFAULT 2 \$L9 + 17: 000804f8 0 NOTYPE LOCAL DEFAULT 2 \$L10 + 18: 00080520 0 NOTYPE LOCAL DEFAULT 2 \$L13 + 19: 00080518 0 NOTYPE LOCAL DEFAULT 2 \$L12 + 20: 00000000 0 FILE LOCAL DEFAULT ABS ifunc_ref.c + 21: 00000000 0 FILE LOCAL DEFAULT ABS + 22: 00080000 16 FUNC LOCAL DEFAULT 1 .iplt.func1 + 23: 0008049c 156 IFUNC GLOBAL DEFAULT 2 func1 + 24: 00080400 48 FUNC GLOBAL DEFAULT 2 main + 25: 00080540 48 FUNC GLOBAL DEFAULT 2 ref1 + 26: 0008049c 156 FUNC GLOBAL DEFAULT 2 func1_ifunc diff --git a/ld/testsuite/ld-mips-elf/ifunc-4-n32.t b/ld/testsuite/ld-mips-elf/ifunc-4-n32.t new file mode 100644 index 0000000..a681706 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-4-n32.t @@ -0,0 +1,10 @@ +tmpdir/ifunc-4-n32: file format elf32-ntradbigmips + + +Disassembly of section .iplt: + +00080000 <.iplt.func1>: + 80000: 3c0f0008 lui t3,0x8 + 80004: 8df90800 lw t9,2048\(t3\) + 80008: 03200008 jr t9 + 8000c: 00000000 nop diff --git a/ld/testsuite/ld-mips-elf/ifunc-4-n64.r b/ld/testsuite/ld-mips-elf/ifunc-4-n64.r new file mode 100644 index 0000000..695742b --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-4-n64.r @@ -0,0 +1,5 @@ +Relocation section '.rel.dyn' at offset 0x11000 contains 1 entries: + Offset Info Type Sym. Value Sym. Name +000000080800 000000000080 R_MIPS_IRELATIVE + Type2: R_MIPS_NONE + Type3: R_MIPS_NONE diff --git a/ld/testsuite/ld-mips-elf/ifunc-4-n64.sym b/ld/testsuite/ld-mips-elf/ifunc-4-n64.sym new file mode 100644 index 0000000..0d044f5 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-4-n64.sym @@ -0,0 +1,29 @@ +Symbol table '.symtab' contains 27 entries: + Num: Value Size Type Bind Vis Ndx Name + 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND + 1: 0000000000080000 0 SECTION LOCAL DEFAULT 1 + 2: 0000000000080400 0 SECTION LOCAL DEFAULT 2 + 3: 0000000000080800 0 SECTION LOCAL DEFAULT 3 + 4: 0000000000081000 0 SECTION LOCAL DEFAULT 4 + 5: 0000000000081010 0 SECTION LOCAL DEFAULT 5 + 6: 0000000000081088 0 SECTION LOCAL DEFAULT 6 + 7: 0000000000000000 0 SECTION LOCAL DEFAULT 7 + 8: 0000000000000000 0 SECTION LOCAL DEFAULT 8 + 9: 0000000000000000 0 SECTION LOCAL DEFAULT 9 + 10: 0000000000000000 0 FILE LOCAL DEFAULT ABS ifunc_ref_main_1.c + 11: 0000000000000000 0 FILE LOCAL DEFAULT ABS ifunc.c + 12: 0000000000080430 36 FUNC LOCAL DEFAULT 2 f1_a + 13: 0000000000080454 36 FUNC LOCAL DEFAULT 2 f1_b + 14: 0000000000080478 36 FUNC LOCAL DEFAULT 2 f1_c + 15: 00000000000804d0 0 NOTYPE LOCAL DEFAULT 2 \$L8 + 16: 00000000000804d8 0 NOTYPE LOCAL DEFAULT 2 \$L9 + 17: 00000000000804f8 0 NOTYPE LOCAL DEFAULT 2 \$L10 + 18: 0000000000080520 0 NOTYPE LOCAL DEFAULT 2 \$L13 + 19: 0000000000080518 0 NOTYPE LOCAL DEFAULT 2 \$L12 + 20: 0000000000000000 0 FILE LOCAL DEFAULT ABS ifunc_ref.c + 21: 0000000000000000 0 FILE LOCAL DEFAULT ABS + 22: 0000000000080000 32 FUNC LOCAL DEFAULT 1 .iplt.func1 + 23: 000000000008049c 156 IFUNC GLOBAL DEFAULT 2 func1 + 24: 0000000000080400 48 FUNC GLOBAL DEFAULT 2 main + 25: 0000000000080540 48 FUNC GLOBAL DEFAULT 2 ref1 + 26: 000000000008049c 156 FUNC GLOBAL DEFAULT 2 func1_ifunc diff --git a/ld/testsuite/ld-mips-elf/ifunc-4-n64.t b/ld/testsuite/ld-mips-elf/ifunc-4-n64.t new file mode 100644 index 0000000..bf5a2d2 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-4-n64.t @@ -0,0 +1,11 @@ +tmpdir/ifunc-4-n64: file format elf64-tradbigmips + + +Disassembly of section .iplt: + +0000000000080000 <.iplt.func1>: + 80000: 3c0f0008 lui t3,0x8 + 80004: ddf90800 ld t9,2048\(t3\) + 80008: 03200008 jr t9 + 8000c: 00000000 nop + ... diff --git a/ld/testsuite/ld-mips-elf/ifunc-4-o32.r b/ld/testsuite/ld-mips-elf/ifunc-4-o32.r new file mode 100644 index 0000000..e899ffc --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-4-o32.r @@ -0,0 +1,3 @@ +Relocation section '.rel.dyn' at offset 0x11000 contains 1 entries: + Offset Info Type Sym.Value Sym. Name +00080800 00000080 R_MIPS_IRELATIVE diff --git a/ld/testsuite/ld-mips-elf/ifunc-4-o32.sym b/ld/testsuite/ld-mips-elf/ifunc-4-o32.sym new file mode 100644 index 0000000..4f6e13e --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-4-o32.sym @@ -0,0 +1,24 @@ +Symbol table '.symtab' contains 22 entries: + Num: Value Size Type Bind Vis Ndx Name + 0: 00000000 0 NOTYPE LOCAL DEFAULT UND + 1: 00080000 0 SECTION LOCAL DEFAULT 1 + 2: 00080400 0 SECTION LOCAL DEFAULT 2 + 3: 00080800 0 SECTION LOCAL DEFAULT 3 + 4: 00081000 0 SECTION LOCAL DEFAULT 4 + 5: 00081008 0 SECTION LOCAL DEFAULT 5 + 6: 00081020 0 SECTION LOCAL DEFAULT 6 + 7: 00000000 0 SECTION LOCAL DEFAULT 7 + 8: 00000000 0 SECTION LOCAL DEFAULT 8 + 9: 00000000 0 SECTION LOCAL DEFAULT 9 + 10: 00000000 0 FILE LOCAL DEFAULT ABS ifunc_ref_main_1.c + 11: 00000000 0 FILE LOCAL DEFAULT ABS ifunc.c + 12: 00080430 36 FUNC LOCAL DEFAULT 2 f1_a + 13: 00080454 36 FUNC LOCAL DEFAULT 2 f1_b + 14: 00080478 36 FUNC LOCAL DEFAULT 2 f1_c + 15: 00000000 0 FILE LOCAL DEFAULT ABS ifunc_ref.c + 16: 00000000 0 FILE LOCAL DEFAULT ABS + 17: 00080000 20 FUNC LOCAL DEFAULT 1 .iplt.func1 + 18: 0008049c 156 IFUNC GLOBAL DEFAULT 2 func1 + 19: 00080400 48 FUNC GLOBAL DEFAULT 2 main + 20: 00080540 48 FUNC GLOBAL DEFAULT 2 ref1 + 21: 0008049c 156 FUNC GLOBAL DEFAULT 2 func1_ifunc diff --git a/ld/testsuite/ld-mips-elf/ifunc-4-o32.t b/ld/testsuite/ld-mips-elf/ifunc-4-o32.t new file mode 100644 index 0000000..bc71cb0 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-4-o32.t @@ -0,0 +1,11 @@ +tmpdir/ifunc-4-o32: file format elf32-tradbigmips + + +Disassembly of section .iplt: + +00080000 <.iplt.func1>: + 80000: 3c0f0008 lui t7,0x8 + 80004: 8df90800 lw t9,2048\(t7\) + 80008: 00000000 nop + 8000c: 03200008 jr t9 + 80010: 00000000 nop diff --git a/ld/testsuite/ld-mips-elf/ifunc-5-n32.r b/ld/testsuite/ld-mips-elf/ifunc-5-n32.r new file mode 100644 index 0000000..fb0ef4a --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-5-n32.r @@ -0,0 +1,4 @@ +Relocation section '.rel.dyn' at offset 0x11000 contains 2 entries: + Offset Info Type Sym.Value Sym. Name +00000000 00000000 R_MIPS_NONE +00000410 00000403 R_MIPS_REL32 func1\(\) func1 diff --git a/ld/testsuite/ld-mips-elf/ifunc-5-n32.sym b/ld/testsuite/ld-mips-elf/ifunc-5-n32.sym new file mode 100644 index 0000000..3756726 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-5-n32.sym @@ -0,0 +1,5 @@ +Symbol table for image: + Num Buc: Value Size Type Bind Vis Ndx Name + 2 0: 00000030 60 FUNC GLOBAL DEFAULT 1 ref1 + 4 0: 0000000c 28 IFUNC GLOBAL DEFAULT 1 func1 + 3 1: 0000000c 28 FUNC GLOBAL DEFAULT 1 func1_ifunc diff --git a/ld/testsuite/ld-mips-elf/ifunc-5-n64.r b/ld/testsuite/ld-mips-elf/ifunc-5-n64.r new file mode 100644 index 0000000..718d84a --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-5-n64.r @@ -0,0 +1,8 @@ +Relocation section '.rel.dyn' at offset 0x11000 contains 2 entries: + Offset Info Type Sym. Value Sym. Name +000000000000 000000000000 R_MIPS_NONE + Type2: R_MIPS_NONE + Type3: R_MIPS_NONE +000000000420 000400001203 R_MIPS_REL32 func1\(\) func1 + Type2: R_MIPS_64 + Type3: R_MIPS_NONE diff --git a/ld/testsuite/ld-mips-elf/ifunc-5-n64.sym b/ld/testsuite/ld-mips-elf/ifunc-5-n64.sym new file mode 100644 index 0000000..c28e09a --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-5-n64.sym @@ -0,0 +1,5 @@ +Symbol table for image: + Num Buc: Value Size Type Bind Vis Ndx Name + 2 0: 0000000000000030 60 FUNC GLOBAL DEFAULT 1 ref1 + 4 0: 000000000000000c 28 IFUNC GLOBAL DEFAULT 1 func1 + 3 1: 000000000000000c 28 FUNC GLOBAL DEFAULT 1 func1_ifunc diff --git a/ld/testsuite/ld-mips-elf/ifunc-5-o32.r b/ld/testsuite/ld-mips-elf/ifunc-5-o32.r new file mode 100644 index 0000000..dbb3325 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-5-o32.r @@ -0,0 +1,4 @@ +Relocation section '.rel.dyn' at offset 0x11000 contains 2 entries: + Offset Info Type Sym.Value Sym. Name +00000000 00000000 R_MIPS_NONE +00000410 00000503 R_MIPS_REL32 func1\(\) func1 diff --git a/ld/testsuite/ld-mips-elf/ifunc-5-o32.sym b/ld/testsuite/ld-mips-elf/ifunc-5-o32.sym new file mode 100644 index 0000000..66a60f7 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-5-o32.sym @@ -0,0 +1,6 @@ +Symbol table for image: + Num Buc: Value Size Type Bind Vis Ndx Name + 3 0: 00000040 76 FUNC GLOBAL DEFAULT 1 ref1 + 5 0: 0000000c 40 IFUNC GLOBAL DEFAULT 1 func1 + 2 0: 00000000 0 SECTION GLOBAL DEFAULT ABS _gp_disp + 4 1: 0000000c 40 FUNC GLOBAL DEFAULT 1 func1_ifunc diff --git a/ld/testsuite/ld-mips-elf/ifunc-6-n32.r b/ld/testsuite/ld-mips-elf/ifunc-6-n32.r new file mode 100644 index 0000000..b14c140 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-6-n32.r @@ -0,0 +1,4 @@ +Relocation section '.rel.dyn' at offset 0x12000 contains 2 entries: + Offset Info Type Sym.Value Sym. Name +00000000 00000000 R_MIPS_NONE +00000800 00000080 R_MIPS_IRELATIVE diff --git a/ld/testsuite/ld-mips-elf/ifunc-6-n32.sym b/ld/testsuite/ld-mips-elf/ifunc-6-n32.sym new file mode 100644 index 0000000..2c822d9 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-6-n32.sym @@ -0,0 +1,6 @@ +Symbol table for image: + Num Buc: Value Size Type Bind Vis Ndx Name + 4 0: 00000070 60 FUNC GLOBAL DEFAULT 1 ref1 + 2 0: 00000400 28 FUNC GLOBAL DEFAULT 1 func1 + 1 1: 00000001 0 SECTION GLOBAL DEFAULT ABS _DYNAMIC_LINKING + 3 2: 00001000 0 OBJECT GLOBAL DEFAULT 12 __RLD_MAP diff --git a/ld/testsuite/ld-mips-elf/ifunc-6-n64.r b/ld/testsuite/ld-mips-elf/ifunc-6-n64.r new file mode 100644 index 0000000..53b6455 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-6-n64.r @@ -0,0 +1,8 @@ +Relocation section '.rel.dyn' at offset 0x12000 contains 2 entries: + Offset Info Type Sym. Value Sym. Name +000000000000 000000000000 R_MIPS_NONE + Type2: R_MIPS_NONE + Type3: R_MIPS_NONE +000000000800 000000000080 R_MIPS_IRELATIVE + Type2: R_MIPS_NONE + Type3: R_MIPS_NONE diff --git a/ld/testsuite/ld-mips-elf/ifunc-6-n64.sym b/ld/testsuite/ld-mips-elf/ifunc-6-n64.sym new file mode 100644 index 0000000..500aada --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-6-n64.sym @@ -0,0 +1,6 @@ +Symbol table for image: + Num Buc: Value Size Type Bind Vis Ndx Name + 4 0: 0000000000000070 60 FUNC GLOBAL DEFAULT 1 ref1 + 2 0: 0000000000000400 28 FUNC GLOBAL DEFAULT 1 func1 + 1 1: 0000000000000001 0 SECTION GLOBAL DEFAULT ABS _DYNAMIC_LINKING + 3 2: 0000000000001000 0 OBJECT GLOBAL DEFAULT 12 __RLD_MAP diff --git a/ld/testsuite/ld-mips-elf/ifunc-6-o32.r b/ld/testsuite/ld-mips-elf/ifunc-6-o32.r new file mode 100644 index 0000000..b14c140 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-6-o32.r @@ -0,0 +1,4 @@ +Relocation section '.rel.dyn' at offset 0x12000 contains 2 entries: + Offset Info Type Sym.Value Sym. Name +00000000 00000000 R_MIPS_NONE +00000800 00000080 R_MIPS_IRELATIVE diff --git a/ld/testsuite/ld-mips-elf/ifunc-6-o32.sym b/ld/testsuite/ld-mips-elf/ifunc-6-o32.sym new file mode 100644 index 0000000..a39cb03 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-6-o32.sym @@ -0,0 +1,6 @@ +Symbol table for image: + Num Buc: Value Size Type Bind Vis Ndx Name + 4 0: 00000080 76 FUNC GLOBAL DEFAULT 1 ref1 + 2 0: 00000400 40 FUNC GLOBAL DEFAULT 1 func1 + 1 1: 00000001 0 SECTION GLOBAL DEFAULT ABS _DYNAMIC_LINKING + 3 2: 00001000 0 OBJECT GLOBAL DEFAULT 12 __RLD_MAP diff --git a/ld/testsuite/ld-mips-elf/ifunc-dyn-def.s b/ld/testsuite/ld-mips-elf/ifunc-dyn-def.s new file mode 100644 index 0000000..9b5d2a8 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-dyn-def.s @@ -0,0 +1,67 @@ + .file 1 "ifunc.c" + .section .mdebug.abi32 + .previous + .nan legacy + .gnu_attribute 4, 1 + .abicalls + .text + .align 2 + .set nomips16 + .set nomicromips + .ent f1_a + .type f1_a, @function +f1_a: + nop + + .set macro + .set reorder + .end f1_a + .size f1_a, .-f1_a + .align 2 + .set nomips16 + .set nomicromips + .ent f1_b + .type f1_b, @function +f1_b: + nop + + .set macro + .set reorder + .end f1_b + .size f1_b, .-f1_b + .align 2 + .set nomips16 + .set nomicromips + .ent f1_c + .type f1_c, @function +f1_c: + .frame $fp,8,$31 # vars= 0, regs= 1/0, args= 0, gp= 0 + nop + + .set macro + .set reorder + .end f1_c + .size f1_c, .-f1_c + .align 2 + .globl func1_ifunc + .set nomips16 + .set nomicromips + .ent func1_ifunc + .type func1_ifunc, @function +func1_ifunc: + lw $2,%got(f1_a)($28) + addiu $2,$2,%lo(f1_a) + lw $2,%got(f1_b)($28) + addiu $2,$2,%lo(f1_b) + lw $2,%got(f1_c)($28) + addiu $2,$2,%lo(f1_c) + nop + + .set macro + .set reorder + .end func1_ifunc + .size func1_ifunc, .-func1_ifunc + .globl func1 + .type func1, @gnu_indirect_function + func1 = func1_ifunc + .ident "GCC: (GNU) 4.9.0 20130917 (experimental)" diff --git a/ld/testsuite/ld-mips-elf/ifunc-dyn-main.s b/ld/testsuite/ld-mips-elf/ifunc-dyn-main.s new file mode 100644 index 0000000..8c12176 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-dyn-main.s @@ -0,0 +1,39 @@ + .file 1 "ifunc_ref_main_2.c" + .section .mdebug.abi32 + .previous + .nan legacy + .gnu_attribute 4, 1 + .abicalls + .option pic0 + .text + .align 2 + .globl main + .set nomips16 + .set nomicromips + .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 + jal ref1 + nop + + move $sp,$fp + lw $31,28($sp) + lw $fp,24($sp) + addiu $sp,$sp,32 + j $31 + nop + + .set macro + .set reorder + .end main + .size main, .-main + .ident "GCC: (GNU) 4.9.0 20130930 (experimental)" diff --git a/ld/testsuite/ld-mips-elf/ifunc-dyn-ref.s b/ld/testsuite/ld-mips-elf/ifunc-dyn-ref.s new file mode 100644 index 0000000..d562096 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-dyn-ref.s @@ -0,0 +1,43 @@ + .file 1 "ifunc_ref.c" + .section .mdebug.abi32 + .previous + .nan legacy + .gnu_attribute 4, 1 + .abicalls + .text + .align 2 + .globl ref1 + .set nomips16 + .set nomicromips + .ent ref1 + .type ref1, @function +ref1: + .frame $fp,32,$31 # vars= 0, regs= 2/0, args= 16, gp= 8 + .mask 0xc0000000,-4 + .fmask 0x00000000,0 + .set noreorder + .cpload $25 + .set nomacro + addiu $sp,$sp,-32 + sw $31,28($sp) + sw $fp,24($sp) + move $fp,$sp + .cprestore 16 + lw $2,%call16(func1)($28) + move $25,$2 + jalr $25 + nop + + lw $28,16($fp) + move $sp,$fp + lw $31,28($sp) + lw $fp,24($sp) + addiu $sp,$sp,32 + j $31 + nop + + .set macro + .set reorder + .end ref1 + .size ref1, .-ref1 + .ident "GCC: (GNU) 4.9.0 20130930 (experimental)" diff --git a/ld/testsuite/ld-mips-elf/ifunc-dyn.ld b/ld/testsuite/ld-mips-elf/ifunc-dyn.ld new file mode 100644 index 0000000..c82c8ce --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-dyn.ld @@ -0,0 +1,25 @@ +ENTRY(_start) +SECTIONS +{ + . = ALIGN (0x400); + .text : { *(.text) } + + . = ALIGN (0x400); + .iplt : { *(.iplt) } + + . = ALIGN (0x400); + .igot : { *(.igot) } + + . = ALIGN (0x400); + .got : { *(.got) } + + . = ALIGN (0x400); + .data : { *(.data) } + + . = ALIGN (0x1000); + .rel.dyn : + { + *(.rel.*) + } + +} diff --git a/ld/testsuite/ld-mips-elf/ifunc-iplt-0x400000.t b/ld/testsuite/ld-mips-elf/ifunc-iplt-0x400000.t new file mode 100644 index 0000000..c46a85d --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-iplt-0x400000.t @@ -0,0 +1,11 @@ +tmpdir/ifunc-iplt-0x400000: file format elf64-tradbigmips + + +Disassembly of section .iplt: + +0000000000400188 <.iplt.func1>: + 400188: 3c0f0041 lui t3,0x41 + 40018c: ddf90320 ld t9,800\(t3\) + 400190: 03200008 jr t9 + 400194: 00000000 nop + ... diff --git a/ld/testsuite/ld-mips-elf/ifunc-iplt-0x400000000.t b/ld/testsuite/ld-mips-elf/ifunc-iplt-0x400000000.t new file mode 100644 index 0000000..3562b23 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-iplt-0x400000000.t @@ -0,0 +1,13 @@ +tmpdir/ifunc-iplt-0x400000000: file format elf64-tradbigmips + + +Disassembly of section .iplt: + +0000000400000188 <.iplt.func1>: + 400000188: 3c0f0004 lui t3,0x4 + 40000018c: 25ef0001 addiu t3,t3,1 + 400000190: 000f7c38 dsll t3,t3,0x10 + 400000194: ddf90320 ld t9,800\(t3\) + 400000198: 03200008 jr t9 + 40000019c: 00000000 nop + ... diff --git a/ld/testsuite/ld-mips-elf/ifunc-iplt-0x4000000000000.t b/ld/testsuite/ld-mips-elf/ifunc-iplt-0x4000000000000.t new file mode 100644 index 0000000..90e8306 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-iplt-0x4000000000000.t @@ -0,0 +1,14 @@ +tmpdir/ifunc-iplt-0x4000000000000: file format elf64-tradbigmips + + +Disassembly of section .iplt: + +0004000000000188 <.iplt.func1>: + 4000000000188: 3c0f0004 lui t3,0x4 + 400000000018c: 3c0e0001 lui t2,0x1 + 4000000000190: 25ef0000 addiu t3,t3,0 + 4000000000194: 000f783c dsll32 t3,t3,0x0 + 4000000000198: 01ee782d daddu t3,t3,t2 + 400000000019c: ddf90320 ld t9,800\(t3\) + 40000000001a0: 03200008 jr t9 + 40000000001a4: 00000000 nop diff --git a/ld/testsuite/ld-mips-elf/ifunc-iplt.ld b/ld/testsuite/ld-mips-elf/ifunc-iplt.ld new file mode 100644 index 0000000..a26b803 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-iplt.ld @@ -0,0 +1,26 @@ +ENTRY(_start) +SECTIONS +{ + . = ALIGN (0x400); + .iplt : { *(.iplt) } + + . = ALIGN (0x400); + .text : { *(.text) } + + . = ALIGN (0x400); + .igot : { *(.igot) } + + . = ALIGN (0x400); + .got : { *(.got) } + + . = ALIGN (0x400); + .data : { *(.data) } + + . = ALIGN (0x1000); + .rel.dyn : + { + *(.rel.*) + } +/* /DISCARD/ : { *(*) } */ + +} diff --git a/ld/testsuite/ld-mips-elf/ifunc-static-def.s b/ld/testsuite/ld-mips-elf/ifunc-static-def.s new file mode 100644 index 0000000..cf84696 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-static-def.s @@ -0,0 +1,155 @@ + .file 1 "ifunc.c" + .section .mdebug.abi32 + .previous + .nan legacy + .gnu_attribute 4, 1 + .abicalls + .option pic0 + .text + .align 2 + .set nomips16 + .set nomicromips + .ent f1_a + .type f1_a, @function +f1_a: + .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 + li $2,1 # 0x1 + move $sp,$fp + lw $fp,4($sp) + addiu $sp,$sp,8 + j $31 + nop + + .set macro + .set reorder + .end f1_a + .size f1_a, .-f1_a + .align 2 + .set nomips16 + .set nomicromips + .ent f1_b + .type f1_b, @function +f1_b: + .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 + li $2,2 # 0x2 + move $sp,$fp + lw $fp,4($sp) + addiu $sp,$sp,8 + j $31 + nop + + .set macro + .set reorder + .end f1_b + .size f1_b, .-f1_b + .align 2 + .set nomips16 + .set nomicromips + .ent f1_c + .type f1_c, @function +f1_c: + .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 + li $2,3 # 0x3 + move $sp,$fp + lw $fp,4($sp) + addiu $sp,$sp,8 + j $31 + nop + + .set macro + .set reorder + .end f1_c + .size f1_c, .-f1_c + .align 2 + .globl func1_ifunc + .set nomips16 + .set nomicromips + .ent func1_ifunc + .type func1_ifunc, @function +func1_ifunc: + .frame $fp,432,$31 # vars= 400, regs= 2/0, args= 16, gp= 8 + .mask 0xc0000000,-4 + .fmask 0x00000000,0 + .set noreorder + .set nomacro + addiu $sp,$sp,-432 + sw $31,428($sp) + sw $fp,424($sp) + move $fp,$sp + addiu $2,$fp,28 + move $4,$2 + nop + + beq $2,$0,$L8 + nop + + li $2,48 # 0x30 + sw $2,24($fp) + j $L9 + nop + +$L8: + li $2,3 # 0x3 + sw $2,24($fp) +$L9: + lw $2,24($fp) + andi $2,$2,0xf0 + beq $2,$0,$L10 + nop + + lui $2,%hi(f1_a) + addiu $2,$2,%lo(f1_a) + j $L13 + nop + +$L10: + lw $2,24($fp) + andi $2,$2,0xf + beq $2,$0,$L12 + nop + + lui $2,%hi(f1_b) + addiu $2,$2,%lo(f1_b) + j $L13 + nop + +$L12: + lui $2,%hi(f1_c) + addiu $2,$2,%lo(f1_c) +$L13: + move $sp,$fp + lw $31,428($sp) + lw $fp,424($sp) + addiu $sp,$sp,432 + j $31 + nop + + .set macro + .set reorder + .end func1_ifunc + .size func1_ifunc, .-func1_ifunc + .globl func1 + .type func1, @gnu_indirect_function + func1 = func1_ifunc + .ident "GCC: (GNU) 4.9.0 20130930 (experimental)" diff --git a/ld/testsuite/ld-mips-elf/ifunc-static-main.s b/ld/testsuite/ld-mips-elf/ifunc-static-main.s new file mode 100644 index 0000000..2093a42 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-static-main.s @@ -0,0 +1,39 @@ + .file 1 "ifunc_ref_main_1.c" + .section .mdebug.abi32 + .previous + .nan legacy + .gnu_attribute 4, 1 + .abicalls + .option pic0 + .text + .align 2 + .globl main + .set nomips16 + .set nomicromips + .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 + jal func1 + nop + + move $sp,$fp + lw $31,28($sp) + lw $fp,24($sp) + addiu $sp,$sp,32 + j $31 + nop + + .set macro + .set reorder + .end main + .size main, .-main + .ident "GCC: (GNU) 4.9.0 20130930 (experimental)" diff --git a/ld/testsuite/ld-mips-elf/ifunc-static-ref.s b/ld/testsuite/ld-mips-elf/ifunc-static-ref.s new file mode 100644 index 0000000..e17db14 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-static-ref.s @@ -0,0 +1,39 @@ + .file 1 "ifunc_ref.c" + .section .mdebug.abi32 + .previous + .nan legacy + .gnu_attribute 4, 1 + .abicalls + .option pic0 + .text + .align 2 + .globl ref1 + .set nomips16 + .set nomicromips + .ent ref1 + .type ref1, @function +ref1: + .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 + jal func1 + nop + + move $sp,$fp + lw $31,28($sp) + lw $fp,24($sp) + addiu $sp,$sp,32 + j $31 + nop + + .set macro + .set reorder + .end ref1 + .size ref1, .-ref1 + .ident "GCC: (GNU) 4.9.0 20130930 (experimental)" diff --git a/ld/testsuite/ld-mips-elf/ifunc-static.ld b/ld/testsuite/ld-mips-elf/ifunc-static.ld new file mode 100644 index 0000000..ef07ec6 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/ifunc-static.ld @@ -0,0 +1,27 @@ +ENTRY(_start) +SECTIONS +{ + . = 0x80000; + . = ALIGN (0x400); + .iplt : { *(.iplt) } + + . = ALIGN (0x400); + .text : { *(.text) } + + . = ALIGN (0x400); + .igot : { *(.igot) } + + . = ALIGN (0x400); + .got : { *(.got) } + + . = ALIGN (0x400); + .data : { *(.data) } + + . = ALIGN (0x1000); + .rel.dyn : + { + *(.rel.*) + } +/* /DISCARD/ : { *(*) } */ + +} diff --git a/ld/testsuite/ld-mips-elf/libifunc-1-n32.sym b/ld/testsuite/ld-mips-elf/libifunc-1-n32.sym new file mode 100644 index 0000000..88d7e5d --- /dev/null +++ b/ld/testsuite/ld-mips-elf/libifunc-1-n32.sym @@ -0,0 +1,4 @@ +Symbol table for image: + Num Buc: Value Size Type Bind Vis Ndx Name + 3 0: 0000000c 28 FUNC GLOBAL DEFAULT 1 func1_ifunc + 2 0: 0000000c 28 IFUNC GLOBAL DEFAULT 1 func1 diff --git a/ld/testsuite/ld-mips-elf/libifunc-1-n64.sym b/ld/testsuite/ld-mips-elf/libifunc-1-n64.sym new file mode 100644 index 0000000..7236950 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/libifunc-1-n64.sym @@ -0,0 +1,4 @@ +Symbol table for image: + Num Buc: Value Size Type Bind Vis Ndx Name + 3 0: 000000000000000c 28 FUNC GLOBAL DEFAULT 1 func1_ifunc + 2 0: 000000000000000c 28 IFUNC GLOBAL DEFAULT 1 func1 diff --git a/ld/testsuite/ld-mips-elf/libifunc-1-o32.sym b/ld/testsuite/ld-mips-elf/libifunc-1-o32.sym new file mode 100644 index 0000000..b5fff26 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/libifunc-1-o32.sym @@ -0,0 +1,4 @@ +Symbol table for image: + Num Buc: Value Size Type Bind Vis Ndx Name + 3 0: 0000000c 40 FUNC GLOBAL DEFAULT 1 func1_ifunc + 2 0: 0000000c 40 IFUNC GLOBAL DEFAULT 1 func1 diff --git a/ld/testsuite/ld-mips-elf/libifunc-2-n32.sym b/ld/testsuite/ld-mips-elf/libifunc-2-n32.sym new file mode 100644 index 0000000..2c1e84e --- /dev/null +++ b/ld/testsuite/ld-mips-elf/libifunc-2-n32.sym @@ -0,0 +1,4 @@ +Symbol table for image: + Num Buc: Value Size Type Bind Vis Ndx Name + 2 0: 00000000 60 FUNC GLOBAL DEFAULT 1 ref1 + 3 0: 00000040 0 FUNC GLOBAL DEFAULT UND func1 diff --git a/ld/testsuite/ld-mips-elf/libifunc-2-n64.sym b/ld/testsuite/ld-mips-elf/libifunc-2-n64.sym new file mode 100644 index 0000000..3bd53fd --- /dev/null +++ b/ld/testsuite/ld-mips-elf/libifunc-2-n64.sym @@ -0,0 +1,4 @@ +Symbol table for image: + Num Buc: Value Size Type Bind Vis Ndx Name + 2 0: 0000000000000000 60 FUNC GLOBAL DEFAULT 1 ref1 + 3 0: 0000000000000040 0 FUNC GLOBAL DEFAULT UND func1 diff --git a/ld/testsuite/ld-mips-elf/libifunc-2-o32.sym b/ld/testsuite/ld-mips-elf/libifunc-2-o32.sym new file mode 100644 index 0000000..b831edd --- /dev/null +++ b/ld/testsuite/ld-mips-elf/libifunc-2-o32.sym @@ -0,0 +1,5 @@ +Symbol table for image: + Num Buc: Value Size Type Bind Vis Ndx Name + 3 0: 00000000 76 FUNC GLOBAL DEFAULT 1 ref1 + 4 0: 00000050 0 FUNC GLOBAL DEFAULT UND func1 + 2 0: 00000000 0 SECTION GLOBAL DEFAULT ABS _gp_disp diff --git a/ld/testsuite/ld-mips-elf/mips-ifunc.exp b/ld/testsuite/ld-mips-elf/mips-ifunc.exp new file mode 100644 index 0000000..ae389cf --- /dev/null +++ b/ld/testsuite/ld-mips-elf/mips-ifunc.exp @@ -0,0 +1,149 @@ +# Expect script for MIPS IFUNC linker tests +# Copyright 2013 +# Free Software Foundation, Inc. +# +# This file is part of the GNU Binutils. +# +# 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. +# + +if {![istarget mips*-*-*] || ![is_elf_format]} { + return +} + +# General setup +############################################# +set has_newabi [expr [istarget *-*-irix6*] \ + || [istarget mips*-*-linux*] \ + || [istarget mips*-sde-elf*]] +set linux_gnu [expr [istarget mips*-*-linux*]] +set embedded_elf [expr [istarget mips*-*-elf]] + +# Set defaults. +set abi_asflags(o32) "" +set abi_asflags(n32) "-march=from-abi -n32 -EB" +set abi_asflags(n64) "-march=from-abi -64 -EB" +set abi_ldflags(o32) "" +set abi_ldflags(n32) -melf32bmipn32 +set abi_ldflags(n64) -melf64bmip + +# Override as needed. +if { [istarget *-*-irix6*] } { + set abi_asflags(o32) "-32 -EB" + set abi_ldflags(o32) -melf32bsmip +} elseif { [istarget mips64*-linux*] } { + set abi_asflags(o32) "-32 -EB" + set abi_ldflags(o32) -melf32btsmip +} elseif { [istarget mips64*-*freebsd*] } { + set abi_asflags(o32) "-32 -EB" + set abi_ldflags(o32) -melf32btsmip_fbsd +} +if { [istarget mips*-*-linux*] || [istarget mips*-sde-elf*] } { + set abi_ldflags(n32) -melf32btsmipn32 + set abi_ldflags(n64) -melf64btsmip +} elseif { [istarget mips64*-*freebsd*] } { + set abi_ldflags(n32) -melf32btsmipn32_fbsd + set abi_ldflags(n64) -melf64btsmip_fbsd +} +############################################# + + +# STT_GNU_IFUNC testing: +# +# 1. Dso with ifunc defined code +# 2. Dso that references external ifunc'ed routines +# 3. Dynamic executable with ifunc defined code +# 4. Static executable with ifunc defined and referenced code +# 5. Dso with with ifunc defined and referenced code +# 6. Dynamic executable with ifunc defined and referenced code +# STT_GNU_IFUNC tests. +set abis [concat o32 [expr {$has_newabi ? "n32 n64" : ""}]] +foreach { abi } $abis { + run_ld_link_tests [list \ + [list \ + "IFUNC 1 (Simple dso with def) ${abi}" \ + "$abi_ldflags($abi) -shared -T ifunc-dyn.ld" "" \ + "$abi_asflags($abi)" \ + [list ifunc-dyn-def.s] \ + [list "readelf -Ds libifunc-1-${abi}.sym"] \ + "libifunc-1-${abi}.so" \ + ] \ + [list \ + "IFUNC 2 (Simple dso with ref) ${abi}" \ + "$abi_ldflags($abi) -shared -T ifunc-dyn.ld" "" \ + "$abi_asflags($abi)" \ + [list ifunc-dyn-ref.s] \ + [list "readelf -Ds libifunc-2-${abi}.sym"] \ + "libifunc-2-${abi}.so" \ + ] \ + [list \ + "IFUNC 3 (Simple dynamic executable with def) ${abi}" \ + "$abi_ldflags($abi) -Bdynamic -L./tmpdir -lifunc-2-${abi} -T ifunc-dyn.ld" "" \ + "$abi_asflags($abi)" \ + [list ifunc-dyn-main.s ifunc-dyn-def.s] \ + [list "readelf -Ds ifunc-3-${abi}.sym" \ + "readelf -r ifunc-3-${abi}.r" \ + "objdump -dj.iplt ifunc-3-${abi}.t"] \ + "ifunc-3-${abi}" \ + ] \ + [list \ + "IFUNC 4 (Simple static executable with def and ref) ${abi}" \ + "$abi_ldflags($abi) -Bstatic -T ifunc-static.ld" "" \ + "$abi_asflags($abi) -non_shared" \ + [list ifunc-static-main.s ifunc-static-def.s ifunc-static-ref.s] \ + [list "readelf -s ifunc-4-${abi}.sym" \ + "readelf -r ifunc-4-${abi}.r" \ + "objdump -dj.iplt ifunc-4-${abi}.t"] \ + "ifunc-4-${abi}" \ + ] \ + [list \ + "IFUNC 5 (Dynamic shared object with def and ref) ${abi}" \ + "$abi_ldflags($abi) -shared -T ifunc-dyn.ld" "" \ + "$abi_asflags($abi) -KPIC" \ + [list ifunc-dyn-def.s ifunc-dyn-ref.s] \ + [list "readelf -Ds ifunc-5-${abi}.sym" \ + "readelf -r ifunc-5-${abi}.r"] \ + "ifunc-5-${abi}" \ + ] \ + [list \ + "IFUNC 6 (Dynamic executable with def and ref) ${abi}" \ + "$abi_ldflags($abi) -Bdynamic -L./tmpdir -lifunc-2-${abi} -T ifunc-dyn.ld" "" \ + "$abi_asflags($abi)" \ + [list ifunc-dyn-main.s ifunc-dyn-def.s ifunc-dyn-ref.s] \ + [list "readelf -Ds ifunc-6-${abi}.sym" \ + "readelf -r ifunc-6-${abi}.r"] \ + "ifunc-6-${abi}" \ + ] \ + ] +} + +# IPLT sequences change based on how big the address of the +# .igot.plt section is based on Mips loading immediate values. +# +set addrs { "0x400000" "0x400000000" "0x4000000000000" } +foreach { addr } $addrs { + run_ld_link_tests [list \ + [list \ + "IFUNC IPLT (Simple static executable with def and ref) ${addr}" \ + "$abi_ldflags(n64) -Bstatic -Ttext-segment ${addr}" "" \ + "$abi_asflags(n64) -non_shared" \ + [list ifunc-static-main.s ifunc-static-def.s ifunc-static-ref.s] \ + [list "objdump -dj.iplt ifunc-iplt-${addr}.t"] \ + "ifunc-iplt-${addr}" \ + ] \ + ] +} + -- 1.7.9.5