This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Define __start/__stop symbols when there is only a dynamic def
On Fri, Jan 26, 2018 at 06:07:20PM -0800, H.J. Lu wrote:
> testsuite/ld-elf/pr21964-1a.c testsuite/ld-elf/pr21964-2a.c
> testsuite/ld-elf/pr21964-1b.c testsuite/ld-elf/pr21964-2b.c
> testsuite/ld-elf/pr21964-1c.c testsuite/ld-elf/pr21964-2c.c
>
> in binutils source tree? They pass without Alan's patch.
Another __start/__stop testcase. It's probably a bug that the test
needs -E.
* testsuite/ld-elf/pr21964-3a.c: New file.
* testsuite/ld-elf/pr21964-3c.c: New file.
* testsuite/ld-elf/shared.exp: Run new __start/__stop testcase.
diff --git a/ld/testsuite/ld-elf/pr21964-3a.c b/ld/testsuite/ld-elf/pr21964-3a.c
new file mode 100644
index 0000000..835040e
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr21964-3a.c
@@ -0,0 +1,11 @@
+extern int __start___verbose[];
+extern int __stop___verbose[];
+int
+foo3 (void)
+{
+ if (__start___verbose == __stop___verbose
+ || __start___verbose[0] != 6)
+ return -1;
+ else
+ return 0;
+}
diff --git a/ld/testsuite/ld-elf/pr21964-3c.c b/ld/testsuite/ld-elf/pr21964-3c.c
new file mode 100644
index 0000000..5b750d1
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr21964-3c.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+
+extern int foo1 (void);
+extern int foo2 (void);
+extern int foo3 (void);
+
+static int my_var __attribute__((used, section("__verbose"))) = 6;
+
+int
+main ()
+{
+ if (foo1 () == 0
+ && foo2 () == 0
+ && foo3 () == 0)
+ printf ("PASS\n");
+ return 0;
+}
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index 5c4d78a..e4729ce 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -565,6 +565,9 @@ set build_tests {
{"Build pr21964-2b.so"
"-shared" "-fPIC"
{pr21964-2b.c} {} "pr21964-2b.so"}
+ {"Build pr21964-3a.so"
+ "-shared" "-fPIC"
+ {pr21964-3a.c} {} "pr21964-3a.so"}
{"Dump pr21978.so"
"-shared" "-fPIC -g -O2"
{pr21978a.c pr21978b.c} {{objdump {-Sl} pr21978.od}} "pr21978.so"}
@@ -701,6 +704,9 @@ set run_tests [list \
[list "Run pr21964-1" \
"-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-1a.so tmpdir/pr21964-1b.so" "" \
{pr21964-1c.c} "pr21964-1" "pass.out" ] \
+ [list "Run pr21964-3" \
+ "-Wl,--no-as-needed,-rpath,tmpdir,-E tmpdir/pr21964-1a.so tmpdir/pr21964-1b.so tmpdir/pr21964-3a.so" "" \
+ {pr21964-3c.c} "pr21964-3" "pass.out" ] \
]
# NetBSD ELF systems do not currently support the .*_array sections.
--
Alan Modra
Australia Development Lab, IBM