binutils-gdb/ld/testsuite/ld-x86-64/protected-func-1b.c
H.J. Lu b6b4298372 x86-64: Test protected function pointers
On x86-64, function pointers in executable for external funtions may be
resolved to their PLT entries in executable.  If it happens, function
pointers of protected funtions in shared libraries must be resolved to
the PLT entries in executable, not addresses of protected funtions in
shared libraries.

	PR ld/27973
	* testsuite/ld-x86-64/x86-64.exp: Run protected function tests.
	* testsuite/ld-x86-64/protected-func-1.h: New file.
	* testsuite/ld-x86-64/protected-func-1a.s: Likewise.
	* testsuite/ld-x86-64/protected-func-1b.c: Likewise.
2021-06-17 10:26:34 -07:00

36 lines
672 B
C

#include <stdio.h>
#include "protected-func-1.h"
int
protected_func_1b (void)
{
return 3;
}
int
main (void)
{
int res = 0;
/* Check if we get the same address for the protected function symbol. */
if (protected_func_1a != protected_func_1a_p ())
{
puts ("'protected_func_1a' in main and shared library doesn't have same address");
res = 1;
}
/* Check if we get the different addresses for the protected function
symbol. */
if (protected_func_1b == protected_func_1b_p ())
{
puts ("'protected_func_1b' in main and shared library has same address");
res = 1;
}
if (!res)
puts ("PASS");
return res;
}