-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mostly tests around not-exported IFUNC functions, IFUNC in statically linked binaries and PIEs, etc.
- Loading branch information
H.J. Lu
authored and
Ulrich Drepper
committed
Jun 22, 2009
1 parent
ccab6d8
commit 3c30afc
Showing
19 changed files
with
457 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/* Test STT_GNU_IFUNC symbols without -fPIC. */ | ||
|
||
#include "ifuncmod5.c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/* Test STT_GNU_IFUNC symbols with -fPIC. */ | ||
|
||
#include "ifuncmod5.c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/* Test STT_GNU_IFUNC symbols with PIE and no DSO. */ | ||
|
||
#include "ifuncmain1.c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/* Test STT_GNU_IFUNC symbols with -fPIC. */ | ||
|
||
#include "ifuncmain5.c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/* Test STT_GNU_IFUNC symbols with -fPIC and -static. */ | ||
|
||
#include "ifuncmain5.c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/* Test STT_GNU_IFUNC symbols with PIE. */ | ||
|
||
#include "ifuncmain5.c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/* Test STT_GNU_IFUNC symbols with -static. */ | ||
|
||
#include "ifuncmain5.c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/* Test STT_GNU_IFUNC symbols with -fPIC and no DSO. */ | ||
|
||
#include "ifuncmain5.c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
Oops, something went wrong.