After blaming my kernel, then the dynamic linker it seems that the problem is in the binary file itself.
The problem is that when the code tries to get the address of the GOT, the address is two bytes out.
objdump output:
Code: Select all
627: e8 00 05 00 00 call b2c <_sbrk+0xa5>
62c: 81 c3 aa 1d 00 00 add $0x1daa,%ebx
632: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
639: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
640: 8b 83 f8 ff ff ff mov -0x8(%ebx),%eax
646: 8b 00 mov (%eax),%eax
**SNIP**
b2c: 8b 1c 24 mov (%esp),%ebx
b2f: c3 ret
I am using the standard linux toolchain (Ubuntu 9.04, gcc 4.3.3, binutils 2.19.1), compiling the library with
Code: Select all
$(CC) -Wall -fPIC -nostdinc -fno-builtin -I./include -fleading-underscore -DBUILD_SO -o $@ -c $<
Code: Select all
$(LD) -x -shared -soname libc.so.1 $(OBJ_LIBC) -o $@ -Map map.txt -e _SoMain