]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
readelf: Do not warn about mapping symbols that extend beyond the end of mergeable...
authorNick Clifton <nickc@redhat.com>
Mon, 8 Dec 2025 12:17:28 +0000 (12:17 +0000)
committerNick Clifton <nickc@redhat.com>
Mon, 8 Dec 2025 12:18:03 +0000 (12:18 +0000)
binutils/readelf.c

index 064c16056a27b45db5188e1268b4596aa4e59565..b001d7177462939d0477bd6ffd22d83dfbce12e6 100644 (file)
@@ -14665,6 +14665,18 @@ print_symbol_size (uint64_t vma, int base)
     }
 }
 
+/* The AArch64, ARM and RISC-V architectures define mapping
+   symbols (eg $d, $x, $t) which sometime should be ignored.  */
+
+static bool
+is_mapping_symbol (const char * name)
+{
+  return name[0] == '$'
+    && name [1] != 0
+    /* FIXME: Check that name[1] is lower case ASCII ?  */
+    && name [2] == 0;
+}
+
 /* Print information on a single symbol.  */
 
 static void
@@ -14801,7 +14813,9 @@ print_symbol (Filedata *           filedata,
 
   /* Local symbols whose value is larger than their section's size are suspicious
      especially if that section is mergeable - and hence might change offsets of
-     the contents inside the section.  */
+     the contents inside the section.
+     Note - for some reason we can get mapping symbols that do not relate to their
+     section's contents - so we ignore those type of symbol as well.  */
   if (ELF_ST_BIND (psym->st_info) == STB_LOCAL
       && ! is_special
       && is_valid
@@ -14809,7 +14823,8 @@ print_symbol (Filedata *           filedata,
       && filedata->section_headers != NULL
       /* FIXME: Should we warn for non-mergeable sections ? */
       && (filedata->section_headers[psym->st_shndx].sh_flags & SHF_MERGE)
-      && psym->st_value > filedata->section_headers[psym->st_shndx].sh_size)
+      && psym->st_value > filedata->section_headers[psym->st_shndx].sh_size
+      && ! is_mapping_symbol (strtab + psym->st_name))
     warn (_("local symbol %s has a value (%#" PRIx64 ") which is larger than mergeable section %s's size (%#" PRIx64 ")\n"),
          strtab + psym->st_name,
          psym->st_value,
@@ -23032,9 +23047,7 @@ get_symbol_for_build_attribute (Filedata *filedata,
 
        /* The AArch64, ARM and RISC-V architectures define mapping symbols
           (eg $d, $x, $t) which we want to ignore.  */
-       if (ba_cache.strtab[sym->st_name] == '$'
-           && ba_cache.strtab[sym->st_name + 1] != 0
-           && ba_cache.strtab[sym->st_name + 2] == 0)
+       if (is_mapping_symbol (ba_cache.strtab + sym->st_name))
          continue;
 
        if (is_open_attr)