elf: Disable some subtests of ifuncmain1, ifuncmain5 for !PIE

(cherry picked from commit 9cc9d61ee1)
This commit is contained in:
Florian Weimer 2022-11-04 18:37:16 +01:00 committed by Sunil K Pandey
parent b6e9f21071
commit ba7a5e3e0f
2 changed files with 22 additions and 0 deletions

View File

@ -19,7 +19,14 @@ typedef int (*foo_p) (void);
#endif #endif
foo_p foo_ptr = foo; foo_p foo_ptr = foo;
/* Address-significant access to protected symbols is not supported in
position-dependent mode on several architectures because GCC
generates relocations that assume that the address is local to the
main program. */
#ifdef __PIE__
foo_p foo_procted_ptr = foo_protected; foo_p foo_procted_ptr = foo_protected;
#endif
extern foo_p get_foo_p (void); extern foo_p get_foo_p (void);
extern foo_p get_foo_hidden_p (void); extern foo_p get_foo_hidden_p (void);
@ -37,12 +44,16 @@ main (void)
if ((*foo_ptr) () != -1) if ((*foo_ptr) () != -1)
abort (); abort ();
#ifdef __PIE__
if (foo_procted_ptr != foo_protected) if (foo_procted_ptr != foo_protected)
abort (); abort ();
#endif
if (foo_protected () != 0) if (foo_protected () != 0)
abort (); abort ();
#ifdef __PIE__
if ((*foo_procted_ptr) () != 0) if ((*foo_procted_ptr) () != 0)
abort (); abort ();
#endif
p = get_foo_p (); p = get_foo_p ();
if (p != foo) if (p != foo)
@ -55,8 +66,10 @@ main (void)
abort (); abort ();
p = get_foo_protected_p (); p = get_foo_protected_p ();
#ifdef __PIE__
if (p != foo_protected) if (p != foo_protected)
abort (); abort ();
#endif
if (ret_foo_protected != 0 || (*p) () != ret_foo_protected) if (ret_foo_protected != 0 || (*p) () != ret_foo_protected)
abort (); abort ();

View File

@ -14,12 +14,19 @@ get_foo (void)
return foo; return foo;
} }
/* Address-significant access to protected symbols is not supported in
position-dependent mode on several architectures because GCC
generates relocations that assume that the address is local to the
main program. */
#ifdef __PIE__
foo_p foo_p
__attribute__ ((noinline)) __attribute__ ((noinline))
get_foo_protected (void) get_foo_protected (void)
{ {
return foo_protected; return foo_protected;
} }
#endif
int int
main (void) main (void)
@ -30,9 +37,11 @@ main (void)
if ((*p) () != -1) if ((*p) () != -1)
abort (); abort ();
#ifdef __PIE__
p = get_foo_protected (); p = get_foo_protected ();
if ((*p) () != 0) if ((*p) () != 0)
abort (); abort ();
#endif
return 0; return 0;
} }