On Linux/ia32, when I compile SPEC CPU 2006 is with -O3 -mfpmath=sse -msse2 -funroll-loops -ffast-math -fwhole-program -flto=jobserver -fuse-linker-plugin using GCC configured with --with-plugin-ld=ld, using binutils as of 2010-10-20 CVS, I got 403.gcc /usr/local/bin/ld: Warning: alignment 4 of symbol `dconst2' in /tmp/ccAavrnI.ltrans9.ltrans.o is smaller than 16 in emit-rtl.o.ironly /usr/local/bin/ld: Warning: alignment 4 of symbol `dconstm1' in /tmp/ccAavrnI.ltrans9.ltrans.o is smaller than 16 in emit-rtl.o.ironly /usr/local/bin/ld: Warning: alignment 8 of symbol `dconst1' in /tmp/ccAavrnI.ltrans16.ltrans.o is smaller than 16 in emit-rtl.o.ironly /usr/local/bin/ld: Warning: alignment 4 of symbol `dconst0' in /tmp/ccAavrnI.ltrans29.ltrans.o is smaller than 16 in emit-rtl.o.ironly /usr/local/bin/ld: Warning: alignment 4 of symbol `sizetype_tab' in /tmp/ccAavrnI.ltrans30.ltrans.o is smaller than 16 in stor-layout.o.ironly readelf -s emit-rtl.o | grep dconst 498: 00000004 24 OBJECT GLOBAL DEFAULT COM dconst0 499: 00000004 24 OBJECT GLOBAL DEFAULT COM dconst1 500: 00000004 24 OBJECT GLOBAL DEFAULT COM dconst2 501: 00000004 24 OBJECT GLOBAL DEFAULT COM dconstm1 The normal symbols have 4 byte alignments, but their IR-only counter ones seem to have 16byte alignment.
/* A symbol belonging to an input file managed by the plugin library. */ struct ld_plugin_symbol { char *name; char *version; int def; int visibility; uint64_t size; char *comdat_key; int resolution; }; For ELF common symbols, we also need value which holds the symbol alignment. Since it is missing, BFD linker plugin generates wrong values for ELF common symbols.
Since plugin doesn't care about alignment of common symbol, we should just use 1 byte alignment. Linker will pick the largest one.
Something like this --- diff --git a/ld/plugin.c b/ld/plugin.c index 79b39e8..78815da 100644 --- a/ld/plugin.c +++ b/ld/plugin.c @@ -292,6 +292,9 @@ asymbol_from_plugin_symbol (bfd *abfd, asymbol *asym, flags = BSF_GLOBAL; section = bfd_com_section_ptr; asym->value = ldsym->size; + /* For ELF targets, set alignment of common symbol to 1. */ + if (bfd_get_flavour (abfd) == bfd_target_elf_flavour) + ((elf_symbol_type *) symbol)->internal_elf_sym.st_value = 1; break; default: ----
A patch is posted at http://sourceware.org/ml/binutils/2010-11/msg00371.html
Fixed.
Thank you.
*** Bug 12564 has been marked as a duplicate of this bug. ***