Debian GNU/Linux

Comment 1 for bug 82020

Philipp Kohlbecher (xt28) wrote :

Binary package hint: binutils

The following assembly code should produce a program that simply exits with status 0 (success).
-----------------------------------
.text
.globl _start
_start:
movl $1, %eax
movl $0, %ebx
call 0xffffe400
-----------------------------------

Calling absolute address 0xffffe400 should use the linux-gate mechanism to issue the _exit(2) system call.

However, after assembling with as (as -o exit.o exit.S, assuming the source file is named "exit.S") and linking with ld (ld -o exit exit.o), the resulting binary produces a segmentation fault instead of the desired behaviour.

Disassembling the object file "exit.o" with objdump -d -r yields:
-----------------------------------
00000000 <_start>:
   0: b8 01 00 00 00 mov $0x1,%eax
   5: bb 02 00 00 00 mov $0x2,%ebx
   a: e8 fc e3 ff ff call ffffe40b <_start+0xffffe40b>
                        b: R_386_PC32 *ABS*
-----------------------------------

Thus, the call to absolute address 0xffffe400 somehow gets mangled to a call to 0xffffe40b.

Disassembling the executable "exit" with objdump -d -r yields:
-----------------------------------
08048074 <_start>:
 8048074: b8 01 00 00 00 mov $0x1,%eax
 8048079: bb 02 00 00 00 mov $0x2,%ebx
 804807e: e8 fc e3 ff ff call 804647f <_start-0x1bf5>
-----------------------------------

In other words, the call got mangled even worse.

I am using dapper with binutils version 2.16.1cvs20060117-1ubuntu2.1.

This may be the same bug as debian bug #322478.