The gcc -S
option will generate assembly code in AT&T syntax, is there a way to generate files in Intel syntax? Or is there a way to convert between the two?
-
Unfortunately gcc can't do this and conversion is difficult because some instructions in AT&T take operands in the same order as Intel, so you have to special case. In addition, some conversions for size where memory dereferencing and such can be difficult. Your best bet is to use a disassembler that will do what you want and make sure you reference symbol files and such. This'll get you 99% of the way.
Jason Dagit : Sounds like someone should add an option for this to gcc seeing as it's free software and all.Cody Brocious : Good luck. Binutils (the component that handles all of this) is quite possibly the worst piece of software in the world to work with. Biggest mess of arcane, black voodoo code ever written.romandas : This may be a wrong answer - one should check Dagit's answer below for a working solution.Nathan Fellman : This is definitely wrong. @hyperlogic, you should change the accepted answerFrom Cody Brocious -
Have you tried this?
gcc -S -masm=intel test.c
Untested, but I found it in this forum where someone claimed it worked for them.
I just tried this on the mac and it failed, so I looked in my man page:
-masm=dialect Output asm instructions using selected dialect. Supported choices are intel or att (the default one). Darwin does not support intel.
It may work on your platform.
I also see this sed script which is not perfect, but may work for you.
Jichao : -masm=intel works on my debian/i386.Thomas : Confirmed to work on Ubuntu Karmic x64 as well.Michael Burr : Worked on my MingGW 3.4.5. Many thanks!From Jason Dagit -
Try:
gcc code.c -S -masm=intel
Jason Dagit's suggestion works.
0 comments:
Post a Comment