This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH 4/5] xtensa: ld: add tests for static linkage relaxation
- From: Max Filippov <jcmvbkbc at gmail dot com>
- To: binutils at sourceware dot org
- Cc: Sterling Augustine <augustine dot sterling at gmail dot com>, Eric Tsai <erictsai at cadence dot com>, linux-xtensa at linux-xtensa dot org, Max Filippov <jcmvbkbc at gmail dot com>
- Date: Mon, 23 Jul 2018 11:10:29 -0700
- Subject: [PATCH 4/5] xtensa: ld: add tests for static linkage relaxation
- References: <20180723181030.11632-1-jcmvbkbc@gmail.com>
ld/
2018-07-23 Max Filippov <jcmvbkbc@gmail.com>
* testsuite/ld-xtensa/relax-static-defs.s: New file.
* testsuite/ld-xtensa/relax-static-local-pie.d: New file.
* testsuite/ld-xtensa/relax-static-local-shared.d: New file.
* testsuite/ld-xtensa/relax-static-local.s: New file.
* testsuite/ld-xtensa/relax-static-pie.d: New file.
* testsuite/ld-xtensa/relax-static-shared.d: New file.
* testsuite/ld-xtensa/relax-static.s: New file.
* testsuite/ld-xtensa/relax-undef-weak-local-pie.d: New file.
* testsuite/ld-xtensa/relax-undef-weak-local-shared.d: New file.
* testsuite/ld-xtensa/relax-undef-weak-local.s: New file.
* testsuite/ld-xtensa/relax-undef-weak-pie.d: New file.
* testsuite/ld-xtensa/relax-undef-weak-shared.d: New file.
* testsuite/ld-xtensa/relax-undef-weak.s: New file.
* testsuite/ld-xtensa/xtensa.exp: New file.
---
ld/testsuite/ld-xtensa/relax-static-defs.s | 33 +++++++++++++++++++++
ld/testsuite/ld-xtensa/relax-static-local-pie.d | 17 +++++++++++
ld/testsuite/ld-xtensa/relax-static-local-shared.d | 17 +++++++++++
ld/testsuite/ld-xtensa/relax-static-local.s | 19 ++++++++++++
ld/testsuite/ld-xtensa/relax-static-pie.d | 13 +++++++++
ld/testsuite/ld-xtensa/relax-static-shared.d | 15 ++++++++++
ld/testsuite/ld-xtensa/relax-static.s | 9 ++++++
.../ld-xtensa/relax-undef-weak-local-pie.d | 6 ++++
.../ld-xtensa/relax-undef-weak-local-shared.d | 6 ++++
ld/testsuite/ld-xtensa/relax-undef-weak-local.s | 31 ++++++++++++++++++++
ld/testsuite/ld-xtensa/relax-undef-weak-pie.d | 6 ++++
ld/testsuite/ld-xtensa/relax-undef-weak-shared.d | 14 +++++++++
ld/testsuite/ld-xtensa/relax-undef-weak.s | 12 ++++++++
ld/testsuite/ld-xtensa/xtensa.exp | 34 ++++++++++++++++++++++
14 files changed, 232 insertions(+)
create mode 100644 ld/testsuite/ld-xtensa/relax-static-defs.s
create mode 100644 ld/testsuite/ld-xtensa/relax-static-local-pie.d
create mode 100644 ld/testsuite/ld-xtensa/relax-static-local-shared.d
create mode 100644 ld/testsuite/ld-xtensa/relax-static-local.s
create mode 100644 ld/testsuite/ld-xtensa/relax-static-pie.d
create mode 100644 ld/testsuite/ld-xtensa/relax-static-shared.d
create mode 100644 ld/testsuite/ld-xtensa/relax-static.s
create mode 100644 ld/testsuite/ld-xtensa/relax-undef-weak-local-pie.d
create mode 100644 ld/testsuite/ld-xtensa/relax-undef-weak-local-shared.d
create mode 100644 ld/testsuite/ld-xtensa/relax-undef-weak-local.s
create mode 100644 ld/testsuite/ld-xtensa/relax-undef-weak-pie.d
create mode 100644 ld/testsuite/ld-xtensa/relax-undef-weak-shared.d
create mode 100644 ld/testsuite/ld-xtensa/relax-undef-weak.s
create mode 100644 ld/testsuite/ld-xtensa/xtensa.exp
diff --git a/ld/testsuite/ld-xtensa/relax-static-defs.s b/ld/testsuite/ld-xtensa/relax-static-defs.s
new file mode 100644
index 000000000000..cce245215efe
--- /dev/null
+++ b/ld/testsuite/ld-xtensa/relax-static-defs.s
@@ -0,0 +1,33 @@
+ .type fd,@function
+ .globl fd
+
+ .type fh,@function
+ .globl fh
+ .hidden fh
+
+ .type fp,@function
+ .globl fp
+ .protected fp
+
+ .type fi,@function
+ .globl fi
+ .internal fi
+
+ .text
+ .globl _start
+_start:
+ nop
+
+ .section ".text.f"
+ .align 4
+fd:
+ nop
+ .align 4
+fh:
+ nop
+ .align 4
+fp:
+ nop
+ .align 4
+fi:
+ nop
diff --git a/ld/testsuite/ld-xtensa/relax-static-local-pie.d b/ld/testsuite/ld-xtensa/relax-static-local-pie.d
new file mode 100644
index 000000000000..c23e33fca809
--- /dev/null
+++ b/ld/testsuite/ld-xtensa/relax-static-local-pie.d
@@ -0,0 +1,17 @@
+#source: relax-static-local.s
+#source: relax-static-defs.s
+#ld: -pie
+#readelf: -r
+#...
+Relocation section '\.rela\.dyn' .* 6 .*
+#...
+.*R_XTENSA_RELATIVE.*
+.*R_XTENSA_RELATIVE.*
+.*R_XTENSA_RELATIVE.*
+.*R_XTENSA_RELATIVE.*
+.*R_XTENSA_RELATIVE.*
+.*R_XTENSA_RELATIVE.*
+#failif
+#...
+Relocation section '\.rela\.plt' .*
+#...
diff --git a/ld/testsuite/ld-xtensa/relax-static-local-shared.d b/ld/testsuite/ld-xtensa/relax-static-local-shared.d
new file mode 100644
index 000000000000..857789433ceb
--- /dev/null
+++ b/ld/testsuite/ld-xtensa/relax-static-local-shared.d
@@ -0,0 +1,17 @@
+#source: relax-static-local.s
+#source: relax-static-defs.s
+#ld: -shared
+#readelf: -r
+#...
+Relocation section '\.rela\.dyn' .* 6 .*
+#...
+.*R_XTENSA_RELATIVE.*
+.*R_XTENSA_RELATIVE.*
+.*R_XTENSA_RELATIVE.*
+.*R_XTENSA_RELATIVE.*
+.*R_XTENSA_RELATIVE.*
+.*R_XTENSA_RELATIVE.*
+#failif
+#...
+Relocation section '\.rela\.plt' .*
+#...
diff --git a/ld/testsuite/ld-xtensa/relax-static-local.s b/ld/testsuite/ld-xtensa/relax-static-local.s
new file mode 100644
index 000000000000..002cb31a13b6
--- /dev/null
+++ b/ld/testsuite/ld-xtensa/relax-static-local.s
@@ -0,0 +1,19 @@
+ .text
+
+ movi a2, fh@plt
+ movi a2, fp@plt
+ movi a2, fi@plt
+
+ movi a2, fh
+ movi a2, fp
+ movi a2, fi
+
+ .section ".text.a"
+
+ movi a2, fh@plt
+ movi a2, fp@plt
+ movi a2, fi@plt
+
+ movi a2, fh
+ movi a2, fp
+ movi a2, fi
diff --git a/ld/testsuite/ld-xtensa/relax-static-pie.d b/ld/testsuite/ld-xtensa/relax-static-pie.d
new file mode 100644
index 000000000000..ded9c1bf88c7
--- /dev/null
+++ b/ld/testsuite/ld-xtensa/relax-static-pie.d
@@ -0,0 +1,13 @@
+#source: relax-static.s
+#source: relax-static-defs.s
+#ld: -pie
+#readelf: -r
+#...
+Relocation section '\.rela\.dyn' .* 2 .*
+#...
+.*R_XTENSA_RELATIVE.*
+.*R_XTENSA_RELATIVE.*
+#failif
+#...
+Relocation section '\.rela\.plt' .*
+#...
diff --git a/ld/testsuite/ld-xtensa/relax-static-shared.d b/ld/testsuite/ld-xtensa/relax-static-shared.d
new file mode 100644
index 000000000000..a202810765f8
--- /dev/null
+++ b/ld/testsuite/ld-xtensa/relax-static-shared.d
@@ -0,0 +1,15 @@
+#source: relax-static.s
+#source: relax-static-defs.s
+#ld: -shared
+#readelf: -r
+#...
+Relocation section '\.rela\.dyn' .* 3 .*
+#...
+.*R_XTENSA_RTLD.*
+.*R_XTENSA_RTLD.*
+.*R_XTENSA_GLOB_DAT.*fd.*
+#...
+Relocation section '\.rela\.plt' .* 1 .*
+#...
+.*R_XTENSA_JMP_SLOT.*fd.*
+#...
diff --git a/ld/testsuite/ld-xtensa/relax-static.s b/ld/testsuite/ld-xtensa/relax-static.s
new file mode 100644
index 000000000000..727d00a0facd
--- /dev/null
+++ b/ld/testsuite/ld-xtensa/relax-static.s
@@ -0,0 +1,9 @@
+ .text
+
+ movi a2, fd@plt
+ movi a2, fd
+
+ .section ".text.a"
+
+ movi a2, fd@plt
+ movi a2, fd
diff --git a/ld/testsuite/ld-xtensa/relax-undef-weak-local-pie.d b/ld/testsuite/ld-xtensa/relax-undef-weak-local-pie.d
new file mode 100644
index 000000000000..3603b2526067
--- /dev/null
+++ b/ld/testsuite/ld-xtensa/relax-undef-weak-local-pie.d
@@ -0,0 +1,6 @@
+#source: relax-undef-weak-local.s
+#ld: -pie
+#readelf: -r
+#...
+There are no relocations in this file.
+#...
diff --git a/ld/testsuite/ld-xtensa/relax-undef-weak-local-shared.d b/ld/testsuite/ld-xtensa/relax-undef-weak-local-shared.d
new file mode 100644
index 000000000000..2bcf373e7ff9
--- /dev/null
+++ b/ld/testsuite/ld-xtensa/relax-undef-weak-local-shared.d
@@ -0,0 +1,6 @@
+#source: relax-undef-weak-local.s
+#ld: -shared
+#readelf: -r
+#...
+There are no relocations in this file.
+#...
diff --git a/ld/testsuite/ld-xtensa/relax-undef-weak-local.s b/ld/testsuite/ld-xtensa/relax-undef-weak-local.s
new file mode 100644
index 000000000000..93f393e8e949
--- /dev/null
+++ b/ld/testsuite/ld-xtensa/relax-undef-weak-local.s
@@ -0,0 +1,31 @@
+ .type fp,@function
+ .weak fp
+ .protected fp
+
+ .type fh,@function
+ .weak fh
+ .hidden fh
+
+ .type fi,@function
+ .weak fi
+ .internal fi
+
+ .globl _start
+_start:
+ movi a5, fp@plt
+ movi a5, fh@plt
+ movi a5, fi@plt
+
+ movi a6, fp
+ movi a6, fh
+ movi a6, fi
+
+ .section ".text.a"
+a:
+ movi a5, fp@plt
+ movi a5, fh@plt
+ movi a5, fi@plt
+
+ movi a6, fp
+ movi a6, fh
+ movi a6, fi
diff --git a/ld/testsuite/ld-xtensa/relax-undef-weak-pie.d b/ld/testsuite/ld-xtensa/relax-undef-weak-pie.d
new file mode 100644
index 000000000000..3eec8960b78b
--- /dev/null
+++ b/ld/testsuite/ld-xtensa/relax-undef-weak-pie.d
@@ -0,0 +1,6 @@
+#source: relax-undef-weak.s
+#ld: -pie
+#readelf: -r
+#...
+There are no relocations in this file.
+#...
diff --git a/ld/testsuite/ld-xtensa/relax-undef-weak-shared.d b/ld/testsuite/ld-xtensa/relax-undef-weak-shared.d
new file mode 100644
index 000000000000..1d7b20b6b242
--- /dev/null
+++ b/ld/testsuite/ld-xtensa/relax-undef-weak-shared.d
@@ -0,0 +1,14 @@
+#source: relax-undef-weak.s
+#ld: -shared
+#readelf: -r
+#...
+Relocation section '\.rela\.dyn' .* 3 .*
+#...
+.*R_XTENSA_RTLD.*
+.*R_XTENSA_RTLD.*
+.*R_XTENSA_GLOB_DAT.*fd.*
+#...
+Relocation section '\.rela\.plt' .* 1 .*
+#...
+.*R_XTENSA_JMP_SLOT.*fd.*
+#...
diff --git a/ld/testsuite/ld-xtensa/relax-undef-weak.s b/ld/testsuite/ld-xtensa/relax-undef-weak.s
new file mode 100644
index 000000000000..19e99b6b1a2a
--- /dev/null
+++ b/ld/testsuite/ld-xtensa/relax-undef-weak.s
@@ -0,0 +1,12 @@
+ .type fd,@function
+ .weak fd
+
+ .globl _start
+_start:
+ movi a5, fd@plt
+ movi a6, fd
+
+ .section ".text.a"
+a:
+ movi a5, fd@plt
+ movi a6, fd
diff --git a/ld/testsuite/ld-xtensa/xtensa.exp b/ld/testsuite/ld-xtensa/xtensa.exp
new file mode 100644
index 000000000000..cd74be28a08c
--- /dev/null
+++ b/ld/testsuite/ld-xtensa/xtensa.exp
@@ -0,0 +1,34 @@
+# Expect script for ld-xtensa tests
+# Copyright (C) 2008-2018 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 "xtensa*-*-*"]) } {
+ return
+}
+
+run_dump_test "relax-static-pie"
+run_dump_test "relax-static-local-pie"
+run_dump_test "relax-static-shared"
+run_dump_test "relax-static-local-shared"
+
+run_dump_test "relax-undef-weak-pie"
+run_dump_test "relax-undef-weak-local-pie"
+run_dump_test "relax-undef-weak-shared"
+run_dump_test "relax-undef-weak-local-shared"
--
2.11.0