添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

So I have a address in %eax I would like to jmp to but the code will not compile, is there a way around this?

movl 0xdeadbeef, %eax
jmp %eax ; <--- compile error: type mismatch for 'jmp'
                @Crashworks, only GAS (counting mainstream assemblers only) uses this weird and unreadable syntax...
– Griwes
                Apr 22, 2012 at 20:59
                I wonder why the only correct answer at the time being got voted down ^^ Care to explain, beloved downvoter?
– Gunther Piez
                Apr 23, 2012 at 10:10
                thanks @NiklasB.! I was just giving the idea... I'm not familiar with AT&T syntax, but I didn't want the idea to pass...
– guga
                Apr 22, 2012 at 21:07
                Note that most modern 80x86 CPUs keep track of calls/returns in a buffer so that they can predict what address RET will return to (and continue with speculative execution) before they know what RET will actually return to. Faked returns will kill that and hurt performance, starting with an immediate "return mispredicted" (rather than a possible "jmp/branch predicted") and possibly continuing with subsequent "return mispredictions" for the depth of the return buffer. Basically, don't do it unless you have to (and you don't have to in this case).
– Brendan
                Apr 22, 2012 at 22:59
                Good point @Brendan. But don't a JMP to register create similar penalty since the register content is unknown until the actual jump occurs? I tried to find a reference talking about penalties but I failed. Can you point me to one? Thanks!
– guga
                Apr 23, 2012 at 0:49
                For the first time executed, a calculated jump will not be predicted. But if it is executed more than once, the branch prediction might detect repeating target addresses (think of a default case in a switch statement) or repeating patterns (if there are any) of addresses. Of course, randomly taken branches will almost never be predicted correctly. Google for Agner Fog microarchitecture
– Gunther Piez
                Apr 23, 2012 at 10:08
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.