This is the mail archive of the
mailing list for the GCC project.
[PATCH] Fix wrong common symbol size in LTO symtabs.
- From: Dave Korn <dave dot korn dot cygwin at gmail dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 09 Nov 2010 21:40:49 +0000
- Subject: [PATCH] Fix wrong common symbol size in LTO symtabs.
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
* 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?
--- 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));
size = 0;