binutils-gdb/ld/testsuite/ld-elf/pr21964-4.c
H.J. Lu 823143c6ca Check if __start/__stop symbols are referenced by shared objects
Define  __start/__stop symbols if they are referenced by shared objects,
not if they are also defined in shared objects.

bfd/

	PR ld/21964
	* elflink.c (bfd_elf_define_start_stop): Check if __start and
	__stop symbols are referenced by shared objects.

ld/

	PR ld/21964
	* testsuite/ld-elf/pr21964-4.c: New file.
	* testsuite/ld-elf/shared.exp: Run pr21964-4 test on Linux.
2018-01-31 05:10:53 -08:00

23 lines
396 B
C

#define _GNU_SOURCE
#include <dlfcn.h>
#include <stdio.h>
extern int __start___verbose[];
int bar (void)
{
static int my_var __attribute__ ((section("__verbose"), used)) = 6;
int *ptr;
ptr = (int*) dlsym (RTLD_DEFAULT, "__start___verbose");
if (ptr != NULL || __start___verbose[0] != 6)
return -1;
return 0;
}
int
main ()
{
if (bar () == 0)
printf ("PASS\n");
return 0;
}