Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Indirect Intersegment Jump

222 views
Skip to first unread message

abhishek

unread,
Jun 28, 2009, 9:02:23 PM6/28/09
to

Thanks a lot to everyone. The following assembly instructions worked
for near indirect jump.

> mov $main, %edx #copies address of main function in %edx
> jmp *%edx

If I store the addredd of 'main' in 'jumpBuffer' location, I able to
use the previous example using following code as well

jmp *jumpBuffer # unsigned long jumpBuffer

Now I want to perform an intersegment indirect jump. The location of
the jump address will be stored in 'jumpBuffer'.

.globl jumpBuffer
.data
.type jumpBuffer, @object
.size jumpBuffer, 8 # I store the offset (4
bytes) and segment selector (2 bytes) in the jumpBuffer
# struct jump_address
{ unsigned long offset; unsigned short selector} jumpBuffer;

So if I get in correctly, the indirect intersegment jump instruction
will be written as,

jmp *jumpBuffer

objdump shows the same instruction opcode as was given by earlier
example.

ff 25 XX XX XX XX jmp *0x8049ffc

The opcode has to be different as the processor needs to distinguish
between the near indirect jumps and indirect intersegment jumps. I
have not tested it in userspace. If I am not wrong intersegment jumps
are not allowed in userspace. Please let me know the correct
instruction.

Thanks in advance,
Abhishek

cr88192

unread,
Jun 28, 2009, 10:31:02 PM6/28/09
to

"abhishek" <abhishek.s...@MUNGED.microcosmotalk.com> wrote in message
news:4a48129f$0$5071$9a6e...@unlimited.newshosting.com...

in the ASM you actually need to use a different instruction...

in Intel style ASM, this would be something like:
jmp far [jmpbuf]

but, in gas it would probably be something like:
ljmp *jmpbuf


but, be sure the segment is correct before doing the jump...


> Thanks in advance,
> Abhishek


Rod Pemberton

unread,
Jun 29, 2009, 5:03:06 AM6/29/09
to

"abhishek" <abhishek.s...@MUNGED.microcosmotalk.com> wrote in message
news:4a48129f$0$5071$9a6e...@unlimited.newshosting.com...
> The opcode has to be different as the processor needs to distinguish
> between the near indirect jumps and indirect intersegment jumps. I
> have not tested it in userspace. If I am not wrong intersegment jumps
> are not allowed in userspace. Please let me know the correct
> instruction.
>

Well, I don't see the 0xe9 jmp in GNU binutils (GAS) i386-opc.tbl. This is
the syntax for the other jmp encodings:

jmp main
jmpl *main
ljmp *main
jmp *%edx
jmp *(%edx)
ljmp *(%edx)
ljmp $segment,$main


Rod Pemberton


0 new messages