crtstuff.c change is bad for (at least) OpenServer
Robert Lipe
robertl@dgii.com
Fri Jan 23 13:30:00 GMT 1998
> > I can't figure out of this is actually a bug or not, but I've partially
> > analyzed a one line change that EGCS just inherited from 2.8.0 that kills
> > COFF code generation on OpenServer dead. I've cc'ed Richard in hopes
> > he can further comment becuase I think this change was his on Dec. 23.
Someone has mentioned that other COFF targets are affected by this, too.
> > crtstuff.c has recently started to look like this:
[ Assembly output of good vs. bad assembler output deleted ]
> > before we start to execute any of the user's code. */
> Well, the code looks reasonable -- ie I don't think we want either the
> prologue or the epilogue in that code.
OK. Perhaps the problem isn't that we need to shed the epilogue.
Perhaps it's that we didn't shed the prologue. We have an imbalance
one way or the other.
> However, we don't know what the final executable looks like, which is
> important when analyzing failures in the .init support.
We can do that easily enough...
When the asm (TEXT_SECTION_ASM_OP) in the COFF __do_global_ctors_aux ()
is enabled, the disassembly of our linked (core-dumping) COFF program
starts off like this:
Disassembly of section .text:
000000d0 <_init> pushl %ebp
000000d1 <_init+1> movl %esp,%ebp
000000d3 <_init+3> subl $0x8,%esp
000000d6 <_init+6> pushl %ebx
000000d7 <_init+7> pushl $0x0
000000d9 <_init+9> nop
000000da <_init+a> nop
000000db <_init+b> nop
000000dc <.init> movl %esp,0xfffffff8(%ebp)
000000df <.init+3> movl 0xfffffff8(%ebp),%eax
000000e2 <.init+6> movl %eax,0xfffffffc(%ebp)
000000e5 <.init+9> movl 0xfffffffc(%ebp),%eax
000000e8 <.init+c> cmpl $0x0,(%eax)
000000eb <.init+f> jne 000000f0 <.init+14>
000000ed <.init+11> jmp 00000100 <.init+24>
000000ef <.init+13> nop
000000f0 <.init+14> movl 0xfffffffc(%ebp),%eax
000000f3 <.init+17> addl $0x4,0xfffffffc(%ebp)
000000f7 <.init+1b> movl (%eax),%ebx
000000f9 <.init+1d> call *%ebx
000000fb <.init+1f> jmp 000000e5 <.init+9>
000000fd <.init+21> nop
000000fe <.init+22> nop
000000ff <.init+23> nop
00000100 <.init+24> jmp 00000108 <.init+2c>
00000102 <.init+26> nop
00000103 <.init+27> nop
00000104 <.init+28> jmp 000000dc <.init>
00000106 <.init+2a> nop
00000107 <.init+2b> nop
00000108 <.init+2c> pushl $0x0
0000010a <.init+2e> nop
0000010b <.init+2f> nop
0000010c <.init> ret $0x0
0000010f <.init+3> nop
00000110 <_start> pushl $0x0
00000112 <_start+2> pushl $0x0
00000114 <_start+4> movl %esp,%ebp
00000116 <_start+6> pushl %edx
00000117 <_start+7> movl $0x97e0,%eax
Now, if we look at the startup on a functioning binary (one with the
line in crtstuff.c commented out) it looks more like:
Disassembly of section .text:
000000d0 <_init> pushl %ebp
000000d1 <_init+1> movl %esp,%ebp
000000d3 <_init+3> subl $0x8,%esp
000000d6 <_init+6> pushl %ebx
000000d7 <_init+7> pushl $0x0
000000d9 <_init+9> nop
000000da <_init+a> nop
000000db <_init+b> nop
000000dc <.init> movl %esp,0xfffffff8(%ebp)
000000df <.init+3> movl 0xfffffff8(%ebp),%eax
000000e2 <.init+6> movl %eax,0xfffffffc(%ebp)
000000e5 <.init+9> movl 0xfffffffc(%ebp),%eax
000000e8 <.init+c> cmpl $0x0,(%eax)
000000eb <.init+f> jne 000000f0 <.init+14>
000000ed <.init+11> jmp 00000100 <.init+24>
000000ef <.init+13> nop
000000f0 <.init+14> movl 0xfffffffc(%ebp),%eax
000000f3 <.init+17> addl $0x4,0xfffffffc(%ebp)
000000f7 <.init+1b> movl (%eax),%ebx
000000f9 <.init+1d> call *%ebx
000000fb <.init+1f> jmp 000000e5 <.init+9>
000000fd <.init+21> nop
000000fe <.init+22> nop
000000ff <.init+23> nop
00000100 <.init+24> jmp 00000108 <.init+2c>
00000102 <.init+26> nop
00000103 <.init+27> nop
00000104 <.init+28> jmp 000000dc <.init>
00000106 <.init+2a> nop
00000107 <.init+2b> nop
00000108 <.init+2c> movl 0xfffffff4(%ebp),%ebx
0000010b <.init+2f> movl %ebp,%esp
0000010d <.init+31> popl %ebp
0000010e <.init+32> ret
0000010f <.init+33> pushl $0x0
00000111 <.init+35> nop
00000112 <.init+36> nop
00000113 <.init+37> nop
00000114 <.init> ret $0x0
00000117 <.init+3> nop
00000118 <_start> pushl $0x0
0000011a <_start+2> pushl $0x0
0000011c <.text+4> movl %esp,%ebp
0000011e <.text+6> pushl %edx
A side-by-side diff makes the difference a little more apparant:
a.out.bad a.out.good
00000102 <.init+26> nop 00000102 <.init+26> nop
00000103 <.init+27> nop 00000103 <.init+27> nop
00000104 <.init+28> jmp 000000dc < 00000104 <.init+28> jmp 000000dc <
00000106 <.init+2a> nop 00000106 <.init+2a> nop
00000107 <.init+2b> nop 00000107 <.init+2b> nop
00000108 <.init+2c> pushl $0x0 | 00000108 <.init+2c> movl 0xfffffff4
0000010a <.init+2e> nop | 0000010b <.init+2f> movl %ebp,%esp
0000010b <.init+2f> nop | 0000010d <.init+31> popl %ebp
0000010c <.init> ret $0x0 | 0000010e <.init+32> ret
0000010f <.init+3> nop | 0000010f <.init+33> pushl $0x0
00000110 <_start> pushl $0x0 | 00000111 <.init+35> nop
00000112 <_start+2> pushl $0x0 | 00000112 <.init+36> nop
00000114 <_start+4> movl %esp,%ebp | 00000113 <.init+37> nop
00000116 <_start+6> pushl %edx | 00000114 <.init> ret $0x0
00000117 <_start+7> movl $0x97e0,%e | 00000117 <.init+3> nop
Or is a disassembly of just crt*.o more what you had in mind?
Thanx for any help offered.
--
Robert Lipe http://www.dgii.com/people/robertl robertl@dgii.com
More information about the Gcc
mailing list