x86-64: Provide more info when failed to convert GOTPCREL
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 4 Feb 2021 14:02:13 +0000 (06:02 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 4 Feb 2021 14:06:44 +0000 (06:06 -0800)
Provide

[hjl@gnu-cfl-2 ld]$ ./ld-new -z norelro  -L/export/gnu/import/git/gitlab/x86-binutils/ld/testsuite/ld-x86-64  -melf32_x86_64 -Ttext=0x80000000 -o tmpdir/dump tmpdir/pr19609-7.o
tmpdir/pr19609-7.o: in function `_start':
(.text+0x2): failed to convert GOTPCREL relocation against 'foobar'; relink with --no-relax
[hjl@gnu-cfl-2 ld]$

instead of

[hjl@gnu-cfl-2 ld]$ ld -z norelro  -L/export/gnu/import/git/gitlab/x86-binutils/ld/testsuite/ld-x86-64  -melf32_x86_64 -Ttext=0x80000000 -o tmpdir/dump tmpdir/pr19609-7.o
ld: failed to convert GOTPCREL relocation; relink with --no-relax
[hjl@gnu-cfl-2 ld]$

bfd/

PR ld/19609
* elf64-x86-64.c (elf_x86_64_relocate_section): Provide more
info when failed to convert GOTPCREL relocation.

ld/

PR ld/19609
* testsuite/ld-x86-64/pr19609-2a.d: Updated.
* testsuite/ld-x86-64/pr19609-2b.d: Likewise.
* testsuite/ld-x86-64/pr19609-4a.d: Likewise.
* testsuite/ld-x86-64/pr19609-4c.d: Likewise.
* testsuite/ld-x86-64/pr19609-5d.d: Likewise.
* testsuite/ld-x86-64/pr19609-7a.d: Likewise.
* testsuite/ld-x86-64/pr19609-7c.d: Likewise.

bfd/ChangeLog
bfd/elf64-x86-64.c
ld/ChangeLog
ld/testsuite/ld-x86-64/pr19609-2a.d
ld/testsuite/ld-x86-64/pr19609-2b.d
ld/testsuite/ld-x86-64/pr19609-4a.d
ld/testsuite/ld-x86-64/pr19609-4c.d
ld/testsuite/ld-x86-64/pr19609-5d.d
ld/testsuite/ld-x86-64/pr19609-7a.d
ld/testsuite/ld-x86-64/pr19609-7c.d

index 97ce3db60bda8fa802d733c2b67f4917daf71e06..ba608e1e77f22eb52aad61ae5d56b168b66b847b 100644 (file)
@@ -1,3 +1,9 @@
+2021-02-04  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/19609
+       * elf64-x86-64.c (elf_x86_64_relocate_section): Provide more
+       info when failed to convert GOTPCREL relocation.
+
 2021-02-04  Nelson Chu  <nelson.chu@sifive.com>
 
        * elfxx-riscv.c (riscv_parse_prefixed_ext): Removed zb*.
index 500f8bfa3094ac182a85940da3ab29b364692ad9..bba22008c0642f6c8fe1e65d98ff5c8ba3ef2a5a 100644 (file)
@@ -2430,6 +2430,7 @@ elf_x86_64_relocate_section (bfd *output_bfd,
   Elf_Internal_Rela *wrel;
   Elf_Internal_Rela *relend;
   unsigned int plt_entry_size;
+  bfd_boolean status;
 
   /* Skip if check_relocs failed.  */
   if (input_section->check_relocs_failed)
@@ -2453,6 +2454,7 @@ elf_x86_64_relocate_section (bfd *output_bfd,
 
   _bfd_x86_elf_set_tls_module_base (info);
 
+  status = TRUE;
   rel = wrel = relocs;
   relend = relocs + input_section->reloc_count;
   for (; rel < relend; wrel++, rel++)
@@ -4118,8 +4120,13 @@ elf_x86_64_relocate_section (bfd *output_bfd,
              if (converted_reloc)
                {
                  info->callbacks->einfo
-                   (_("%F%P: failed to convert GOTPCREL relocation; relink with --no-relax\n"));
-                 return FALSE;
+                   ("%X%H:", input_bfd, input_section, rel->r_offset);
+                 info->callbacks->einfo
+                   (_(" failed to convert GOTPCREL relocation against "
+                      "'%s'; relink with --no-relax\n"),
+                    name);
+                 status = FALSE;
+                 continue;
                }
              (*info->callbacks->reloc_overflow)
                (info, (h ? &h->root : NULL), name, howto->name,
@@ -4160,7 +4167,7 @@ elf_x86_64_relocate_section (bfd *output_bfd,
       input_section->reloc_count -= deleted;
     }
 
-  return TRUE;
+  return status;
 }
 
 /* Finish up dynamic symbol handling.  We set the contents of various
index 3cd2be0add534fef9ffd87c5d74db4f1d57f0ca9..52639f30b2007cb1c24d083af082c133c47245dc 100644 (file)
@@ -1,3 +1,14 @@
+2021-02-04  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/19609
+       * testsuite/ld-x86-64/pr19609-2a.d: Updated.
+       * testsuite/ld-x86-64/pr19609-2b.d: Likewise.
+       * testsuite/ld-x86-64/pr19609-4a.d: Likewise.
+       * testsuite/ld-x86-64/pr19609-4c.d: Likewise.
+       * testsuite/ld-x86-64/pr19609-5d.d: Likewise.
+       * testsuite/ld-x86-64/pr19609-7a.d: Likewise.
+       * testsuite/ld-x86-64/pr19609-7c.d: Likewise.
+
 2021-02-04  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/15146
index 2bed641dc243f3f0770abca27b7e849e50d82038..6d3db92afb71b6eb3eb457949946fdf64ef06cd7 100644 (file)
@@ -1,4 +1,4 @@
 #source: pr19609-2.s
 #as: --64 -mrelax-relocations=yes
 #ld: -melf_x86_64 -Ttext=0x70000000 -Tdata=0xa0000000
-#error: failed to convert GOTPCREL relocation; relink with --no-relax
+#error: .*failed to convert GOTPCREL relocation against 'foo'; relink with --no-relax.*
index 3741ebbc158bfa43df80f44ee7fcf850305639b0..4fee93d7034d7c218ad658acb49a1535e1ea9fa3 100644 (file)
@@ -1,4 +1,4 @@
 #source: pr19609-2.s
 #as: --x32 -mrelax-relocations=yes
 #ld: -melf32_x86_64 -Ttext=0x70000000 -Tdata=0xa0000000
-#error: failed to convert GOTPCREL relocation; relink with --no-relax
+#error: .*failed to convert GOTPCREL relocation against 'foo'; relink with --no-relax.*
index f08843c5001a998fd15efe248efcb26bea86a946..eb37d0c8729b56489da2fa165f7811582870a7f2 100644 (file)
@@ -1,4 +1,4 @@
 #source: pr19609-4.s
 #as: --64 -mrelax-relocations=yes
 #ld: -melf_x86_64 -Ttext=0x70000000 -Tdata=0xa0000000
-#error: failed to convert GOTPCREL relocation; relink with --no-relax
+#error: .*failed to convert GOTPCREL relocation against 'foo'; relink with --no-relax.*failed to convert GOTPCREL relocation against 'foo'; relink with --no-relax.*
index f08843c5001a998fd15efe248efcb26bea86a946..eb37d0c8729b56489da2fa165f7811582870a7f2 100644 (file)
@@ -1,4 +1,4 @@
 #source: pr19609-4.s
 #as: --64 -mrelax-relocations=yes
 #ld: -melf_x86_64 -Ttext=0x70000000 -Tdata=0xa0000000
-#error: failed to convert GOTPCREL relocation; relink with --no-relax
+#error: .*failed to convert GOTPCREL relocation against 'foo'; relink with --no-relax.*failed to convert GOTPCREL relocation against 'foo'; relink with --no-relax.*
index 608c97bd6b9034d810e321ab324ef58041e37f24..0ab28efff1efd3ec23ee613af8c358903313a087 100644 (file)
@@ -1,4 +1,4 @@
 #source: pr19609-5.s
 #as: --64 -mrelax-relocations=yes
 #ld: -melf_x86_64 -Ttext=0x80000000
-#error: failed to convert GOTPCREL relocation; relink with --no-relax
+#error: .*failed to convert GOTPCREL relocation against 'bar'; relink with --no-relax
index 015a6ffd0a787dec211e5a6e59cb93b357220be6..34704a94c16408eedc1b52b9cb78d7d2de94adc9 100644 (file)
@@ -1,4 +1,4 @@
 #source: pr19609-7.s
 #as: --64 -mrelax-relocations=yes
 #ld: -melf_x86_64 -Ttext=0x80000000
-#error: failed to convert GOTPCREL relocation; relink with --no-relax
+#error: .*failed to convert GOTPCREL relocation against 'foobar'; relink with --no-relax
index ff600498d4f80773ea7daa11e77d99b4f538bf5d..09488e22a8e5473ec618058e96fe70d9f612cbbd 100644 (file)
@@ -1,4 +1,4 @@
 #source: pr19609-7.s
 #as: --x32 -mrelax-relocations=yes
 #ld: -melf32_x86_64 -Ttext=0x80000000
-#error: failed to convert GOTPCREL relocation; relink with --no-relax
+#error: .*failed to convert GOTPCREL relocation against 'foobar'; relink with --no-relax