public inbox for gas2@sourceware.org
 help / color / mirror / Atom feed
* A PREFIX_SEPARATOR bug in binutils 2.9
@ 1998-04-21 11:41 H.J. Lu
  1998-04-21 11:54 ` Ian Lance Taylor
  0 siblings, 1 reply; 11+ messages in thread
From: H.J. Lu @ 1998-04-21 11:41 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gas2

Hi,

In binutils, PREFIX_SEPARATOR is defined as '/' for x86. But there
is

#if defined (TE_I386AIX) || defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
const char comment_chars[] = "#/";
#else
const char comment_chars[] = "#";
#endif

in config/tc-i386.c. It makes '/' to start a comment. It won't work.
We can define PREFIX_SEPARATOR as

#if defined (TE_I386AIX) || defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
#define PREFIX_SEPARATOR '\\'
#else
#define PREFIX_SEPARATOR '/'
#endif

But I don't like it. Any suggestion how to fix it?

Thanks.



-- 
H.J. Lu (hjl@gnu.org)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: A PREFIX_SEPARATOR bug in binutils 2.9
  1998-04-21 11:41 A PREFIX_SEPARATOR bug in binutils 2.9 H.J. Lu
@ 1998-04-21 11:54 ` Ian Lance Taylor
  1998-04-21 12:32   ` H.J. Lu
  0 siblings, 1 reply; 11+ messages in thread
From: Ian Lance Taylor @ 1998-04-21 11:54 UTC (permalink / raw)
  To: hjl; +Cc: gas2

   From: hjl@lucon.org (H.J. Lu)
   Date: Tue, 21 Apr 1998 11:41:32 -0700 (PDT)

   In binutils, PREFIX_SEPARATOR is defined as '/' for x86. But there
   is

   #if defined (TE_I386AIX) || defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
   const char comment_chars[] = "#/";
   #else
   const char comment_chars[] = "#";
   #endif

   in config/tc-i386.c. It makes '/' to start a comment. It won't work.

Why do you say ``it won't work?''  What do you mean?  That code has
been there since May 1993, so clearly it can work.

   We can define PREFIX_SEPARATOR as

   #if defined (TE_I386AIX) || defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
   #define PREFIX_SEPARATOR '\\'
   #else
   #define PREFIX_SEPARATOR '/'
   #endif

   But I don't like it. Any suggestion how to fix it?

What is the actual problem you are trying to solve?

Ian

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: A PREFIX_SEPARATOR bug in binutils 2.9
  1998-04-21 11:54 ` Ian Lance Taylor
@ 1998-04-21 12:32   ` H.J. Lu
  1998-04-21 12:39     ` Ian Lance Taylor
  0 siblings, 1 reply; 11+ messages in thread
From: H.J. Lu @ 1998-04-21 12:32 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gas2

> 
>    From: hjl@lucon.org (H.J. Lu)
>    Date: Tue, 21 Apr 1998 11:41:32 -0700 (PDT)
> 
>    In binutils, PREFIX_SEPARATOR is defined as '/' for x86. But there
>    is
> 
>    #if defined (TE_I386AIX) || defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
>    const char comment_chars[] = "#/";
>    #else
>    const char comment_chars[] = "#";
>    #endif
> 
>    in config/tc-i386.c. It makes '/' to start a comment. It won't work.
> 
> Why do you say ``it won't work?''  What do you mean?  That code has

PREFIX_SEPARATOR indicates a prefix, like

	data16PREFIX_SEPARATORmov foo,%eax

But '/' is also used to start a comment. So

	data16/mov foo,%eax

becomes

	data16

after preprocessing.

> been there since May 1993, so clearly it can work.
> 

Apparently, noone tried to use it or reported it.

>    We can define PREFIX_SEPARATOR as
> 
>    #if defined (TE_I386AIX) || defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
>    #define PREFIX_SEPARATOR '\\'
>    #else
>    #define PREFIX_SEPARATOR '/'
>    #endif
> 
>    But I don't like it. Any suggestion how to fix it?
> 
> What is the actual problem you are trying to solve?
> 

Can you try the code below on x86/elf?

# gcc -v x.s -c
# objdump -d x.o
# gcc -v x.s -c -Wa,-f
# objdump -d x.o

H.J.
----x.s--
/xmxmmmmmmmx
	data16/mov 	foo,%ax

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: A PREFIX_SEPARATOR bug in binutils 2.9
  1998-04-21 12:39         ` Ian Lance Taylor
@ 1998-04-21 12:32           ` Martynas Kunigelis
  1998-04-21 12:34             ` Ian Lance Taylor
  1998-04-21 12:34           ` H.J. Lu
  1 sibling, 1 reply; 11+ messages in thread
From: Martynas Kunigelis @ 1998-04-21 12:32 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: hjl, gas2, kunimart

On Tue, 21 Apr 1998, Ian Lance Taylor wrote:

> 
> Why not encourage people to write the prefix on a separate line, which
> works for both a.out and ELF?
> 

And you can do it on the same line, use ';':

data16; mov foo,%eax

Martynas



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: A PREFIX_SEPARATOR bug in binutils 2.9
  1998-04-21 12:39         ` Ian Lance Taylor
  1998-04-21 12:32           ` Martynas Kunigelis
@ 1998-04-21 12:34           ` H.J. Lu
  1998-04-21 12:39             ` Ian Lance Taylor
  1 sibling, 1 reply; 11+ messages in thread
From: H.J. Lu @ 1998-04-21 12:34 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gas2, kunimart

> Why not encourage people to write the prefix on a separate line, which
> works for both a.out and ELF?
> 

That is a separate issue. Since PREFIX_SEPARATOR is wrong on ELF, we
should fix it. I think we can change it

#define PREFIX_SEPARATOR '\\'

so that everyone will be happy.

-- 
H.J. Lu (hjl@gnu.org)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: A PREFIX_SEPARATOR bug in binutils 2.9
  1998-04-21 12:32           ` Martynas Kunigelis
@ 1998-04-21 12:34             ` Ian Lance Taylor
  0 siblings, 0 replies; 11+ messages in thread
From: Ian Lance Taylor @ 1998-04-21 12:34 UTC (permalink / raw)
  To: martynas; +Cc: hjl, gas2, kunimart

   Date: Tue, 21 Apr 1998 21:32:37 +0200 (MET DST)
   From: Martynas Kunigelis <martynas@nm3.ktu.lt>

   On Tue, 21 Apr 1998, Ian Lance Taylor wrote:

   > 
   > Why not encourage people to write the prefix on a separate line, which
   > works for both a.out and ELF?
   > 

   And you can do it on the same line, use ';':

   data16; mov foo,%eax

Oh yeah.

That works with the UnixWare assembler as well.

Ian

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: A PREFIX_SEPARATOR bug in binutils 2.9
  1998-04-21 12:32   ` H.J. Lu
@ 1998-04-21 12:39     ` Ian Lance Taylor
  1998-04-21 12:39       ` H.J. Lu
  0 siblings, 1 reply; 11+ messages in thread
From: Ian Lance Taylor @ 1998-04-21 12:39 UTC (permalink / raw)
  To: hjl; +Cc: gas2

   From: hjl@lucon.org (H.J. Lu)
   Date: Tue, 21 Apr 1998 12:02:45 -0700 (PDT)

   PREFIX_SEPARATOR indicates a prefix, like

	   data16PREFIX_SEPARATORmov foo,%eax

   But '/' is also used to start a comment. So

	   data16/mov foo,%eax

   becomes

	   data16

   after preprocessing.

Thanks.  If you include a test case with a bug report, it will save
everybody's time.

   > been there since May 1993, so clearly it can work.

   Apparently, noone tried to use it or reported it.

So the next question is whether we think this ought to work.

Evidently gcc does not generate code of this form, or this would have
been noticed long ago.

Note that there is another way to accomplish this:
	data16
	mov 	foo,%eax

I tried the test case
	data16/mov foo,%eax
on the UnixWare assembler, and it failed there as well.  In fact, the
reason gas uses '/' to start a comment for i386 ELF is because that is
how the UnixWare assembler behaves.

Putting data16 on a separate line, as above, works with both gas and
the UnixWare assembler.

I don't know if the UnixWare assembler permits you to specify a prefix
on the same line as an instruction.  I tried a few other characters,
but I couldn't find anything that worked.

So I'm not sure whether we need to change anything here.

Ian

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: A PREFIX_SEPARATOR bug in binutils 2.9
  1998-04-21 12:34           ` H.J. Lu
@ 1998-04-21 12:39             ` Ian Lance Taylor
  1998-04-21 17:45               ` Alan Modra
  0 siblings, 1 reply; 11+ messages in thread
From: Ian Lance Taylor @ 1998-04-21 12:39 UTC (permalink / raw)
  To: hjl; +Cc: gas2, kunimart

   From: hjl@lucon.org (H.J. Lu)
   Date: Tue, 21 Apr 1998 12:34:46 -0700 (PDT)

   > Why not encourage people to write the prefix on a separate line, which
   > works for both a.out and ELF?
   > 

   That is a separate issue. Since PREFIX_SEPARATOR is wrong on ELF, we
   should fix it. I think we can change it

   #define PREFIX_SEPARATOR '\\'

   so that everyone will be happy.

I am questioning the need for PREFIX_SEPERATOR at all.  I don't see
any particular reason to use it on ELF if it is not required and if no
other ELF assembler supports it.

Since changing PREFIX_SEPERATOR to a backslash won't help any existing
code, nor help any person that I know of, nor conform to any existing
documentation, I don't see any reason to do it.

I think it would make more sense to remove PREFIX_SEPERATOR entirely
from the i386 ELF assembler.  However, since the existing assembler
appears to work, and it has many far more serious coding problems,
that would be a zero priority change.

Ian

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: A PREFIX_SEPARATOR bug in binutils 2.9
  1998-04-21 12:39       ` H.J. Lu
@ 1998-04-21 12:39         ` Ian Lance Taylor
  1998-04-21 12:32           ` Martynas Kunigelis
  1998-04-21 12:34           ` H.J. Lu
  0 siblings, 2 replies; 11+ messages in thread
From: Ian Lance Taylor @ 1998-04-21 12:39 UTC (permalink / raw)
  To: hjl; +Cc: gas2, kunimart

   From: hjl@lucon.org (H.J. Lu)
   Date: Tue, 21 Apr 1998 12:24:22 -0700 (PDT)

   If we don't change, PREFIX_SEPARATOR is just a dummy for x86/ELF. If
   someone writes some asm code for both ELF/a.out and use '/' as
   PREFIX_SEPARATOR, the error may not be discovered at the assembly time.

Yes, this is one of the things you have to be aware of if you want to
write code that will work for both a.out and ELF.

   Martynas Kunigelis <kunimart@pit.ktu.lt> found this while working on
   16bit support in gas. Since PREFIX_SEPARATOR has never really been used
   and has never worked, I suggest we change it to somethin else. Martynas
   used '\\' for x86/ELF. But I don't like it. On the other hand, I haven't
   found one I really like. I guess I can live with '\\'. We can just
   define PREFIX_SEPARATOR as '\\' for all x86. At least, it will work
   if someone really wants to use it.

Why not encourage people to write the prefix on a separate line, which
works for both a.out and ELF?

Does anybody know how the SCO assembler works for code like this?
	data16
	mov 	foo,%eax

Ian

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: A PREFIX_SEPARATOR bug in binutils 2.9
  1998-04-21 12:39     ` Ian Lance Taylor
@ 1998-04-21 12:39       ` H.J. Lu
  1998-04-21 12:39         ` Ian Lance Taylor
  0 siblings, 1 reply; 11+ messages in thread
From: H.J. Lu @ 1998-04-21 12:39 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gas2, kunimart

> Evidently gcc does not generate code of this form, or this would have
> been noticed long ago.
> 
> Note that there is another way to accomplish this:
> 	data16
> 	mov 	foo,%eax
> 
> I tried the test case
> 	data16/mov foo,%eax
> on the UnixWare assembler, and it failed there as well.  In fact, the
> reason gas uses '/' to start a comment for i386 ELF is because that is
> how the UnixWare assembler behaves.
> 
> Putting data16 on a separate line, as above, works with both gas and
> the UnixWare assembler.
> 
> I don't know if the UnixWare assembler permits you to specify a prefix
> on the same line as an instruction.  I tried a few other characters,
> but I couldn't find anything that worked.
> 
> So I'm not sure whether we need to change anything here.
> 

If we don't change, PREFIX_SEPARATOR is just a dummy for x86/ELF. If
someone writes some asm code for both ELF/a.out and use '/' as
PREFIX_SEPARATOR, the error may not be discovered at the assembly time.

Martynas Kunigelis <kunimart@pit.ktu.lt> found this while working on
16bit support in gas. Since PREFIX_SEPARATOR has never really been used
and has never worked, I suggest we change it to somethin else. Martynas
used '\\' for x86/ELF. But I don't like it. On the other hand, I haven't
found one I really like. I guess I can live with '\\'. We can just
define PREFIX_SEPARATOR as '\\' for all x86. At least, it will work
if someone really wants to use it.

Thanks.


-- 
H.J. Lu (hjl@gnu.org)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: A PREFIX_SEPARATOR bug in binutils 2.9
  1998-04-21 12:39             ` Ian Lance Taylor
@ 1998-04-21 17:45               ` Alan Modra
  0 siblings, 0 replies; 11+ messages in thread
From: Alan Modra @ 1998-04-21 17:45 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gas2, martynas, hjl

> 
>    From: hjl@lucon.org (H.J. Lu)
>    Date: Tue, 21 Apr 1998 12:34:46 -0700 (PDT)
> 
>    > Why not encourage people to write the prefix on a separate line, which
>    > works for both a.out and ELF?
>    > 
> 
>    That is a separate issue. Since PREFIX_SEPARATOR is wrong on ELF, we
>    should fix it. I think we can change it
> 
>    #define PREFIX_SEPARATOR '\\'
> 
>    so that everyone will be happy.
> 
> I am questioning the need for PREFIX_SEPERATOR at all.  I don't see
> any particular reason to use it on ELF if it is not required and if no
> other ELF assembler supports it.

The only reason I can think of is that we may want to treat prefixes
on a separate line differently to prefixes specified "with the
instruction"

eg.  We might find it desirable for
	ds
	lgdt	0
to emit the ds prefix while
	ds/ldgt 0  (or whatever the syntax is)
or
	lgdt	%ds:0
shouldn't. ie. gas realises that ds is the default segment.

Martynas (martynas@nm3.ktu.lt) has been working on a 16 bit capable
gas, and he's keeping track of address size prefixes as a means to
tell the assembler that the next instruction is a 16 bit one.

For instance `addr16; mov 0,%ebx' generates   67 8b 1e 00 00	
       while         `mov 0,%ebx' generates      8b 1d 00 00 00 00
So the `addr16' can't just be emitted; It considerably effects
following code, and not just offset sizes, but modrm bytes too.

I'm wondering if this is really a good idea.  Maybe it would be better
if addr16 didn't effect the code generated, and instead we require a
`.code16' directive.

How do other unix assemblers handle 16 bit code?  Or don't they?
Can someone with access to Unixware, SCO, etc. assemblers do some
experimentation please?

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~1998-04-21 17:45 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-04-21 11:41 A PREFIX_SEPARATOR bug in binutils 2.9 H.J. Lu
1998-04-21 11:54 ` Ian Lance Taylor
1998-04-21 12:32   ` H.J. Lu
1998-04-21 12:39     ` Ian Lance Taylor
1998-04-21 12:39       ` H.J. Lu
1998-04-21 12:39         ` Ian Lance Taylor
1998-04-21 12:32           ` Martynas Kunigelis
1998-04-21 12:34             ` Ian Lance Taylor
1998-04-21 12:34           ` H.J. Lu
1998-04-21 12:39             ` Ian Lance Taylor
1998-04-21 17:45               ` Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).