This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[AArch64] Improve BFD overflow warning message for -fpic

This patch gives the user more readable error message.

for R_AARCH64_LD64_GOTPAGE_LO15/R_AARCH64_LD32_GOTPAGE_LO14 overflow,
largely it's caused by too many GOT entry can't fit into -fpic model,
need to recompile using -fPIC to allow 4G GOT table size.

the new error message will be the following:

./ld-new  -shared -o tmpdir/dump tmpdir/dump0.o 
tmpdir/dump0.o:(.text+0x0): relocation truncated to fit: R_AARCH64_LD64_GOTPAGE_LO15 against undefined symbol `global_0'
tmpdir/dump0.o:(.text+0x0): warning: Too many GOT entries for -fpic, please recompile with -fPIC
./ld-new: final link failed: Nonrepresentable section on output

2015-07-28  Jiong Wang  <>

  * elfnn-aarch64.c (elfNN_aarch64_relocate_section): Add more warning message for

diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 6808ca3..b48c4b6 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -5688,6 +5688,9 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
       if (r != bfd_reloc_ok && r != bfd_reloc_continue)
+	  bfd_reloc_code_real_type real_r_type
+	    = elfNN_aarch64_bfd_reloc_from_type (r_type);
 	  switch (r)
 	    case bfd_reloc_overflow:
@@ -5695,6 +5698,16 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
 		  (info, (h ? &h->root : NULL), name, howto->name, (bfd_vma) 0,
 		   input_bfd, input_section, rel->r_offset))
 		return FALSE;
+	      if (real_r_type == BFD_RELOC_AARCH64_LD64_GOTPAGE_LO15
+		  || real_r_type == BFD_RELOC_AARCH64_LD32_GOTPAGE_LO14)
+		{
+		  (*info->callbacks->warning)
+		    (info,
+		     _("Too many GOT entries for -fpic, "
+		       "please recompile with -fPIC"),
+		     name, input_bfd, input_section, rel->r_offset);
+		  return FALSE;
+		}
 	    case bfd_reloc_undefined:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]