[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] symbols: discard stray file symbols


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Thu, 4 Sep 2025 17:53:14 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zLg0Bop3g9RNrWHcZaV6FS1fa74+VJ9gCzTt5m86b3c=; b=RHxLlJb7z2Ec/8pyPgEsSCiQkuRzAXx1afAHePUBqQjF750p1pZMg7XtE/kSTSayEuZG5aF+8YlPEiPYMvq8GUeAkCjU13mfLIPbSnrvOfVr6MGTxObcTnL5BbleFVF5Ck458gyBwMDgoiM/F4tvKsi2XXDHIjqLyYKZd1kGk8Jxk9KlMDHnXiaBMX3WoWcMUfFe2nTI0qfqTabS4MxEYSB09bCZgTneW5lpBlxYJVOhNhckyY4wJdOEjjd52BlF4JIJRlJ5n7pP9wboyKBcaSZjk34/WzH6963fLvsyIHx10CdsWvrPb7k1ssCVVx8FQ17LXdFI/l+ZAgAwuGf6GQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NCg8Met6HEC96Lfkz2cLhNO7FaFbYTOEd67tLi358+VxazoNlHUEE2FRl6Sh6m/BP/JTM4FHR7Jiw652dttj6jwuHTZlQ+Fqaoyrp52bnptkvtPJ9ChzxUSAyNIw7+6va2H5NjePKdCA/o5T7IXbx9YkS9Xhe8H7J96Fi3VVMhLnP5qIC4ogoCdPShwUfqQFi7C0ReoIaPGv6dkIJirYBHeLGD/eb4cvhXPCNDUAE018qbNOynnReief8O0WdwTaHJWZ0+imqp4XIIt4iJag8f1ygRwve9onsrzGDMGeDEm7eV7XElmvCCUVDJtOxKPM/R6MNWbDgXtVeQ9ONgr14A==
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Thu, 04 Sep 2025 21:53:24 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 2025-04-16 05:00, Jan Beulich wrote:
By observation GNU ld 2.25 may emit file symbols for .data.read_mostly
when linking xen.efi. Due to the nature of file symbols in COFF symbol
tables (see the code comment) the symbols_offsets[] entries for such
symbols would cause assembler warnings regarding value truncation. Of
course the resulting entries would also be both meaningless and useless.
Add a heuristic to get rid of them, really taking effect only when
--all-symbols is specified (otherwise these symbols are discarded
anyway).

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
Factor 2 may in principle still be too small: We zap what looks like
real file symbols already in read_symbol(), so table_cnt doesn't really
reflect the number of symbol table entries encountered. It has proven to
work for me in practice though, with still some leeway left.

--- a/xen/tools/symbols.c
+++ b/xen/tools/symbols.c
@@ -213,6 +213,16 @@ static int symbol_valid(struct sym_entry
        if (strstr((char *)s->sym + offset, "_compiled."))
                return 0;
+ /* At least GNU ld 2.25 may emit bogus file symbols referencing a
+        * section name while linking xen.efi. In COFF symbol tables the
+        * "value" of file symbols is a link (symbol table index) to the next
+        * file symbol. Since file (and other) symbols (can) come with one
+        * (or in principle more) auxiliary symbol table entries, the value in
+        * this heuristic is bounded to twice the number of symbols we have
+        * found. See also read_symbol() as to the '?' checked for here. */
+       if (s->sym[0] == '?' && s->sym[1] == '.' && s->addr < table_cnt * 2)
+               return 0;
+
        return 1;
  }

I looked at this. It'll drop symbols, but I don't know enough to give an R-b. I can't give an actionable A-b either. Maybe someone else can chime in.

Maybe this is just showing my lack of knowledge, but could any symbol starting "?." be considered invalid? I don't think I've ever seen any like that.

Regards,
Jason



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.