Quoting Jan Hubicka <hubi...@ucw.cz>:

Perhaps we can somehow poison the object names that are brought local with -fwhole-program
so linking explode, but I am not sure there is way to do so.

The linker will generally emit a diagnostic when the size or alignment of a symbol increases, or the type changes.
Unfortunately, this makes the warnings dependent on the link order and type
of symbols; I see no way to make it warn about common symbols without
alignment which are linked after poisoned symbols.

[amyl...@meolyon symclash]$ tail a.c b.S c.c
==> a.c <==
int i;
char c;

==> b.S <==
        .section .note.poison
        .globl i
        .type   i, @function
i:      .size   i, 0
        .globl c
        .type   c, @function
c:      .size   c, 43

==> c.c <==
int main ()
{
  return 0;
}
[amyl...@meolyon symclash]$ gcc a.c b.S c.c --save-temps
/usr/bin/ld: Warning: alignment 1 of symbol `i' in b.o is smaller than 4 in a.o
/usr/bin/ld: Warning: type of symbol `i' changed from 1 to 2 in b.o
/usr/bin/ld: Warning: size of symbol `c' changed from 1 in a.o to 43 in b.o
/usr/bin/ld: Warning: type of symbol `c' changed from 1 to 2 in b.o
[amyl...@meolyon symclash]$ gcc b.S a.c c.c -Wall --save-temps
/usr/bin/ld: Warning: alignment 1 of symbol `i' in b.o is smaller than 4 in a.o

Reply via email to