This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix wrong common symbol size in LTO symtabs.


    Hello list,

  While trying out LTO bootstraps using GNU LD on x86_64 linux, I kept
noticing these linker warnings crop up:

> ld: Warning: alignment 8 of symbol `libiberty_concat_ptr' in
> /tmp/cc8L5wpz.ltrans5.ltrans.o is smaller than 16 in concat.o.ironly?
> ld: Warning: size of symbol `libiberty_concat_ptr' changed from 64 in
> concat.o.ironly? to 8 in /tmp/cc8L5wpz.ltrans5.ltrans.o

  The code that writes out LTO symbols needs to pass the size of COMMON
symbols to the linker.  In what looks like a trivial thinko, it uses DECL_SIZE
to get this value; but DECL_SIZE is the size in bits, and the symbol needs to
contain the size in bytes.  I took a look at how emit_common() is called,
which turns out to be indirectly from assemble_noswitch_variable(), and it
uses DECL_SIZE_UNITS there to get the correct byte-size for the asm directive
that declares the COMMON object in the real object code, so I figured the IR
should match.

gcc/ChangeLog:

	* lto-streamer-out.c (write_symbol): Use DECL_SIZE_UNITS to get size
	of common symbols in bytes, not DECL_SIZE which returns bitsize.

  Now undergoing bootstraps vs. both GOLD and GNU LD, vs. normal or
lto-bootstrap, on x86_64-unknown-linux-gnu.  OK assuming no regressions?

    cheers,
      DaveK


Index: gcc/lto-streamer-out.c
===================================================================
--- gcc/lto-streamer-out.c	(revision 166297)
+++ gcc/lto-streamer-out.c	(working copy)
@@ -2435,8 +2435,8 @@ write_symbol (struct lto_streamer_cache_d *cache,
   if (kind == GCCPK_COMMON
       && DECL_SIZE (t)
       && TREE_CODE (DECL_SIZE (t)) == INTEGER_CST)
-    size = (((uint64_t) TREE_INT_CST_HIGH (DECL_SIZE (t))) << 32)
-      | TREE_INT_CST_LOW (DECL_SIZE (t));
+    size = (((uint64_t) TREE_INT_CST_HIGH (DECL_SIZE_UNIT (t))) << 32)
+      | TREE_INT_CST_LOW (DECL_SIZE_UNIT (t));
   else
     size = 0;
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]