aboutsummaryrefslogtreecommitdiff
path: root/gold
diff options
context:
space:
mode:
Diffstat (limited to 'gold')
-rw-r--r--gold/ChangeLog12
-rw-r--r--gold/testsuite/icf_safe_so_test.cc8
-rwxr-xr-xgold/testsuite/icf_safe_so_test.sh2
-rw-r--r--gold/x86_64.cc18
4 files changed, 23 insertions, 17 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 0300722..5defad4 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,5 +1,17 @@
2020-10-13 H.J. Lu <hongjiu.lu@intel.com>
+ 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.
+
+2020-10-13 H.J. Lu <hongjiu.lu@intel.com>
+
* icf.cc (Icf::find_identical_sections): Skip zero-sized sections.
2020-10-09 Alan Modra <amodra@gmail.com>
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
diff --git a/gold/x86_64.cc b/gold/x86_64.cc
index 1d9d920..9cb2cf0 100644
--- a/gold/x86_64.cc
+++ b/gold/x86_64.cc
@@ -3992,12 +3992,6 @@ Target_x86_64<size>::Scan::local_reloc_may_be_function_pointer(
unsigned int r_type,
const elfcpp::Sym<size, false>&)
{
- // When building a shared library, do not fold any local symbols as it is
- // not possible to distinguish pointer taken versus a call by looking at
- // the relocation types.
- if (parameters->options().shared())
- return true;
-
return possible_function_pointer_reloc(src_obj, src_indx,
reloc.get_r_offset(), r_type);
}
@@ -4017,16 +4011,8 @@ Target_x86_64<size>::Scan::global_reloc_may_be_function_pointer(
Output_section* ,
const elfcpp::Rela<size, false>& reloc,
unsigned int r_type,
- Symbol* gsym)
-{
- // When building a shared library, do not fold symbols whose visibility
- // is hidden, internal or protected.
- if (parameters->options().shared()
- && (gsym->visibility() == elfcpp::STV_INTERNAL
- || gsym->visibility() == elfcpp::STV_PROTECTED
- || gsym->visibility() == elfcpp::STV_HIDDEN))
- return true;
-
+ Symbol*)
+{
return possible_function_pointer_reloc(src_obj, src_indx,
reloc.get_r_offset(), r_type);
}