This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[AArch64] Improve BFD overflow warning message for -fpic
- From: Jiong Wang <jiong dot wang at arm dot com>
- To: "binutils\ at sourceware dot org" <binutils at sourceware dot org>
- Date: Tue, 28 Jul 2015 16:55:56 +0100
- Subject: [AArch64] Improve BFD overflow warning message for -fpic
- Authentication-results: sourceware.org; auth=none
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 <jiong.wang@arm.com>
bfd/
* elfnn-aarch64.c (elfNN_aarch64_relocate_section): Add more warning message for
R_AARCH64_LD64_GOTPAGE_LO15/R_AARCH64_LD32_GOTPAGE_LO14.
--
Regards,
Jiong
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;
+ }
break;
case bfd_reloc_undefined: