[PATCH] PR32870: ld: arm32: fix segfault when linking with LLVMgold.so plugin under LTO

dongjianqiang (A) dongjianqiang2@huawei.com
Tue Apr 15 09:14:08 GMT 2025


Hi, 

Proposed patch to PR32870.
When handling the iplt in ARM32, the ld must check whether the input_bfd
is in ELF format. If the input is an LLVM Bitcode file, an error will be raised.

Any suggestions? Thanks.

---
	PR 32870
	* elf32-arm.c (elf32_arm_output_arch_local_syms): Check input_bfd

diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 3b7cee3de1c..3af964ce034 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -18345,6 +18345,9 @@ elf32_arm_output_arch_local_syms (bfd *output_bfd,
 	  struct arm_local_iplt_info **local_iplt;
 	  unsigned int i, num_syms;
 
+	  if (!is_arm_elf (input_bfd))
+	    continue;
+
 	  local_iplt = elf32_arm_local_iplt (input_bfd);
 	  if (local_iplt != NULL)
 	    {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-arm32-fix-segfault-when-linking-with-LLVMgold.so-plu.patch
Type: application/octet-stream
Size: 970 bytes
Desc: 0001-arm32-fix-segfault-when-linking-with-LLVMgold.so-plu.patch
URL: <https://sourceware.org/pipermail/binutils/attachments/20250415/93f93fff/attachment.obj>


More information about the Binutils mailing list