Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Test for ELF IFUNC functionality.
- Loading branch information
H.J. Lu
authored and
Ulrich Drepper
committed
Jun 3, 2009
1 parent
fbb04b3
commit 2f083d7
Showing
25 changed files
with
673 additions
and
1 deletion.
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 "ifuncmod1.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 "ifuncmod1.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,72 @@ | ||
/* Test 3 STT_GNU_IFUNC symbols. */ | ||
|
||
extern int global; | ||
|
||
static int | ||
one (void) | ||
{ | ||
return 1; | ||
} | ||
|
||
static int | ||
minus_one (void) | ||
{ | ||
return -1; | ||
} | ||
|
||
static int | ||
zero (void) | ||
{ | ||
return 0; | ||
} | ||
|
||
void * foo1_ifunc (void) __asm__ ("foo1"); | ||
__asm__(".type foo1, %gnu_indirect_function"); | ||
|
||
void * | ||
foo1_ifunc (void) | ||
{ | ||
switch (global) | ||
{ | ||
case 1: | ||
return one; | ||
case -1: | ||
return minus_one; | ||
default: | ||
return zero; | ||
} | ||
} | ||
|
||
void * foo2_ifunc (void) __asm__ ("foo2"); | ||
__asm__(".type foo2, %gnu_indirect_function"); | ||
|
||
void * | ||
foo2_ifunc (void) | ||
{ | ||
switch (global) | ||
{ | ||
case 1: | ||
return minus_one; | ||
case -1: | ||
return one; | ||
default: | ||
return zero; | ||
} | ||
} | ||
|
||
void * foo3_ifunc (void) __asm__ ("foo3"); | ||
__asm__(".type foo3, %gnu_indirect_function"); | ||
|
||
void * | ||
foo3_ifunc (void) | ||
{ | ||
switch (global) | ||
{ | ||
case 1: | ||
return one; | ||
case -1: | ||
return zero; | ||
default: | ||
return minus_one; | ||
} | ||
} |
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 "ifuncdep2.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,66 @@ | ||
/* Test STT_GNU_IFUNC symbols: | ||
1. Direct function call. | ||
2. Function pointer. | ||
3. Visibility without override. | ||
*/ | ||
|
||
#include <stdlib.h> | ||
|
||
int global = -1; | ||
|
||
int ret_foo; | ||
int ret_foo_hidden; | ||
int ret_foo_protected; | ||
|
||
extern int foo (void); | ||
extern int foo_protected (void); | ||
|
||
#ifndef FOO_P | ||
typedef int (*foo_p) (void); | ||
#endif | ||
|
||
foo_p foo_ptr = foo; | ||
foo_p foo_procted_ptr = foo_protected; | ||
|
||
extern foo_p get_foo_p (void); | ||
extern foo_p get_foo_hidden_p (void); | ||
extern foo_p get_foo_protected_p (void); | ||
|
||
int | ||
main (void) | ||
{ | ||
foo_p p; | ||
|
||
if (foo_ptr != foo) | ||
abort (); | ||
if (foo () != -1) | ||
abort (); | ||
if ((*foo_ptr) () != -1) | ||
abort (); | ||
|
||
if (foo_procted_ptr != foo_protected) | ||
abort (); | ||
if (foo_protected () != 0) | ||
abort (); | ||
if ((*foo_procted_ptr) () != 0) | ||
abort (); | ||
|
||
p = get_foo_p (); | ||
if (p != foo) | ||
abort (); | ||
if (ret_foo != -1 || (*p) () != ret_foo) | ||
abort (); | ||
|
||
p = get_foo_hidden_p (); | ||
if (ret_foo_hidden != 1 || (*p) () != ret_foo_hidden) | ||
abort (); | ||
|
||
p = get_foo_protected_p (); | ||
if (p != foo_protected) | ||
abort (); | ||
if (ret_foo_protected != 0 || (*p) () != ret_foo_protected) | ||
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 "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,3 @@ | ||
/* Test STT_GNU_IFUNC symbols with -fPIC and -static. */ | ||
|
||
#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,3 @@ | ||
/* Test STT_GNU_IFUNC symbols with PIE. */ | ||
|
||
#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,3 @@ | ||
/* Test STT_GNU_IFUNC symbols with -static. */ | ||
|
||
#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,3 @@ | ||
/* Test STT_GNU_IFUNC symbols with -fPIC and no DSO. */ | ||
|
||
#include "ifuncmain1.c" |
Oops, something went wrong.