+2017-08-21 Alan Modra <amodra@gmail.com>
+ H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/21964
+ * elf-bfd.h (SYMBOLIC_BIND): Return TRUE for __start/__stop symbols.
+ * elflink.c (bfd_elf_define_start_stop): Rewrite.
+
2017-08-21 Hans-Peter Nilsson <hp@bitrange.com>
PR ld/20125
library, if any. A unique symbol can never be bound locally. */
#define SYMBOLIC_BIND(INFO, H) \
(!(H)->unique_global \
- && ((INFO)->symbolic || ((INFO)->dynamic && !(H)->dynamic)))
+ && ((INFO)->symbolic \
+ || (H)->start_stop \
+ || ((INFO)->dynamic && !(H)->dynamic)))
#ifdef __cplusplus
}
bfd_elf_define_start_stop (struct bfd_link_info *info,
const char *symbol, asection *sec)
{
- struct bfd_link_hash_entry *h;
+ struct elf_link_hash_entry *h;
- h = bfd_generic_define_start_stop (info, symbol, sec);
- if (h != NULL)
+ h = elf_link_hash_lookup (elf_hash_table (info), symbol,
+ FALSE, FALSE, TRUE);
+ if (h != NULL
+ && (h->root.type == bfd_link_hash_undefined
+ || h->root.type == bfd_link_hash_undefweak
+ || (h->ref_regular && !h->def_regular)))
{
- struct elf_link_hash_entry *eh = (struct elf_link_hash_entry *) h;
- eh->start_stop = 1;
- eh->u2.start_stop_section = sec;
- _bfd_elf_link_hash_hide_symbol (info, eh, TRUE);
- if (ELF_ST_VISIBILITY (eh->other) != STV_INTERNAL)
- eh->other = ((eh->other & ~ELF_ST_VISIBILITY (-1))
- | STV_HIDDEN);
+ h->root.type = bfd_link_hash_defined;
+ h->root.u.def.section = sec;
+ h->root.u.def.value = 0;
+ h->def_regular = 1;
+ h->def_dynamic = 0;
+ h->start_stop = 1;
+ h->u2.start_stop_section = sec;
+ if (symbol[0] == '.')
+ {
+ /* .startof. and .sizeof. symbols are local. */
+ _bfd_elf_link_hash_hide_symbol (info, h, TRUE);
+ }
+ else if (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
+ h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_PROTECTED;
+ return &h->root;
}
- return h;
+ return NULL;
}
+2017-08-21 H.J. Lu <hongjiu.lu@intel.com>
+ Alan Modra <amodra@gmail.com>
+
+ PR ld/21964
+ * testsuite/ld-elf/pr21562a.d: Update for changed start/stop symbols.
+ * testsuite/ld-elf/pr21562b.d: Likewise.
+ * testsuite/ld-elf/pr21562c.d: Likewise.
+ * testsuite/ld-elf/pr21562d.d: Likewise.
+ * testsuite/ld-elf/pr21562e.d: Likewise.
+ * testsuite/ld-elf/pr21562f.d: Likewise.
+ * testsuite/ld-elf/pr21562g.d: Likewise.
+ * testsuite/ld-elf/pr21562h.d: Likewise.
+ * testsuite/ld-elf/pr21562i.d: Likewise.
+ * testsuite/ld-elf/pr21562j.d: Likewise.
+ * testsuite/ld-elf/pr21562k.d: Likewise.
+ * testsuite/ld-elf/pr21562l.d: Likewise.
+ * testsuite/ld-elf/pr21562m.d: Likewise.
+ * testsuite/ld-elf/pr21562n.d: Likewise.
+ * testsuite/ld-elf/sizeofa.d: Likewise.
+ * testsuite/ld-elf/sizeofb.d: Likewise.
+ * testsuite/ld-elf/startofa.d: Likewise.
+ * testsuite/ld-elf/startofb.d: Likewise.
+ * testsuite/ld-gc/pr20022.d: Likewise.
+ * testsuite/ld-gc/start.d: Likewise.
+ * testsuite/ld-elf/pr21964-1a.c: New file.
+ * testsuite/ld-elf/pr21964-1b.c: New file.
+ * testsuite/ld-elf/pr21964-2a.c: New file.
+ * testsuite/ld-elf/pr21964-2b.c: New file.
+ * testsuite/ld-elf/shared.exp: Run PR ld/21964 tests.
+
2017-08-21 Hans-Peter Nilsson <hp@bitrange.com>
PR ld/20125
#...
\[[ 0-9]+\] scnfoo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +0*10[ \t]+.*
#...
- +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +___?start_scnfoo
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +GLOBAL +PROTECTED +[0-9]+ +___?start_scnfoo
#pass
#...
\[[ 0-9]+\] scnfoo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +0*10[ \t]+.*
#...
- +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +___?stop_scnfoo
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +GLOBAL +PROTECTED +[0-9]+ +___?stop_scnfoo
#pass
#...
\[[ 0-9]+\] scnfoo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +0*10[ \t]+.*
#...
- +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +___?start_scnfoo
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +GLOBAL +PROTECTED +[0-9]+ +___?start_scnfoo
#pass
#...
\[[ 0-9]+\] scnfoo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +0*10[ \t]+.*
#...
- +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +___?stop_scnfoo
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +GLOBAL +PROTECTED +[0-9]+ +___?stop_scnfoo
#pass
#...
\[[ 0-9]+\] scnfoo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +0*10[ \t]+.*
#...
- +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +___?start_scnfoo
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +GLOBAL +PROTECTED +[0-9]+ +___?start_scnfoo
#pass
#...
\[[ 0-9]+\] scnfoo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +0*10[ \t]+.*
#...
- +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +___?stop_scnfoo
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +GLOBAL +PROTECTED +[0-9]+ +___?stop_scnfoo
#pass
#...
\[[ 0-9]+\] scnfoo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +0*10[ \t]+.*
#...
- +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +___?start_scnfoo
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +GLOBAL +PROTECTED +[0-9]+ +___?start_scnfoo
#pass
#...
\[[ 0-9]+\] scnfoo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +0*10[ \t]+.*
#...
- +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +___?stop_scnfoo
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +GLOBAL +PROTECTED +[0-9]+ +___?stop_scnfoo
#pass
#...
\[[ 0-9]+\] scnfoo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +0*10[ \t]+.*
#...
- +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +___?start_scnfoo
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +GLOBAL +PROTECTED +[0-9]+ +___?start_scnfoo
#pass
#...
\[[ 0-9]+\] scnfoo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +0*10[ \t]+.*
#...
- +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +___?stop_scnfoo
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +GLOBAL +PROTECTED +[0-9]+ +___?stop_scnfoo
#pass
#...
\[[ 0-9]+\] \.foo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +0*10[ \t]+.*
#...
- +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +___?start_scnfoo
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +GLOBAL +PROTECTED +[0-9]+ +___?start_scnfoo
#pass
#...
\[[ 0-9]+\] \.foo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +0*10[ \t]+.*
#...
- +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +___?stop_scnfoo
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +GLOBAL +PROTECTED +[0-9]+ +___?stop_scnfoo
#pass
#...
\[[ 0-9]+\] \.foo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +0*10[ \t]+.*
#...
- +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +___?start_scnfoo
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +GLOBAL +PROTECTED +[0-9]+ +___?start_scnfoo
#pass
#...
\[[ 0-9]+\] \.foo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +0*10[ \t]+.*
#...
- +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +___?stop_scnfoo
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +GLOBAL +PROTECTED +[0-9]+ +___?stop_scnfoo
#pass
--- /dev/null
+extern int __start___verbose[];
+extern int __stop___verbose[];
+int foo (void)
+{
+ static int my_var __attribute__((used, section("__verbose"))) = 5;
+ if (__start___verbose == __stop___verbose
+ || __start___verbose[0] != 5)
+ return -1;
+ else
+ return 0;
+}
--- /dev/null
+#include <stdio.h>
+
+extern int foo (void);
+
+extern int __start___verbose[];
+extern int __stop___verbose[];
+static int my_var __attribute__((used, section("__verbose"))) = 6;
+int bar (void)
+{
+ if (__start___verbose == __stop___verbose)
+ return -1;
+
+ if (__start___verbose[0] != 6)
+ return -2;
+ else
+ return 0;
+}
+
+int main()
+{
+ if (bar () == 0 && foo () == 0)
+ printf ("PASS\n");
+ return 0;
+}
--- /dev/null
+extern int __start___verbose[];
+extern int __stop___verbose[];
+int foo (void)
+{
+ static int my_var __attribute__((used, section("__verbose"))) = 5;
+ if (__start___verbose == __stop___verbose
+ && __start___verbose[0] != 5)
+ return -1;
+ else
+ return 0;
+}
--- /dev/null
+#include <dlfcn.h>
+#include <stdio.h>
+
+int main()
+{
+ void *dl;
+ void *sym;
+ int (*func) (void);
+
+ dl = dlopen("pr21964-2.so", RTLD_LAZY);
+ if (!dl)
+ return 1;
+
+ sym = dlsym(dl, "__start___verbose");
+ if (!sym)
+ return 2;
+
+ func = dlsym(dl, "foo");
+ if (!func)
+ return 3;
+ if (func () == 0)
+ printf ("PASS\n");
+
+ dlclose(dl);
+
+ return 0;
+}
{"Build libpr19073.so"
"-shared -Wl,--version-script=pr19073.map tmpdir/pr19073a.o" "-fPIC"
{dummy.c} {{readelf {--dyn-syms --wide} pr19073.rd}} "libpr19073.so"}
+ {"Build pr21964-1.so"
+ "-shared" "-fPIC"
+ {pr21964-1a.c} {} "pr21964-1.so"}
+ {"Build pr21964-2.so"
+ "-shared" "-fPIC"
+ {pr21964-2a.c} {} "pr21964-2.so"}
}
run_cc_link_tests $build_tests
[list "Run pr18458" \
"-Wl,--no-as-needed,-z,now tmpdir/libpr18458a.so tmpdir/libpr18458b.so" "" \
{pr18458c.c} "pr18458" "pass.out" ] \
+ [list "Run pr21964-1" \
+ "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-1.so" "" \
+ {pr21964-1b.c} "pr21964-1" "pass.out" ] \
]
# NetBSD ELF systems do not currently support the .*_array sections.
[list "Run dl6d1 with --dynamic-list-data and dlopen on libdl6d.so" \
"-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
{dl6dmain.c} "dl6d1" "dl6b.out" ] \
+ [list "Run pr21964-2" \
+ "-Wl,--no-as-needed,-rpath,tmpdir $extralibs" "" \
+ {pr21964-2b.c} "pr21964-2" "pass.out" ] \
]
# Only run them when libdl is available.
+Num: +Value +Size Type +Bind +Vis +Ndx Name
+0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND +
#...
- +[0-9]+: +[a-f0-9]+ +0 +(NOTYPE|OBJECT) +(LOC|GLOB)AL +DEFAULT +[0-9]+ +___?stop_scnfoo
+ +[0-9]+: +[a-f0-9]+ +0 +(NOTYPE|OBJECT) +GLOBAL +(PROTECTED|DEFAULT) +[0-9]+ +___?stop_scnfoo
#...
+[0-9]+: +[a-f0-9]+ +0 +(NOTYPE|OBJECT) +GLOBAL +DEFAULT +UND +.sizeof.scnfoo
#pass
+Num: +Value +Size Type +Bind +Vis +Ndx Name
+0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND +
#...
- +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +LOCAL +DEFAULT +[0-9]+ +___?stop_scnfoo
-#...
- +[0-9]+: 0+10 + +0 +NOTYPE +LOCAL +DEFAULT +ABS +.sizeof.scnfoo
+ +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +PROTECTED +[0-9]+ +___?stop_scnfoo
#pass
+Num: +Value +Size Type +Bind +Vis +Ndx Name
+0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND +
#...
- +[0-9]+: +[a-f0-9]+ +0 +(NOTYPE|OBJECT) +(LOCAL +DEFAULT +[0-9]+ +___?start_scnfoo|GLOBAL +DEFAULT +UND +.startof.scnfoo)
+ +[0-9]+: +[a-f0-9]+ +0 +(NOTYPE|OBJECT) +GLOBAL +DEFAULT +UND +.startof.scnfoo
#...
- +[0-9]+: +[a-f0-9]+ +0 +(NOTYPE|OBJECT) +GLOBAL +DEFAULT +(UND +.startof.scnfoo|[0-9]+ +___?start_scnfoo)
+ +[0-9]+: +[a-f0-9]+ +0 +(NOTYPE|OBJECT) +GLOBAL +(PROTECTED|DEFAULT) +[0-9]+ +___?start_scnfoo
#pass
+Num: +Value +Size Type +Bind +Vis +Ndx Name
+0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND +
#...
- +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +LOCAL +DEFAULT +[0-9]+ +.startof.scnfoo
-#...
- +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +LOCAL +DEFAULT +[0-9]+ +___?start_scnfoo
+ +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +PROTECTED +[0-9]+ +___?start_scnfoo
#pass
#...
\[[ 0-9]+\] _foo[ \t]+PROGBITS[ \t]+[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+[ \t]+.*
#...
- +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +__start__foo
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +GLOBAL +PROTECTED +[0-9]+ +__start__foo
#pass
#notarget: *-*-*aout *-*-*oldld frv-*-linux* metag-*-linux*
#...
-[0-9a-f]+ d +__start__foo
+[0-9a-f]+ D +__start__foo
#...