aboutsummaryrefslogtreecommitdiff
path: root/gold/testsuite
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-10-13 05:10:24 -0700
committerH.J. Lu <hjl.tools@gmail.com>2020-10-13 05:10:36 -0700
commitaac1d94f19492fb6bea7193497bce599952c429d (patch)
treea228a103e97cc042b6d2ea5f5171294da08da4cb /gold/testsuite
parent1fb1d64f4a7c817f91a164dc22d5a22a0e75c1b8 (diff)
downloadfsf-binutils-gdb-aac1d94f19492fb6bea7193497bce599952c429d.zip
fsf-binutils-gdb-aac1d94f19492fb6bea7193497bce599952c429d.tar.gz
fsf-binutils-gdb-aac1d94f19492fb6bea7193497bce599952c429d.tar.bz2
Gold: Enable safe ICF for shared object on x86-64
With commit 4aebb6312eb5dcd12f2f8420028547584b708907 Author: Rahul Chaudhry <rahulchaudhry@google.com> Date: Wed Feb 15 00:37:10 2017 -0800 Improved support for --icf=safe when used with -pie. we now check opcode with R_X86_64_PC32 relocation, which tell branches from other instructions. We can enable safe ICF for shared object on x86-64. Also, global symbols with non-default visibility should be folded like local symbols. PR gold/21452 * x86_64.cc (Scan::local_reloc_may_be_function_pointer): Remove check for shared library. (Scan::global_reloc_may_be_function_pointer): Remove check for shared library and symbol visibility. * testsuite/icf_safe_so_test.cc (bar_static): New function. (main): Take function address of bar_static and use it. * testsuite/icf_safe_so_test.sh (arch_specific_safe_fold): Also check fold on x86-64. Check bar_static isn't folded.
Diffstat (limited to 'gold/testsuite')
-rw-r--r--gold/testsuite/icf_safe_so_test.cc8
-rwxr-xr-xgold/testsuite/icf_safe_so_test.sh2
2 files changed, 9 insertions, 1 deletions
diff --git a/gold/testsuite/icf_safe_so_test.cc b/gold/testsuite/icf_safe_so_test.cc
index 1c59303..3256655 100644
--- a/gold/testsuite/icf_safe_so_test.cc
+++ b/gold/testsuite/icf_safe_so_test.cc
@@ -61,10 +61,18 @@ int bar_glob()
return 2;
}
+static int
+bar_static()
+{
+ return 2;
+}
+
int main()
{
int (*p)() = foo_glob;
(void)p;
+ p = bar_static;
+ (void)p;
foo_static();
foo_prot();
foo_hidden();
diff --git a/gold/testsuite/icf_safe_so_test.sh b/gold/testsuite/icf_safe_so_test.sh
index 10f8782..4c253c5 100755
--- a/gold/testsuite/icf_safe_so_test.sh
+++ b/gold/testsuite/icf_safe_so_test.sh
@@ -83,7 +83,7 @@ END {
arch_specific_safe_fold()
{
- if grep -q -e "Intel 80386" -e "ARM" -e "PowerPC" $1;
+ if grep -q -e "Advanced Micro Devices X86-64" -e "Intel 80386" -e "ARM" -e "PowerPC" $1;
then
shift
shift