[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
A problem about i386ex board
- Date: 12 Aug 1999 21:01:27 -0000
- From: biguo at 263.net (biguo at 263.net)
- Subject: A problem about i386ex board
> biguo at 263.net wrote:
>
> > > biguo at 263.net wrote:
> > >
> > > > hello,everyone!Recently I met a strange problem about i386ex board.In last a few weeks I have completely burn and run the hello_world_c DEMO."hello world" have been appeared in com2.But since 26,July,there are no any reponse after hello_world_c demo is burned and run.I have made no changes about Linux and RTEMS.But I compiled a program with other cross compiler,such as MOCROTEC VTEX.After > the > program is burned and run in i386ex board,it's all fine.Why?Are there something wrong with cross gcc compiler or i386ex board?I'm puzzled.Can anybody tell me the possible reasons?Thanks in advance for any help.
> > > >
> > > > _____________________________________________
> > > > ????????--???????????????????? http://www.263.net
> > > > ???????? ???????? ???????? ???????? ??????????
> > > > ???????? ???????? ???????? ???????? ????????
> > > > ???????? ???????? ???????? ???????? ????????
> > >
> > > There is a possible problem with your start.S file. Please insert these two nop instructions into start.S:
> > >
> > > .section .initial
> > > nop /* required for linker -- initial jump is to "label - 2" */
> > > nop /* ie. _initInternalRegisters -2 ( which now == .initial ) */
> > >
> > > If you're start.S already has these two nop's then I don't know what could be wrong. Please tell me if your start.S has or does not have these two nop instructions, and I will provide a patch to the RTEMS people.
> > >
> > > Thanks.
> >
> > > (????:??????"text/x-vcard",??????"vcard.vcf")
> > >
> >
> > Mr. ivanenko:
> > You're right.There aren't two "nop" instructions before SYM( _initInternalRegisters) in start.s.I add two "nop" instructions there.It's all fine.But I don't understand what's the reason.Is it relative with gcc?Is it relative with INTEL X86 processor?Thank you.
> >
> > _____________________________________________
> > ????????--???????????????????? http://www.263.net
> > ???????? ???????? ???????? ???????? ??????????
> > ???????? ???????? ???????? ???????? ????????
> > ???????? ???????? ???????? ???????? ????????
>
> This is a programming problem:
>
> The problem is because gcc is defaulting to .code32, so the instruction jmp SYM(_initInternalRegisters) is assuming that the jmp offset is rel32. This means that an address 4 bytes long is the offset specified by the compiler for the jump instruction. Hence, the compiler sets the offset relative to the next instruction, which is 4 bytes away.
>
> But the processor is running in real mode at this time, hence the address of the jump offset can only be two bytes long. So, the processor assumes that the address of the next instruction is only 2 bytes away, and uses that address instead as the base for the jmp.
>
> Since the jump is a near jump, only the lower 16 bits of the address are significant. The jump actually does jump two bytes too far. Adding the 2 nops solves this problem without assuming that the compiler is capable of understanding the .code16 directive. It also makes a dissassembled listing readable.
>
> If you are using a compiler that supports the .code16 directive, putting it before the .reset section SHOULD also work, but then disassembly with objdump will fail.
>
> I do not have a working test facility for the board available at this time. If you could try adding .code16 before the jmp SYM(_initInternalRegisters) and removing the two nops, I'd love to know if it actually works -- the final srecord in hello.i does show a change in the offset and size of instruction.
>
>
>
> (????:??????"text/x-vcard",??????"vcard.vcf")
>
Because SYM(_initInternalRegisters) is public symbol,I find out that it has been allocated to 4 bytes address by gcc.Though I add .code16 before .reset section,it doesn't work.If SYM(_initInternalRegisters) isn't a public symbol,it will be 2 bytes.Hence,it works well.Meanwhile,I use disassembler to find out that SYM(_initInternalRegisters) is a 2 bytes address at this time.Why SYM(_initInternalRegisters) is defined as public symbol?Is SYM(_initInternalRegisters) defined as a local symbole?If so,don't need to add two "nop" instruction before SYM(_initInternalRegisters).Which choice is more reasonable?
The modified part of start.s look like as the following:
.
.
.
/*PUBLIC( SYM(_initInternalRegisters) )*/
.
.
.
.section .reset
PUBLIC ( SYM(reset) )
SYM(reset):
.code16 /*ADD*/
nop
cli
cld
jmp SYM(_initInternalRegisters) /* different section in this file */
.code32 /* in case this section moves */
nop /* required by CHIP LAB to pad out size */
nop
nop
nop
nop
.section .initial
SYM(_initInternalRegisters):
.code16
_____________________________________________
????????--???????????????????? http://www.263.net
???????? ???????? ???????? ???????? ??????????
???????? ???????? ???????? ???????? ????????
???????? ???????? ???????? ???????? ????????