------- Comment #27 from dannysmith at users dot sourceforge dot net 2008-10-01 10:22 ------- (In reply to comment #13) > Created an attachment (id=16425) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16425&action=view) [edit] > Revised patch with correct section switching > That patch causes other problems This test case:
/* t1.c */ int i[0]; int k; void testi (void) { i[0] = 0; } void testk (void) { k = 0; } int main (void) { return 0; } now fails with t1.c:(.text+0x5): undefined reference to `_i' The assembler code is .file "t1.c" .text .p2align 4,,15 .globl _testi .def _testi; .scl 2; .type 32; .endef _testi: pushl %ebp movl %esp, %ebp movl $0, _i popl %ebp ret .p2align 4,,15 .globl _testk .def _testk; .scl 2; .type 32; .endef _testk: pushl %ebp movl %esp, %ebp movl $0, _k popl %ebp ret .def ___main; .scl 2; .type 32; .endef .p2align 4,,15 .globl _main .def _main; .scl 2; .type 32; .endef _main: pushl %ebp movl %esp, %ebp andl $-16, %esp call ___main xorl %eax, %eax movl %ebp, %esp popl %ebp ret .bss .balign 4 .comm _i, 0 <<<<< size of i[0] .balign 4 .comm _k, 4 I suspect we need to add this bit, or similar, back in - rounded = size ? size : 1; - rounded += (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1; - rounded = (rounded / (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - * (BIGGEST_ALIGNMENT / BITS_PER_UNIT)); and output rounded rather than size. Testing now. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37216