Timothy Leung
Timothy Leung

Reputation: 1465

Confusion in assembly line $lea 0xffffffe8(%ebp)$

Dump of assembler code for function ckpass:
0x0804851e <ckpass+0>: push %ebp
0x0804851f <ckpass+1>: mov %esp,%ebp
0x08048521 <ckpass+3>: sub $0x38,%esp
0x08048524 <ckpass+6>: movl $0x10,0x8(%esp)
0x0804852c <ckpass+14>: movl $0x0,0x4(%esp)
0x08048534 <ckpass+22>: lea 0xffffffe8(%ebp),%eax
0x08048537 <ckpass+25>: mov %eax,(%esp)
0x0804853a <ckpass+28>: call 0x80483dc <_init+136>
0x0804853f <ckpass+33>: lea 0xffffffe8(%ebp),%eax
0x08048542 <ckpass+36>: mov %eax,(%esp)
0x08048545 <ckpass+39>: call 0x804839c <_init+72>
*0x0804854a <ckpass+44>: lea 0xffffffe8(%ebp),%eax*
0x0804854d <ckpass+47>: mov %eax,0x4(%esp)
0x08048551 <ckpass+51>: lea 0xffffffd8(%ebp),%eax
0x08048554 <ckpass+54>: mov %eax,(%esp)
0x08048557 <ckpass+57>: call 0x8048571 <hashpass>
0x0804855c <ckpass+62>: lea 0xffffffd8(%ebp),%eax
0x0804855f <ckpass+65>: movl $0x80486e8,0x4(%esp)
0x08048567 <ckpass+73>: mov %eax,(%esp)
0x0804856a <ckpass+76>: call 0x804838c <_init+56>
0x0804856f <ckpass+81>: leave
0x08048570 <ckpass+82>: ret

This is a disassembly from

int ckpass()
{
    char a[____];
    char b[____];
    memset(_________, _____, _____);
    gets(________);
    hashpass(b, a);
    return strcmp(________, good_hash);
}

What exactly lea 0xffffffe8(%ebp),%eax means?

I thought lea s(%ebp), %eax is equal to eax = epb + s

I search in google, it said it means buffer.

But I have buffer a and buffer b in this example, how can i distinguish them?

Upvotes: 0

Views: 507

Answers (1)

Seva Alekseyev
Seva Alekseyev

Reputation: 61331

It means eax := ebp - 16. The disassembler can't tell between signed and unsigned constants. The command loads an address of some variable on the stack into eax.

Upvotes: 2

Related Questions