This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: i386/x86_64 segment register issuses


On Mon, Mar 28, 2005 at 01:57:17AM -0500, Ross Ridge wrote:
> > The current gas will accept this and. But if fsindex is ever a memory
> > operand,
> > 
> >                 asm volatile("movl %%fs,%0" : "=g" (fsindex));
> > 
> > fsindex will have some random value in the upper 16bits.
> 
> fsindex will have whatever value it had before in the upper 16-bits.
> It's only undefined because of a bug in the Linux kernel, not because
> the instruction itself ever produces an undefined result when a memory
> operand is used.  This kind of move instruction can never have a 32-bit
> memory operand.

The assembler in CVS generates the same binary code as

	movw %ds,(%eax)

for

	movl %ds,(%eax)

But the previous assemblers will generate

	66 8c 18   movw   %ds,(%eax)

for

	movw %ds,(%eax)

This bug has been fixed for a while. I guess that may be why Linux
kernel uses

	movl %ds,(%eax)

My patch will force

	movw %ds,(%eax)

which will add the unnecessary "0x66" with older assemblers. I guess I
will add a switch to assembler to allow

	movl %ds,(%eax)

and the kernel will check and use it.


H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]