]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Only warn on badly sized symbols
authorMatthew Malcomson <matthew.malcomson@arm.com>
Mon, 7 Feb 2022 16:19:43 +0000 (16:19 +0000)
committerMatthew Malcomson <matthew.malcomson@arm.com>
Mon, 7 Feb 2022 16:20:04 +0000 (16:20 +0000)
The reasoning behind only warning for symbols which have a size which
cannot be precisely bounded is that there is nothing *requiring* precise
bounds, GCC knowingly avoids changing the size of some symbols for
precise bounds (TLS and symbols with user-specified alignment and
user-specified section), and LLD only warns on imprecise bounds rather
than erroring.
N.b. the reasoning for GCC avoiding padding in these cases is explained
in the commit message of b302420cb55 in the GCC branch
vendors/ARM/heads/morello.

All in all it's not something that we want in our toolchain as a
requirement, and it's not something that other toolchains have as a
requirement, so there doesn't seem to be much of a reason to include it.

In order to make this warning a little nicer for anyone reading it, we
add the name of the symbol to the warning.  Update the testsuite to
account for this.

Co-Author:   Alex Coplan  <alex.coplan@arm.com>

bfd/elfnn-aarch64.c
ld/testsuite/ld-aarch64/emit-relocs-morello-5.d

index cd54beec7b7d9f6b6977634dcd82501b80ab6cd4..939fac197d5dab3dcee8b9d820957e68419ca0af 100644 (file)
@@ -6460,6 +6460,18 @@ c64_fixup_frag (bfd *input_bfd, struct bfd_link_info *info,
   asection *perm_sec = sym_sec;
   bfd_boolean bounds_ok = FALSE;
 
+  const char *sym_name;
+
+  if (sym)
+    {
+      Elf_Internal_Shdr *symtab_hdr = &elf_symtab_hdr (input_bfd);
+      sym_name = (bfd_elf_string_from_elf_section (input_bfd,
+                                                  symtab_hdr->sh_link,
+                                                  sym->st_name));
+    }
+  else
+    sym_name = h->root.root.string;
+
   if (size == 0 && sym_sec)
     {
       bounds_ok = TRUE;
@@ -6492,11 +6504,13 @@ c64_fixup_frag (bfd *input_bfd, struct bfd_link_info *info,
 
   if (!bounds_ok && !c64_valid_cap_range (&base, &limit))
     {
+      /* Just warn about this.  It's not a requirement that bounds on
+        objects should be precise, so there's no reason to error out on
+        such an object.  */
       /* xgettext:c-format */
-      _bfd_error_handler (_("%pB: capability range may exceed object bounds"),
-                         input_bfd);
-      bfd_set_error (bfd_error_bad_value);
-      return bfd_reloc_notsupported;
+      _bfd_error_handler
+       (_("%pB: capability range for '%s' may exceed object bounds"),
+        input_bfd, sym_name);
     }
 
   if (perm_sec && perm_sec->flags & SEC_CODE)
index 05bbef145e03786dbb489b40441e78fbff69ddb5..7fa7909bdffd47c6877df709ad74d17bf0fc9c1f 100644 (file)
@@ -1,6 +1,4 @@
 #source: emit-relocs-morello-5.s
 #as: -march=morello+c64
 #ld: -static
-#error: .*: capability range may exceed object bounds
-#error: .*: in function `_start':.*
-#error: .*: dangerous relocation: unsupported relocation
+#warning: .*: capability range for 'bigarray' may exceed object bounds