diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2014-11-20 12:41:11 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2014-11-20 12:41:11 -0800 |
commit | 76e7af5ffa07e570c7cedb8b8141a822905d78f0 (patch) | |
tree | 5a8a2c50e37dd125a947bec0454403f01630fa6d /ld | |
parent | 731885c1add5b5012654fe1a70572f033c8d21f8 (diff) | |
download | gdb-76e7af5ffa07e570c7cedb8b8141a822905d78f0.zip gdb-76e7af5ffa07e570c7cedb8b8141a822905d78f0.tar.gz gdb-76e7af5ffa07e570c7cedb8b8141a822905d78f0.tar.bz2 |
Add function and function pointer tests
This patch adds tests for function and function pointer.
* ld-x86-64/plt-lib.c: New file.
* ld-x86-64/plt-main.out: Likewise.
* ld-x86-64/plt-main1.c: Likewise.
* ld-x86-64/plt-main1.rd: Likewise.
* ld-x86-64/plt-main2.c: Likewise.
* ld-x86-64/plt-main2.rd: Likewise.
* ld-x86-64/plt-main3.c: Likewise.
* ld-x86-64/plt-main3.rd: Likewise.
* ld-x86-64/plt-main4.c: Likewise.
* ld-x86-64/plt-main4.rd: Likewise.
* ld-x86-64/plt-main5.c: Likewise.
* ld-x86-64/x86-64.exp: Run plt-main tests.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/testsuite/ChangeLog | 16 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/plt-lib.c | 11 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/plt-main.out | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/plt-main1.c | 8 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/plt-main1.rd | 3 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/plt-main2.c | 3 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/plt-main2.rd | 3 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/plt-main3.c | 15 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/plt-main3.rd | 5 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/plt-main4.c | 14 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/plt-main4.rd | 5 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/plt-main5.c | 15 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/x86-64.exp | 55 |
13 files changed, 154 insertions, 0 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 63f145e..5c5fe88 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,5 +1,21 @@ 2014-11-20 H.J. Lu <hongjiu.lu@intel.com> + * ld-x86-64/plt-lib.c: New file. + * ld-x86-64/plt-main.out: Likewise. + * ld-x86-64/plt-main1.c: Likewise. + * ld-x86-64/plt-main1.rd: Likewise. + * ld-x86-64/plt-main2.c: Likewise. + * ld-x86-64/plt-main2.rd: Likewise. + * ld-x86-64/plt-main3.c: Likewise. + * ld-x86-64/plt-main3.rd: Likewise. + * ld-x86-64/plt-main4.c: Likewise. + * ld-x86-64/plt-main4.rd: Likewise. + * ld-x86-64/plt-main5.c: Likewise. + + * ld-x86-64/x86-64.exp: Run plt-main tests. + +2014-11-20 H.J. Lu <hongjiu.lu@intel.com> + * ld-ifunc/ifunc-main.c (get_bar): New function. (main): Use it. diff --git a/ld/testsuite/ld-x86-64/plt-lib.c b/ld/testsuite/ld-x86-64/plt-lib.c new file mode 100644 index 0000000..5e64ccd --- /dev/null +++ b/ld/testsuite/ld-x86-64/plt-lib.c @@ -0,0 +1,11 @@ +int +foo (void) +{ + return 1; +} + +int +bar (void) +{ + return -1; +} diff --git a/ld/testsuite/ld-x86-64/plt-main.out b/ld/testsuite/ld-x86-64/plt-main.out new file mode 100644 index 0000000..d86bac9 --- /dev/null +++ b/ld/testsuite/ld-x86-64/plt-main.out @@ -0,0 +1 @@ +OK diff --git a/ld/testsuite/ld-x86-64/plt-main1.c b/ld/testsuite/ld-x86-64/plt-main1.c new file mode 100644 index 0000000..90bb966 --- /dev/null +++ b/ld/testsuite/ld-x86-64/plt-main1.c @@ -0,0 +1,8 @@ +extern int bar(void); +typedef int (*func_p) (void); + +func_p +get_bar (void) +{ + return bar; +} diff --git a/ld/testsuite/ld-x86-64/plt-main1.rd b/ld/testsuite/ld-x86-64/plt-main1.rd new file mode 100644 index 0000000..9ce3814 --- /dev/null +++ b/ld/testsuite/ld-x86-64/plt-main1.rd @@ -0,0 +1,3 @@ +#... +[0-9a-f ]+R_X86_64_GOTPCREL +0+ bar - 4 +#pass diff --git a/ld/testsuite/ld-x86-64/plt-main2.c b/ld/testsuite/ld-x86-64/plt-main2.c new file mode 100644 index 0000000..d76694e --- /dev/null +++ b/ld/testsuite/ld-x86-64/plt-main2.c @@ -0,0 +1,3 @@ +extern int foo(void); +typedef int (*func_p) (void); +func_p foo_ptr = foo; diff --git a/ld/testsuite/ld-x86-64/plt-main2.rd b/ld/testsuite/ld-x86-64/plt-main2.rd new file mode 100644 index 0000000..5cc55ca --- /dev/null +++ b/ld/testsuite/ld-x86-64/plt-main2.rd @@ -0,0 +1,3 @@ +#... +[0-9a-f ]+R_X86_64_64 +0+ foo \+ 0 +#pass diff --git a/ld/testsuite/ld-x86-64/plt-main3.c b/ld/testsuite/ld-x86-64/plt-main3.c new file mode 100644 index 0000000..026e05f --- /dev/null +++ b/ld/testsuite/ld-x86-64/plt-main3.c @@ -0,0 +1,15 @@ +extern int bar(void); +typedef int (*func_p) (void); +extern func_p get_bar (void); + +void +check_bar (void) +{ + func_p bar_ptr = get_bar (); + if (bar_ptr != bar) + __builtin_abort (); + if (bar_ptr() != -1) + __builtin_abort (); + if (bar() != -1) + __builtin_abort (); +} diff --git a/ld/testsuite/ld-x86-64/plt-main3.rd b/ld/testsuite/ld-x86-64/plt-main3.rd new file mode 100644 index 0000000..46d7cc9 --- /dev/null +++ b/ld/testsuite/ld-x86-64/plt-main3.rd @@ -0,0 +1,5 @@ +#... +[0-9a-f ]+R_X86_64_GOTPCREL +0+ bar - 4 +#... +[0-9a-f ]+R_X86_64_PLT32 +0+ bar - 4 +#pass diff --git a/ld/testsuite/ld-x86-64/plt-main4.c b/ld/testsuite/ld-x86-64/plt-main4.c new file mode 100644 index 0000000..992ba5f --- /dev/null +++ b/ld/testsuite/ld-x86-64/plt-main4.c @@ -0,0 +1,14 @@ +extern int foo(void); +typedef int (*func_p) (void); +extern func_p foo_ptr; + +void +check_foo (void) +{ + if (foo_ptr != foo) + __builtin_abort (); + if (foo_ptr() != 1) + __builtin_abort (); + if (foo() != 1) + __builtin_abort (); +} diff --git a/ld/testsuite/ld-x86-64/plt-main4.rd b/ld/testsuite/ld-x86-64/plt-main4.rd new file mode 100644 index 0000000..8be3f86 --- /dev/null +++ b/ld/testsuite/ld-x86-64/plt-main4.rd @@ -0,0 +1,5 @@ +#... +[0-9a-f ]+R_X86_64_GOTPCREL +0+ foo - 4 +#... +[0-9a-f ]+R_X86_64_PLT32 +0+ foo - 4 +#pass diff --git a/ld/testsuite/ld-x86-64/plt-main5.c b/ld/testsuite/ld-x86-64/plt-main5.c new file mode 100644 index 0000000..97351a8 --- /dev/null +++ b/ld/testsuite/ld-x86-64/plt-main5.c @@ -0,0 +1,15 @@ +#include <stdio.h> + +extern void check_foo (void); +extern void check_bar (void); + +int +main (void) +{ + check_foo (); + check_bar (); + + printf ("OK\n"); + + return 0; +} diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index 7f09458..ecc1194 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -332,6 +332,61 @@ if { [isnative] && [which $CC] != 0 } { "-shared -melf32_x86_64 tmpdir/simple-x32.o" "" "--x32" {dummy.s} {{readelf {-s --wide} x86-64-x32.rd}} "x86-64-x32"} } + + run_cc_link_tests [list \ + [list \ + "Build plt-lib.so" \ + "-shared" \ + "-fPIC" \ + { plt-lib.c } \ + {} \ + "libplt-lib.so" \ + ] \ + [list \ + "Build libplt-main1.a" \ + "" \ + "-fPIC" \ + { plt-main1.c } \ + {{readelf {-Wr} plt-main1.rd}} \ + "libplt-main1.a" \ + ] \ + [list \ + "Build libplt-main2.a" \ + "" \ + "-fPIC" \ + { plt-main2.c } \ + {{readelf {-Wr} plt-main2.rd}} \ + "libplt-main2.a" \ + ] \ + [list \ + "Build libplt-main3.a" \ + "" \ + "-fPIC" \ + { plt-main3.c } \ + {{readelf {-Wr} plt-main3.rd}} \ + "libplt-main3.a" \ + ] \ + [list \ + "Build libplt-main4.a" \ + "" \ + "-fPIC" \ + { plt-main4.c } \ + {{readelf {-Wr} plt-main4.rd}} \ + "libplt-main4.a" \ + ] \ + ] + + run_ld_link_exec_tests [] [list \ + [list \ + "Run plt-main" \ + "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \ + tmpdir/plt-main4.o tmpdir/libplt-lib.so" \ + "" \ + { plt-main5.c } \ + "plt-main" \ + "plt-main.out" \ + ] \ + ] } if { ![istarget "x86_64-*-linux*"]} { |