mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-23 01:33:36 +08:00
Add more IFUNC tests.
Mostly tests around not-exported IFUNC functions, IFUNC in statically linked binaries and PIEs, etc.
This commit is contained in:
parent
ccab6d8f73
commit
3c30afc862
58
ChangeLog
58
ChangeLog
@ -1,3 +1,61 @@
|
||||
2009-06-19 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* elf/Makefile (distribute): Add ifuncmain1staticpie.c,
|
||||
ifuncmain5.c, ifuncmain5pic.c, ifuncmain5picstatic.c,
|
||||
ifuncmain5pie.c, ifuncmain5static.c, ifuncmain5staticpic.c,
|
||||
ifuncdep5.c, ifuncdep5pic.c, ifuncmod5.c, ifuncmain7.c,
|
||||
ifuncmain7pic.c, ifuncmain7picstatic.c, ifuncmain7pie.c, and
|
||||
ifuncmain7static.c.
|
||||
(tests-static): Add ifuncmain5static, ifuncmain5picstatic,
|
||||
ifuncmain7static, and ifuncmain7picstatic.
|
||||
(tests): Also depend on $(objpfx)ifuncmain1staticpie.out,
|
||||
$(objpfx)ifuncmain5pie.out, $(objpfx)ifuncmain6pie.out, and
|
||||
$(objpfx)ifuncmain7pie.out.
|
||||
(modules-names): Add ifuncmod5 ifuncmod6
|
||||
(ifuncmod5.so-no-z-defs): Define.
|
||||
(ifuncmod6.so-no-z-defs): Define.
|
||||
(CFLAGS-ifuncmain5pic.c): Define.
|
||||
(CFLAGS-ifuncmain5picstatic.c): Define.
|
||||
(CFLAGS-ifuncmain5staticpic.c): Define.
|
||||
(CFLAGS-ifuncdep5pic.c): Define.
|
||||
(CFLAGS-ifuncmain7pic.c): Define.
|
||||
(CFLAGS-ifuncmain7picstatic.c): Define.
|
||||
(CFLAGS-ifuncmain1staticpie.c): Define.
|
||||
(CFLAGS-ifuncmain5pie.c): Define.
|
||||
(CFLAGS-ifuncmain6pie.c): Define.
|
||||
(CFLAGS-ifuncmain7pie.c): Define.
|
||||
($(objpfx)ifuncmain1staticpie.out): Define.
|
||||
($(objpfx)ifuncmain1staticpie): Define.
|
||||
($(objpfx)ifuncmain5pie.out): Define.
|
||||
($(objpfx)ifuncmain5pie): Define.
|
||||
($(objpfx)ifuncmain6pie.out): Define.
|
||||
($(objpfx)ifuncmain6pie): Define.
|
||||
($(objpfx)ifuncmain5): Define.
|
||||
($(objpfx)ifuncmain5pic): Define.
|
||||
($(objpfx)ifuncmain5static): Define.
|
||||
($(objpfx)ifuncmain5staticpic): Define.
|
||||
($(objpfx)ifuncmain5picstatic): Define.
|
||||
(generated): Add ifuncmain1staticpie, ifuncmain1staticpie.out,
|
||||
ifuncmain5pie, ifuncmain5pie.out, ifuncmain6pie, and
|
||||
ifuncmain6pie.out.
|
||||
* elf/b/elf/ifuncmain1staticpie.c: New file.
|
||||
* elf/ifuncdep5.c: New file.
|
||||
* elf/ifuncdep5pic.c: New file.
|
||||
* elf/ifuncmain5.c: New file.
|
||||
* elf/ifuncmain5pic.c: New file.
|
||||
* elf/ifuncmain5picstatic.c: New file.
|
||||
* elf/ifuncmain5pie.c: New file.
|
||||
* elf/ifuncmain5static.c: New file.
|
||||
* elf/ifuncmain5staticpic.c: New file.
|
||||
* elf/ifuncmain6pie.c: New file.
|
||||
* elf/ifuncmain7.c: New file.
|
||||
* elf/ifuncmain7pic.c: New file.
|
||||
* elf/ifuncmain7picstatic.c: New file.
|
||||
* elf/ifuncmain7pie.c: New file.
|
||||
* elf/ifuncmain7static.c: New file.
|
||||
* elf/ifuncmod5.c: New file.
|
||||
* elf/ifuncmod6.c: New file.
|
||||
|
||||
2009-06-20 Ulrich Drepper <drepper@redhat.com>
|
||||
|
||||
[BZ #10085]
|
||||
|
82
elf/Makefile
82
elf/Makefile
@ -99,10 +99,18 @@ distribute := rtld-Rules \
|
||||
ifuncmain1staticpic.c ifuncmain1picstatic.c \
|
||||
ifuncdep1.c ifuncdep1pic.c ifuncmod1.c \
|
||||
ifuncmain1pie.c ifuncmain1vispie.c \
|
||||
ifuncmain1staticpie.c \
|
||||
ifuncmain2.c ifuncmain2static.c ifuncdep2.c \
|
||||
ifuncmain2pic.c ifuncmain2picstatic.c ifuncdep2pic.c \
|
||||
ifuncmain3.c ifuncmod3.c \
|
||||
ifuncmain4.c ifuncmain4static.c ifuncmain4picstatic.c
|
||||
ifuncmain4.c ifuncmain4static.c ifuncmain4picstatic.c \
|
||||
ifuncmain5.c ifuncmain5pic.c ifuncmain5picstatic.c \
|
||||
ifuncmain5pie.c ifuncmain5static.c \
|
||||
ifuncmain5staticpic.c \
|
||||
ifuncdep5.c ifuncdep5pic.c ifuncmod5.c \
|
||||
ifuncmain6pie.c ifuncmod6.c \
|
||||
ifuncmain7.c ifuncmain7pic.c ifuncmain7picstatic.c \
|
||||
ifuncmain7pie.c ifuncmain7static.c
|
||||
|
||||
CFLAGS-dl-runtime.c = -fexceptions -fasynchronous-unwind-tables
|
||||
CFLAGS-dl-lookup.c = -fexceptions -fasynchronous-unwind-tables
|
||||
@ -244,16 +252,22 @@ modules-names-nobuild := filtmod1
|
||||
ifeq (yes,$(multi-arch))
|
||||
tests-static += ifuncmain1static ifuncmain1picstatic \
|
||||
ifuncmain2static ifuncmain2picstatic \
|
||||
ifuncmain4static ifuncmain4picstatic
|
||||
ifuncmain4static ifuncmain4picstatic \
|
||||
ifuncmain5static ifuncmain5picstatic \
|
||||
ifuncmain7static ifuncmain7picstatic
|
||||
|
||||
ifeq (yes,$(build-shared))
|
||||
tests += ifuncmain1 ifuncmain1pic ifuncmain1vis ifuncmain1vispic \
|
||||
ifuncmain1staticpic \
|
||||
ifuncmain2 ifuncmain2pic ifuncmain3 ifuncmain4
|
||||
ifuncmain2 ifuncmain2pic ifuncmain3 ifuncmain4 \
|
||||
ifuncmain5 ifuncmain5pic ifuncmain5staticpic \
|
||||
ifuncmain7 ifuncmain7pic
|
||||
ifeq (yes,$(have-fpie))
|
||||
tests: $(objpfx)ifuncmain1pie.out $(objpfx)ifuncmain1vispie.out
|
||||
tests: $(objpfx)ifuncmain1pie.out $(objpfx)ifuncmain1vispie.out \
|
||||
$(objpfx)ifuncmain1staticpie.out $(objpfx)ifuncmain5pie.out \
|
||||
$(objpfx)ifuncmain6pie.out $(objpfx)ifuncmain7pie.out
|
||||
endif
|
||||
modules-names += ifuncmod1 ifuncmod3
|
||||
modules-names += ifuncmod1 ifuncmod3 ifuncmod5 ifuncmod6
|
||||
endif
|
||||
endif
|
||||
|
||||
@ -530,6 +544,8 @@ reldep9mod1.so-no-z-defs = yes
|
||||
unload3mod4.so-no-z-defs = yes
|
||||
unload4mod1.so-no-z-defs = yes
|
||||
ifuncmod1.so-no-z-defs = yes
|
||||
ifuncmod5.so-no-z-defs = yes
|
||||
ifuncmod6.so-no-z-defs = yes
|
||||
|
||||
ifeq ($(build-shared),yes)
|
||||
# Build all the modules even when not actually running test programs.
|
||||
@ -980,12 +996,22 @@ CFLAGS-ifuncmain2pic.c += $(pic-ccflag)
|
||||
CFLAGS-ifuncmain2picstatic.c += $(pic-ccflag)
|
||||
CFLAGS-ifuncdep2pic.c += $(pic-ccflag)
|
||||
CFLAGS-ifuncmain4picstatic.c += $(pic-ccflag)
|
||||
CFLAGS-ifuncmain5pic.c += $(pic-ccflag)
|
||||
CFLAGS-ifuncmain5picstatic.c += $(pic-ccflag)
|
||||
CFLAGS-ifuncmain5staticpic.c += $(pic-ccflag)
|
||||
CFLAGS-ifuncdep5pic.c += $(pic-ccflag)
|
||||
CFLAGS-ifuncmain7pic.c += $(pic-ccflag)
|
||||
CFLAGS-ifuncmain7picstatic.c += $(pic-ccflag)
|
||||
|
||||
LDFLAGS-ifuncmain3 = -Wl,-export-dynamic
|
||||
|
||||
ifeq (yesyes,$(have-fpie)$(build-shared))
|
||||
CFLAGS-ifuncmain1pie.c += $(pie-ccflag)
|
||||
CFLAGS-ifuncmain1vispie.c += $(pie-ccflag)
|
||||
CFLAGS-ifuncmain1staticpie.c += $(pie-ccflag)
|
||||
CFLAGS-ifuncmain5pie.c += $(pie-ccflag)
|
||||
CFLAGS-ifuncmain6pie.c += $(pie-ccflag)
|
||||
CFLAGS-ifuncmain7pie.c += $(pie-ccflag)
|
||||
|
||||
$(objpfx)ifuncmain1pie.out: $(objpfx)ifuncmain1pie
|
||||
$(elf-objpfx)$(rtld-installed-name) \
|
||||
@ -997,6 +1023,16 @@ $(objpfx)ifuncmain1pie: $(objpfx)ifuncmain1pie.o $(objpfx)ifuncmod1.so
|
||||
|
||||
generated += ifuncmain1pie ifuncmain1pie.out
|
||||
|
||||
$(objpfx)ifuncmain1staticpie.out: $(objpfx)ifuncmain1staticpie
|
||||
$(elf-objpfx)$(rtld-installed-name) \
|
||||
--library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
|
||||
$< > $@
|
||||
|
||||
$(objpfx)ifuncmain1staticpie: $(objpfx)ifuncmain1staticpie.o $(objpfx)ifuncdep1pic.o
|
||||
$(+link-pie)
|
||||
|
||||
generated += ifuncmain1staticpie ifuncmain1staticpie.out
|
||||
|
||||
$(objpfx)ifuncmain1vispie.out: $(objpfx)ifuncmain1vispie
|
||||
$(elf-objpfx)$(rtld-installed-name) \
|
||||
--library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
|
||||
@ -1006,6 +1042,36 @@ $(objpfx)ifuncmain1vispie: $(objpfx)ifuncmain1vispie.o $(objpfx)ifuncmod1.so
|
||||
$(+link-pie)
|
||||
|
||||
generated += ifuncmain1vispie ifuncmain1vispie.out
|
||||
|
||||
$(objpfx)ifuncmain5pie.out: $(objpfx)ifuncmain5pie
|
||||
$(elf-objpfx)$(rtld-installed-name) \
|
||||
--library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
|
||||
$< > $@
|
||||
|
||||
$(objpfx)ifuncmain5pie: $(objpfx)ifuncmain5pie.o $(objpfx)ifuncmod5.so
|
||||
$(+link-pie)
|
||||
|
||||
generated += ifuncmain5pie ifuncmain5pie.out
|
||||
|
||||
$(objpfx)ifuncmain6pie.out: $(objpfx)ifuncmain6pie
|
||||
$(elf-objpfx)$(rtld-installed-name) \
|
||||
--library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
|
||||
$< > $@
|
||||
|
||||
$(objpfx)ifuncmain6pie: $(objpfx)ifuncmain6pie.o $(objpfx)ifuncmod6.so
|
||||
$(+link-pie)
|
||||
|
||||
generated += ifuncmain6pie ifuncmain6pie.out
|
||||
|
||||
$(objpfx)ifuncmain7pie.out: $(objpfx)ifuncmain7pie
|
||||
$(elf-objpfx)$(rtld-installed-name) \
|
||||
--library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
|
||||
$< > $@
|
||||
|
||||
$(objpfx)ifuncmain7pie: $(objpfx)ifuncmain7pie.o
|
||||
$(+link-pie)
|
||||
|
||||
generated += ifuncmain7pie ifuncmain7pie.out
|
||||
endif
|
||||
|
||||
$(objpfx)ifuncmain1: $(addprefix $(objpfx),ifuncmod1.so)
|
||||
@ -1022,3 +1088,9 @@ $(objpfx)ifuncmain2picstatic: $(addprefix $(objpfx),ifuncdep2pic.o)
|
||||
|
||||
$(objpfx)ifuncmain3: $(libdl)
|
||||
$(objpfx)ifuncmain3.out: $(objpfx)ifuncmod3.so
|
||||
|
||||
$(objpfx)ifuncmain5: $(addprefix $(objpfx),ifuncmod5.so)
|
||||
$(objpfx)ifuncmain5pic: $(addprefix $(objpfx),ifuncmod5.so)
|
||||
$(objpfx)ifuncmain5static: $(addprefix $(objpfx),ifuncdep5.o)
|
||||
$(objpfx)ifuncmain5staticpic: $(addprefix $(objpfx),ifuncdep5pic.o)
|
||||
$(objpfx)ifuncmain5picstatic: $(addprefix $(objpfx),ifuncdep5pic.o)
|
||||
|
3
elf/ifuncdep5.c
Normal file
3
elf/ifuncdep5.c
Normal file
@ -0,0 +1,3 @@
|
||||
/* Test STT_GNU_IFUNC symbols without -fPIC. */
|
||||
|
||||
#include "ifuncmod5.c"
|
3
elf/ifuncdep5pic.c
Normal file
3
elf/ifuncdep5pic.c
Normal file
@ -0,0 +1,3 @@
|
||||
/* Test STT_GNU_IFUNC symbols with -fPIC. */
|
||||
|
||||
#include "ifuncmod5.c"
|
3
elf/ifuncmain1staticpie.c
Normal file
3
elf/ifuncmain1staticpie.c
Normal file
@ -0,0 +1,3 @@
|
||||
/* Test STT_GNU_IFUNC symbols with PIE and no DSO. */
|
||||
|
||||
#include "ifuncmain1.c"
|
40
elf/ifuncmain5.c
Normal file
40
elf/ifuncmain5.c
Normal file
@ -0,0 +1,40 @@
|
||||
/* Test STT_GNU_IFUNC symbols with dynamic function pointer only. */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
int global = -1;
|
||||
|
||||
extern int foo (void);
|
||||
extern int foo_protected (void);
|
||||
|
||||
typedef int (*foo_p) (void);
|
||||
|
||||
foo_p
|
||||
__attribute__ ((noinline))
|
||||
get_foo (void)
|
||||
{
|
||||
return foo;
|
||||
}
|
||||
|
||||
foo_p
|
||||
__attribute__ ((noinline))
|
||||
get_foo_protected (void)
|
||||
{
|
||||
return foo_protected;
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
foo_p p;
|
||||
|
||||
p = get_foo ();
|
||||
if ((*p) () != -1)
|
||||
abort ();
|
||||
|
||||
p = get_foo_protected ();
|
||||
if ((*p) () != 0)
|
||||
abort ();
|
||||
|
||||
return 0;
|
||||
}
|
3
elf/ifuncmain5pic.c
Normal file
3
elf/ifuncmain5pic.c
Normal file
@ -0,0 +1,3 @@
|
||||
/* Test STT_GNU_IFUNC symbols with -fPIC. */
|
||||
|
||||
#include "ifuncmain5.c"
|
3
elf/ifuncmain5picstatic.c
Normal file
3
elf/ifuncmain5picstatic.c
Normal file
@ -0,0 +1,3 @@
|
||||
/* Test STT_GNU_IFUNC symbols with -fPIC and -static. */
|
||||
|
||||
#include "ifuncmain5.c"
|
3
elf/ifuncmain5pie.c
Normal file
3
elf/ifuncmain5pie.c
Normal file
@ -0,0 +1,3 @@
|
||||
/* Test STT_GNU_IFUNC symbols with PIE. */
|
||||
|
||||
#include "ifuncmain5.c"
|
3
elf/ifuncmain5static.c
Normal file
3
elf/ifuncmain5static.c
Normal file
@ -0,0 +1,3 @@
|
||||
/* Test STT_GNU_IFUNC symbols with -static. */
|
||||
|
||||
#include "ifuncmain5.c"
|
3
elf/ifuncmain5staticpic.c
Normal file
3
elf/ifuncmain5staticpic.c
Normal file
@ -0,0 +1,3 @@
|
||||
/* Test STT_GNU_IFUNC symbols with -fPIC and no DSO. */
|
||||
|
||||
#include "ifuncmain5.c"
|
63
elf/ifuncmain6pie.c
Normal file
63
elf/ifuncmain6pie.c
Normal file
@ -0,0 +1,63 @@
|
||||
/* Test STT_GNU_IFUNC symbols in PIE:
|
||||
|
||||
1. Direct function call.
|
||||
2. Function pointer.
|
||||
3. Reference from a shared library.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef int (*foo_p) (void);
|
||||
extern foo_p foo_ptr;
|
||||
|
||||
static int
|
||||
one (void)
|
||||
{
|
||||
return -30;
|
||||
}
|
||||
|
||||
void * foo_ifunc (void) __asm__ ("foo");
|
||||
__asm__(".type foo, %gnu_indirect_function");
|
||||
|
||||
void *
|
||||
foo_ifunc (void)
|
||||
{
|
||||
return one;
|
||||
}
|
||||
|
||||
extern int foo (void);
|
||||
extern foo_p get_foo (void);
|
||||
extern foo_p get_foo_p (void);
|
||||
|
||||
foo_p my_foo_ptr = foo;
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
foo_p p;
|
||||
|
||||
p = get_foo ();
|
||||
if (p != foo)
|
||||
abort ();
|
||||
if ((*p) () != -30)
|
||||
abort ();
|
||||
|
||||
p = get_foo_p ();
|
||||
if (p != foo)
|
||||
abort ();
|
||||
if ((*p) () != -30)
|
||||
abort ();
|
||||
|
||||
if (foo_ptr != foo)
|
||||
abort ();
|
||||
if (my_foo_ptr != foo)
|
||||
abort ();
|
||||
if ((*foo_ptr) () != -30)
|
||||
abort ();
|
||||
if ((*my_foo_ptr) () != -30)
|
||||
abort ();
|
||||
if (foo () != -30)
|
||||
abort ();
|
||||
|
||||
return 0;
|
||||
}
|
70
elf/ifuncmain7.c
Normal file
70
elf/ifuncmain7.c
Normal file
@ -0,0 +1,70 @@
|
||||
/* Test local STT_GNU_IFUNC symbols:
|
||||
|
||||
1. Direct function call.
|
||||
2. Function pointer.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
extern int foo (void);
|
||||
|
||||
static int
|
||||
one (void)
|
||||
{
|
||||
return -30;
|
||||
}
|
||||
|
||||
static void * foo_ifunc (void) __asm__ ("foo");
|
||||
__asm__(".type foo, %gnu_indirect_function");
|
||||
|
||||
static void *
|
||||
__attribute__ ((used))
|
||||
foo_ifunc (void)
|
||||
{
|
||||
return one;
|
||||
}
|
||||
|
||||
typedef int (*foo_p) (void);
|
||||
|
||||
foo_p foo_ptr = foo;
|
||||
|
||||
foo_p
|
||||
__attribute__ ((noinline))
|
||||
get_foo_p (void)
|
||||
{
|
||||
return foo_ptr;
|
||||
}
|
||||
|
||||
foo_p
|
||||
__attribute__ ((noinline))
|
||||
get_foo (void)
|
||||
{
|
||||
return foo;
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
foo_p p;
|
||||
|
||||
p = get_foo ();
|
||||
if (p != foo)
|
||||
abort ();
|
||||
if ((*p) () != -30)
|
||||
abort ();
|
||||
|
||||
p = get_foo_p ();
|
||||
if (p != foo)
|
||||
abort ();
|
||||
if ((*p) () != -30)
|
||||
abort ();
|
||||
|
||||
if (foo_ptr != foo)
|
||||
abort ();
|
||||
if ((*foo_ptr) () != -30)
|
||||
abort ();
|
||||
if (foo () != -30)
|
||||
abort ();
|
||||
|
||||
return 0;
|
||||
}
|
7
elf/ifuncmain7pic.c
Normal file
7
elf/ifuncmain7pic.c
Normal file
@ -0,0 +1,7 @@
|
||||
/* Test local STT_GNU_IFUNC symbols with -fPIC:
|
||||
|
||||
1. Direct function call.
|
||||
2. Function pointer.
|
||||
*/
|
||||
|
||||
#include "ifuncmain7.c"
|
7
elf/ifuncmain7picstatic.c
Normal file
7
elf/ifuncmain7picstatic.c
Normal file
@ -0,0 +1,7 @@
|
||||
/* Test local STT_GNU_IFUNC symbols with -fPIC and -static:
|
||||
|
||||
1. Direct function call.
|
||||
2. Function pointer.
|
||||
*/
|
||||
|
||||
#include "ifuncmain7.c"
|
7
elf/ifuncmain7pie.c
Normal file
7
elf/ifuncmain7pie.c
Normal file
@ -0,0 +1,7 @@
|
||||
/* Test local STT_GNU_IFUNC symbols with PIE:
|
||||
|
||||
1. Direct function call.
|
||||
2. Function pointer.
|
||||
*/
|
||||
|
||||
#include "ifuncmain7.c"
|
7
elf/ifuncmain7static.c
Normal file
7
elf/ifuncmain7static.c
Normal file
@ -0,0 +1,7 @@
|
||||
/* Test local STT_GNU_IFUNC symbols with -static:
|
||||
|
||||
1. Direct function call.
|
||||
2. Function pointer.
|
||||
*/
|
||||
|
||||
#include "ifuncmain7.c"
|
78
elf/ifuncmod5.c
Normal file
78
elf/ifuncmod5.c
Normal file
@ -0,0 +1,78 @@
|
||||
/* Test STT_GNU_IFUNC symbols without direct function call. */
|
||||
|
||||
extern int global;
|
||||
|
||||
static int
|
||||
one (void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
minus_one (void)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
zero (void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void * foo_ifunc (void) __asm__ ("foo");
|
||||
__asm__(".type foo, %gnu_indirect_function");
|
||||
|
||||
void *
|
||||
foo_ifunc (void)
|
||||
{
|
||||
switch (global)
|
||||
{
|
||||
case 1:
|
||||
return one;
|
||||
case -1:
|
||||
return minus_one;
|
||||
default:
|
||||
return zero;
|
||||
}
|
||||
}
|
||||
|
||||
void * foo_hidden_ifunc (void) __asm__ ("foo_hidden");
|
||||
__asm__(".type foo_hidden, %gnu_indirect_function");
|
||||
|
||||
void *
|
||||
foo_hidden_ifunc (void)
|
||||
{
|
||||
switch (global)
|
||||
{
|
||||
case 1:
|
||||
return minus_one;
|
||||
case -1:
|
||||
return one;
|
||||
default:
|
||||
return zero;
|
||||
}
|
||||
}
|
||||
|
||||
void * foo_protected_ifunc (void) __asm__ ("foo_protected");
|
||||
__asm__(".type foo_protected, %gnu_indirect_function");
|
||||
|
||||
void *
|
||||
foo_protected_ifunc (void)
|
||||
{
|
||||
switch (global)
|
||||
{
|
||||
case 1:
|
||||
return one;
|
||||
case -1:
|
||||
return zero;
|
||||
default:
|
||||
return minus_one;
|
||||
}
|
||||
}
|
||||
|
||||
/* Test hidden indirect function. */
|
||||
__asm__(".hidden foo_hidden");
|
||||
|
||||
/* Test protected indirect function. */
|
||||
__asm__(".protected foo_protected");
|
19
elf/ifuncmod6.c
Normal file
19
elf/ifuncmod6.c
Normal file
@ -0,0 +1,19 @@
|
||||
/* Test STT_GNU_IFUNC symbol reference in a shared library. */
|
||||
|
||||
extern int foo (void);
|
||||
|
||||
typedef int (*foo_p) (void);
|
||||
|
||||
foo_p foo_ptr = foo;
|
||||
|
||||
foo_p
|
||||
get_foo_p (void)
|
||||
{
|
||||
return foo_ptr;
|
||||
}
|
||||
|
||||
foo_p
|
||||
get_foo (void)
|
||||
{
|
||||
return foo;
|
||||
}
|
Loading…
Reference in New Issue
Block a user