mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-21 02:24:17 +08:00
Check address of versined symbol
Since GCC 5 folds symbol address comparison, assuming each symbol has a different address, &foo == &bar is always false for GCC 5. This patch adds check_ptr_eq if 2 addresses are the same and uses it to check the address of versined symbol. PR ld/18718 * ld-elf/check-ptr-eq.c: New file. * ld-elf/pr18718.c (main): Call check_ptr_eq. * ld-elf/shared.exp: Add check-ptr-eq.c to PR ld/18718 tests.
This commit is contained in:
12
ld/testsuite/ld-elf/check-ptr-eq.c
Normal file
12
ld/testsuite/ld-elf/check-ptr-eq.c
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
extern void abort (void);
|
||||||
|
|
||||||
|
/* Since GCC 5 folds symbol address comparison, assuming each symbol has
|
||||||
|
different address, &foo == &bar is always false for GCC 5. Use
|
||||||
|
check_ptr_eq to check if 2 addresses are the same. */
|
||||||
|
|
||||||
|
void
|
||||||
|
check_ptr_eq (void *p1, void *p2)
|
||||||
|
{
|
||||||
|
if (p1 != p2)
|
||||||
|
abort ();
|
||||||
|
}
|
@ -2,6 +2,7 @@
|
|||||||
#include <bfd_stdint.h>
|
#include <bfd_stdint.h>
|
||||||
|
|
||||||
extern void foo (void);
|
extern void foo (void);
|
||||||
|
extern void check_ptr_eq (void *, void *);
|
||||||
|
|
||||||
void
|
void
|
||||||
new_foo (void)
|
new_foo (void)
|
||||||
@ -21,6 +22,7 @@ int
|
|||||||
main(void)
|
main(void)
|
||||||
{
|
{
|
||||||
bar ();
|
bar ();
|
||||||
|
check_ptr_eq (&foo, &new_foo);
|
||||||
printf("PASS\n");
|
printf("PASS\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -533,7 +533,7 @@ if { [istarget *-*-linux*]
|
|||||||
"Run pr18718" \
|
"Run pr18718" \
|
||||||
"" \
|
"" \
|
||||||
"" \
|
"" \
|
||||||
{ pr18718.c } \
|
{ pr18718.c check-ptr-eq.c } \
|
||||||
"pr18718" \
|
"pr18718" \
|
||||||
"pass.out" \
|
"pass.out" \
|
||||||
"-O2 -I../bfd" \
|
"-O2 -I../bfd" \
|
||||||
@ -542,7 +542,7 @@ if { [istarget *-*-linux*]
|
|||||||
"Run pr18718 with PIE (1)" \
|
"Run pr18718 with PIE (1)" \
|
||||||
"-pie" \
|
"-pie" \
|
||||||
"" \
|
"" \
|
||||||
{ pr18718.c } \
|
{ pr18718.c check-ptr-eq.c } \
|
||||||
"pr18718pie1" \
|
"pr18718pie1" \
|
||||||
"pass.out" \
|
"pass.out" \
|
||||||
"-O2 -fPIE -I../bfd" \
|
"-O2 -fPIE -I../bfd" \
|
||||||
@ -551,7 +551,7 @@ if { [istarget *-*-linux*]
|
|||||||
"Run pr18718 with PIE (2)" \
|
"Run pr18718 with PIE (2)" \
|
||||||
"" \
|
"" \
|
||||||
"" \
|
"" \
|
||||||
{ pr18718.c } \
|
{ pr18718.c check-ptr-eq.c } \
|
||||||
"pr18718pie2" \
|
"pr18718pie2" \
|
||||||
"pass.out" \
|
"pass.out" \
|
||||||
"-O2 -fPIE -I../bfd" \
|
"-O2 -fPIE -I../bfd" \
|
||||||
@ -560,7 +560,7 @@ if { [istarget *-*-linux*]
|
|||||||
"Run pr18718 with PIC (1)" \
|
"Run pr18718 with PIC (1)" \
|
||||||
"" \
|
"" \
|
||||||
"" \
|
"" \
|
||||||
{ pr18718.c } \
|
{ pr18718.c check-ptr-eq.c } \
|
||||||
"pr18718pic1" \
|
"pr18718pic1" \
|
||||||
"pass.out" \
|
"pass.out" \
|
||||||
"-O2 -fPIC -I../bfd" \
|
"-O2 -fPIC -I../bfd" \
|
||||||
@ -569,7 +569,7 @@ if { [istarget *-*-linux*]
|
|||||||
"Run pr18718 with PIC (2)" \
|
"Run pr18718 with PIC (2)" \
|
||||||
"-pie" \
|
"-pie" \
|
||||||
"" \
|
"" \
|
||||||
{ pr18718.c } \
|
{ pr18718.c check-ptr-eq.c } \
|
||||||
"pr18718pic2" \
|
"pr18718pic2" \
|
||||||
"pass.out" \
|
"pass.out" \
|
||||||
"-O2 -fPIC -I../bfd" \
|
"-O2 -fPIC -I../bfd" \
|
||||||
|
Reference in New Issue
Block a user