[PATCH 4/4] gold/aarch64: Use PLT entry as function address

H.J. Lu hjl.tools@gmail.com
Fri Aug 23 23:05:19 GMT 2024


When the function address is taken, uses its PLT entry as its function
address.

	PR gold/32113
	* aarch64.cc (Target_aarch64::Scan::global): Call
	set_needs_dynsym_value when the function address is taken.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
 gold/aarch64.cc | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/gold/aarch64.cc b/gold/aarch64.cc
index 0b9f6c43b6b..952821e81a0 100644
--- a/gold/aarch64.cc
+++ b/gold/aarch64.cc
@@ -6534,7 +6534,15 @@ Target_aarch64<size, big_endian>::Scan::global(
     case elfcpp::R_AARCH64_LDST128_ABS_LO12_NC: // 299
       {
 	if (gsym->needs_plt_entry())
-	  target->make_plt_entry(symtab, layout, gsym);
+	  {
+	    target->make_plt_entry(symtab, layout, gsym);
+	    // Since this is not a PC-relative relocation, we may be
+	    // taking the address of a function. In that case we need to
+	    // set the entry in the dynamic symbol table to the address of
+	    // the PLT entry.
+	    if (gsym->is_from_dynobj() && !parameters->options().shared())
+	      gsym->set_needs_dynsym_value();
+	  }
 	// Make a dynamic relocation if necessary.
 	if (gsym->needs_dynamic_reloc(arp->reference_flags()))
 	  {
-- 
2.46.0



More information about the Binutils mailing list