mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-18 14:53:32 +08:00
Add ifunc-main IFUNC tests
* ld-ifunc/ifunc.exp: Run ifunc-main. * ld-ifunc/ifunc-lib.c: New file. * ld-ifunc/ifunc-main.c: Likewise. * ld-ifunc/ifunc-main.out: Likewise.
This commit is contained in:
parent
7e7cbeb3a2
commit
5f7cbeec7d
@ -1,3 +1,10 @@
|
||||
2014-11-20 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* ld-ifunc/ifunc.exp: Run ifunc-main.
|
||||
* ld-ifunc/ifunc-lib.c: New file.
|
||||
* ld-ifunc/ifunc-main.c: Likewise.
|
||||
* ld-ifunc/ifunc-main.out: Likewise.
|
||||
|
||||
2014-11-20 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* lib/ld-lib.exp (check_ifunc_available): New.
|
||||
|
29
ld/testsuite/ld-ifunc/ifunc-lib.c
Normal file
29
ld/testsuite/ld-ifunc/ifunc-lib.c
Normal file
@ -0,0 +1,29 @@
|
||||
static int
|
||||
one (void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
minus_one (void)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
void * foo_ifunc (void) __asm__ ("foo");
|
||||
__asm__(".type foo, %gnu_indirect_function");
|
||||
|
||||
void *
|
||||
foo_ifunc (void)
|
||||
{
|
||||
return one;
|
||||
}
|
||||
|
||||
void * bar_ifunc (void) __asm__ ("bar");
|
||||
__asm__(".type bar, %gnu_indirect_function");
|
||||
|
||||
void *
|
||||
bar_ifunc (void)
|
||||
{
|
||||
return minus_one;
|
||||
}
|
29
ld/testsuite/ld-ifunc/ifunc-main.c
Normal file
29
ld/testsuite/ld-ifunc/ifunc-main.c
Normal file
@ -0,0 +1,29 @@
|
||||
#include <stdio.h>
|
||||
|
||||
extern int foo(void);
|
||||
extern int bar(void);
|
||||
|
||||
int (*foo_ptr)(void) = foo;
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
int (*bar_ptr)(void) = bar;
|
||||
if (bar_ptr != bar)
|
||||
__builtin_abort ();
|
||||
if (bar_ptr() != -1)
|
||||
__builtin_abort ();
|
||||
if (bar() != -1)
|
||||
__builtin_abort ();
|
||||
|
||||
if (foo_ptr != foo)
|
||||
__builtin_abort ();
|
||||
if (foo_ptr() != 1)
|
||||
__builtin_abort ();
|
||||
if (foo() != 1)
|
||||
__builtin_abort ();
|
||||
|
||||
printf ("OK\n");
|
||||
|
||||
return 0;
|
||||
}
|
1
ld/testsuite/ld-ifunc/ifunc-main.out
Normal file
1
ld/testsuite/ld-ifunc/ifunc-main.out
Normal file
@ -0,0 +1 @@
|
||||
OK
|
@ -418,6 +418,17 @@ if { ![check_ifunc_available] } {
|
||||
return
|
||||
}
|
||||
|
||||
run_cc_link_tests [list \
|
||||
[list \
|
||||
"Build ifunc-lib.so" \
|
||||
"-shared" \
|
||||
"-fPIC" \
|
||||
{ ifunc-lib.c } \
|
||||
{} \
|
||||
"libifunc-lib.so" \
|
||||
] \
|
||||
]
|
||||
|
||||
run_ld_link_exec_tests [] [list \
|
||||
[list \
|
||||
"Run pr16467" \
|
||||
@ -428,4 +439,21 @@ run_ld_link_exec_tests [] [list \
|
||||
"pr16467.out" \
|
||||
"" \
|
||||
] \
|
||||
[list \
|
||||
"Run ifunc-main" \
|
||||
"tmpdir/libifunc-lib.so" \
|
||||
"" \
|
||||
{ ifunc-main.c } \
|
||||
"ifunc-main" \
|
||||
"ifunc-main.out" \
|
||||
] \
|
||||
[list \
|
||||
"Run ifunc-main with -fpic" \
|
||||
"tmpdir/libifunc-lib.so" \
|
||||
"" \
|
||||
{ ifunc-main.c } \
|
||||
"ifunc-main" \
|
||||
"ifunc-main.out" \
|
||||
"-fpic" \
|
||||
] \
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user