To understand how things work, this is how valgrind starts up: - The valgrind launcher (/usr/bin/valgrind) is run. - The launcher decides which tool you want execs it to replace the launcher. - The tool binary loads at a high address then acts as an ELF loader and loads the target program into the same process, using LD_PRELOAD to try and inject a small amount of code into it.
Run "ld --verbose" to see the default linker script, and note the line . = 0x08048000 + SIZEOF_HEADERS; This is the problem. ld estimates SIZEOF_HEADERS, and sometimes guesses low by 1 Elf32_Phdr (or by 2 in extremely rare cases). A workaround is to capture the default linker script "ld --verbose >script.lds", delete the header and trailer lines [delimited by '====='], change the initial address to ". = 0x08048000 + 52 + 8*32;" where 52 is sizeof(Elf32_Ehdr) and 32 is sizeof(Elf32_Phdr), then use the resulting script to replace the default: "ld -T script.lds ..."
Here are some things to do: o Study the info pages that come with ld. See ld.info, Node: Builtin Functions, SIZEOF_HEADERS. o Compare the elf linker scripts (probably in /usr/i486-suse-linux/lib/ldscripts/ on your system) against standard ones. eg. from ftp.varesearch.com/pub/support/hjl/binutils/ If they are different, try the standard scripts. o Delete SIZEOF_HEADERS from your linker script, and replace with a fixed number. Try 1024. o If all this fails, post a bug report to firstname.lastname@example.org