Stream: project-inline-asm

Topic: Symbol names with intel syntax


Amanieu (Feb 29 2020 at 18:05, on Zulip):

I've just come across a pretty significant issue with Intel syntax: some symbol names can't be represented.

Amanieu (Feb 29 2020 at 18:06, on Zulip):

For example eax, byte, etc.

Amanieu (Feb 29 2020 at 18:06, on Zulip):
mov eax, eax # is this a symbol or a register
Amanieu (Feb 29 2020 at 18:06, on Zulip):

There doesn't appear to be a solution https://sourceware.org/bugzilla/show_bug.cgi?id=37

Amanieu (Feb 29 2020 at 18:11, on Zulip):

LLVM's internal assembler seems to be able to parse quoted strings as symbols: "eax"

Amanieu (Feb 29 2020 at 18:11, on Zulip):

But that doesn't work in GAS: "eax" is still parsed as a register name

Hanna Kruppe (Feb 29 2020 at 18:22, on Zulip):

I don't really see how that's significant for Rust inline asm, can you elaborate? One would have to deliberately give a symbol one of these names with #[no_mangle] (and use it with intel-style asm) to run into this, and platform-/toolchain-dependent breakage when giving symbols certain "reserved" names is nothing new or specific to inline asm. It also isn't novel that assemblers have all sorts of weird corner cases that vary between implementations or versions.

Amanieu (Feb 29 2020 at 18:23, on Zulip):

It is significant because we provide a sym operand type which will insert the symbol of a given static or fn into the asm code.

Amanieu (Feb 29 2020 at 18:24, on Zulip):

You would expect this to work correctly for all symbol names.

Hanna Kruppe (Feb 29 2020 at 18:25, on Zulip):

I realize that, but as I said you'd have to deliberately pick such a name with #[no_mangle] and when you do that, there's a million things other than inline asm that can break depending on the name.

Amanieu (Feb 29 2020 at 18:26, on Zulip):

Eh, fair enough.

Last update: Jul 02 2020 at 19:35UTC