[PATCH 3/4] gold/aarch64: Check non-PIC relocation for PIC output
H.J. Lu
hjl.tools@gmail.com
Fri Aug 23 23:05:18 GMT 2024
Call check_non_pic on non-PIC relocations for PIC output, excluding
relocations against _GLOBAL_OFFSET_TABLE_ which is a local symbol
defined by linker. Since aarch64 does require PIC relocations for
PIC output, set FN_PTRS_IN_SO_WITHOUT_PIC to false for aarch64.
PR gold/19328
* aarch64.cc (Target_aarch64::Scan::global): Call check_non_pic
for PIC output.
* configure.ac (FN_PTRS_IN_SO_WITHOUT_PIC): Set to false for
aarch64.
* configure: Regenerated.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
gold/aarch64.cc | 5 +++++
gold/configure | 1 +
gold/configure.ac | 1 +
3 files changed, 7 insertions(+)
diff --git a/gold/aarch64.cc b/gold/aarch64.cc
index d96123539da..0b9f6c43b6b 100644
--- a/gold/aarch64.cc
+++ b/gold/aarch64.cc
@@ -6544,6 +6544,11 @@ Target_aarch64<size, big_endian>::Scan::global(
target->copy_reloc(symtab, layout, object,
data_shndx, output_section, gsym, rela);
}
+ else if (strcmp(gsym->name(), "_GLOBAL_OFFSET_TABLE_") != 0
+ && (gsym->is_from_dynobj()
+ || gsym->is_undefined()
+ || gsym->is_preemptible()))
+ check_non_pic(object, r_type);
}
break;
}
diff --git a/gold/configure b/gold/configure
index a2674d6ecbb..97ca3ac9aa2 100755
--- a/gold/configure
+++ b/gold/configure
@@ -9407,6 +9407,7 @@ fi
if
case $target_cpu in
+ aarch64*) false;;
powerpc*) false;;
x86_64) false;;
sparc64) false;;
diff --git a/gold/configure.ac b/gold/configure.ac
index 52f7a701128..96c1493bd15 100644
--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -345,6 +345,7 @@ dnl tell the unittest framework if we're compiling for one of those
dnl targets, so it doesn't try to run the tests that do that.
AM_CONDITIONAL(FN_PTRS_IN_SO_WITHOUT_PIC, [
case $target_cpu in
+ aarch64*) false;;
powerpc*) false;;
x86_64) false;;
sparc64) false;;
--
2.46.0
More information about the Binutils
mailing list