Moves of a value to a segment register from a 16-bit register is
equivalent to one from it's corresponding 32-bit register. Match gas's
behavior and rewrite instructions to the shorter of equivalent forms.
Details
Diff Detail
Event Timeline
I dono, if someone really writes movl %eax, %cs I would assume they really want the prefix, right? Obviously gas does something else, but that's surprising to me.
Adding Joerg's and my comments below because phabricator dropped them on the floor.
Nirav said:
The ISA doesn't actually have a 32-bit mov instruction of this form (though all the processors I've seen accept the bytes pattern associated with the 32-bit variant). I doubt that anyone
dealing with explicit segment twiddling ever wants the effectless prefix added. AFAIK these instructions are only ever emitted via explicit assembly so they it would be easy enough to
add the byte via an explicit ".byte" directive.
Ideally we'd only have the 16-bit mov instruction which accepts but ignores the OpSize prefix, but we need to accept the text syntax "mov %eax, %fs" to handle what objdump dumps,
hence this workaround.
Joerg Sonnenberger said:
Sometimes people want explicitly sized assembler for later runtime
patching. I'm not sure it matters in this case.
Joerg
Please make this and the comment below complete sentences.