public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Rafael Avila de Espindola <rafael.espindola@gmail.com>
To: binutils@sourceware.org
Cc: iant@google.com
Subject: [gold][patch] Don't put symbols dropped by the plugin in the symbol tables
Date: Thu, 17 Feb 2011 20:13:00 -0000	[thread overview]
Message-ID: <4D5D8153.70009@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 579 bytes --]

The attached patch avoids putting symbols in the symbol tables if there 
are only found in IL files. This is important for when LTO manages to 
drop some symbols completely.

When linking libxul it reduces the final .so from 39339456 bytes to 
34450128 bytes. And yes, firefox still works :-)

2010-02-17  Rafael Ávila de Espíndola <respindola@mozilla.com>

	* symtab.cc (Symbol::should_add_dynsym_entry) Return false for
	plugin only symbols.
	(Symbol_table::sized_finalize_symbol) Mark symbol only present
	in plugin files as not needed in the symbol table.

Cheers,
Rafael


[-- Attachment #2: symtab.patch --]
[-- Type: text/x-patch, Size: 1044 bytes --]

diff --git a/gold/symtab.cc b/gold/symtab.cc
index cb650fb..d4ac297 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -310,6 +310,11 @@ Sized_symbol<size>::allocate_common(Output_data* od, Value_type value)
 inline bool
 Symbol::should_add_dynsym_entry(Symbol_table* symtab) const
 {
+  // If the symbol is only present on plugin files, the plugin decided we
+  // don't need it.
+  if (!this->in_real_elf())
+    return false;
+
   // If the symbol is used by a dynamic relocation, we need to add it.
   if (this->needs_dynsym_entry())
     return true;
@@ -2593,6 +2598,15 @@ Symbol_table::sized_finalize_symbol(Symbol* unsized_sym)
       return false;
     }
 
+  // If the symbol is only present on plugin files, the plugin decided we
+  // don't need it.
+  if (!sym->in_real_elf())
+    {
+      gold_assert(!sym->has_symtab_index());
+      sym->set_symtab_index(-1U);
+      return false;
+    }
+
   // Compute final symbol value.
   Compute_final_value_status status;
   Value_type value = this->compute_final_value(sym, &status);

             reply	other threads:[~2011-02-17 20:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-17 20:13 Rafael Avila de Espindola [this message]
2011-02-18  5:43 ` Ian Lance Taylor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D5D8153.70009@gmail.com \
    --to=rafael.espindola@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=iant@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).