| Branch: | Revision:

root / linux-user / elfload.c @ a4c075f1

History | View | Annotate | Download (80.5 kB)

# Date Author Comment
a4c075f1 05/20/2011 06:35 pm Ulrich Hecht

s390x: s390x-linux-user support

This patch adds support for running s390x binaries in the linux-user emulation

Signed-off-by: Ulrich Hecht <>
Signed-off-by: Alexander Graf <>

d2fbca94 04/12/2011 09:49 pm Guan Xuetao

unicore32: necessary modifications for other files to support unicore32

Signed-off-by: Guan Xuetao <>
Signed-off-by: Blue Swirl <>

80f5ce75 02/17/2011 11:46 am Laurent Vivier

linux-user: correct core dump format

This patch allows to really use the core dumped by qemu with guest
architecture tools.

- it adds a missing bswap_phdr() for the program headers
of memory regions.

"objdump -x" sample:


0x1000000 off 0x00200000 vaddr 0x00000400 paddr 0x00000000 align 2**21...

1af02e83 02/09/2011 10:33 am Mike Frysinger

linux-user/elfload: add FDPIC support

Signed-off-by: Mike Frysinger <>
Signed-off-by: Riku Voipio <>

8d79de6e 02/09/2011 10:33 am Stefan Weil

linux-user: Fix possible realloc memory leak

Extract from "man realloc":
"If realloc() fails the original block is left untouched;
it is not freed or moved."

Fix a possible memory leak (reported by cppcheck).

Cc: Riku Voipio <>
Signed-off-by: Stefan Weil <>...

5d5c9930 07/29/2010 07:54 pm Richard Henderson

linux-user: Protect against allocation failure in load_symbols.

Cc: malc <>
Signed-off-by: Richard Henderson <>
Signed-off-by: malc <>

9955ffac 07/29/2010 09:32 am Richard Henderson

linux-user: Reduce lseek+reads while loading elf files.

Define BPRM_BUF_SIZE to 1k and read that amount initially. If the
data we want from the binary is in this buffer, use it instead of
reading from the file again.

Signed-off-by: Richard Henderson <>...

28490231 07/29/2010 09:32 am Richard Henderson

linux-user: Define ELF_DATA generically.

The only consideration on this value is the target endianness.
The existing defines were incorrect for alpha and sh4eb.

Signed-off-by: Richard Henderson <>
Signed-off-by: Edgar E. Iglesias <>

991f8f0c 07/29/2010 09:32 am Richard Henderson

linux-user: Clean up byte-swapping in elfload.c.

Remove ifdefs from code by defining empty inline functions
when byte swapping isn't needed. Push loops over swapping
arrays of structures into the swapping functions.

Signed-off-by: Richard Henderson <>...

682674b8 07/29/2010 09:32 am Richard Henderson

linux-user: Load symbols from the interpreter.

First, adjust load_symbols to accept a load_bias parameter. At the same
time, read the entire section header table in one go, use pread instead
f lseek+read for the symbol and string tables, and properly free...

9058abdd 07/29/2010 09:32 am Richard Henderson

linux-user: Improve consistency checking in elf headers.

Validate more fields of the elf header. Extract those checks
into two common functions to be used in both load_elf_interp
and load_elf_binary.

Signed-off-by: Richard Henderson <>
Signed-off-by: Edgar E. Iglesias <>

60dcbcb5 07/29/2010 09:32 am Richard Henderson

linux-user: Put the stack guard page at the top.

There are no supported stack-grows-up targets. We were putting
the guard page at the highest address, i.e. the bottom of the stack.
Use the maximum of host and guest page size for the guard size.

Signed-off-by: Richard Henderson <>...

b9329d4b 07/29/2010 09:32 am Richard Henderson

linux-user: Remove partial support for a.out interpreters.

At the bottom of the a.out support was the unimplemented load_aout_interp
function. There were other portions of the support that didn't look
right; when I went to look in the Linux kernel for clarification, I found...

8e62a717 07/29/2010 09:32 am Richard Henderson

linux-user: Extract load_elf_image from load_elf_interp.

Moving toward a single copy of the elf binary loading code.
Fill in the details of the loaded image into a struct image_info.

Adjust create_elf_tables to read from such structures instead
of from a collection of passed arguments. Don't return error...

bf858897 07/29/2010 09:32 am Richard Henderson

linux-user: Re-use load_elf_image for the main binary.

This requires moving the PT_INTERP extraction and GUEST_BASE
handling into load_elf_image. Key this off a non-null pointer
argument to receive the interpreter name.

Signed-off-by: Richard Henderson <>...

cf129f3a 07/29/2010 09:32 am Richard Henderson

linux-user: Handle filesz < memsz for any PT_LOAD segment.

I caught padzero not properly initializing the .bss segment
on a statically linked Alpha program. Rather than a minimal
patch, replace the gross code with a single mmap+memset.

Share more code between load_elf_interp and load_elf_binary....

e167d46c 07/29/2010 09:32 am Richard Henderson

Add more DT_* and AT_* constants to qemu's copy of elf.h.

Moving some PPC AT_* constants from elfload.c at the same time.

Signed-off-by: Richard Henderson <>
Signed-off-by: Edgar E. Iglesias <>

d97ef72e 07/29/2010 09:32 am Richard Henderson

linux-user: Reindent elfload.c.

Signed-off-by: Richard Henderson <>
Signed-off-by: Edgar E. Iglesias <>

97374d38 06/16/2010 03:03 pm Paul Brook

Usermode exec-stack fix

When loading a shared library that requires an executable stack,
glibc uses the mprotext PROT_GROWSDOWN flag to achieve this.
We don't support PROT_GROWSDOWN.
Add a special case to handle changing the stack permissions in this way....

68a1c816 05/29/2010 04:27 am Paul Brook

Pre-allocate guest address space

Allow pre-allocation of the guest virtual address space in usermode emulation.

Signed-off-by: Paul Brook <>

0d5d4699 05/19/2010 04:24 pm Edgar E. Iglesias

microblaze: Update elf machine nums.

189 was allocated in upstream binutils.

0xbaab was the old temporary value. Still used by some tools and the
linux kernel.

I've seen 115 in older gdb versions, but lets ignore that one.

Signed-off-by: Edgar E. Iglesias <>

e4cbd44d 05/19/2010 04:09 pm Edgar E. Iglesias

microblaze: Add linux-user core dumping support.

Signed-off-by: Edgar E. Iglesias <>

2e9a5713 05/05/2010 06:32 pm Paul Brook


The usermode PAGE_RESERVED code is not required by the current mmap
implementation, and is already broken when guest_base != 0.
Unfortunately the bsd emulation still uses the old mmap implementation,
so we can't rip it out altogether....

c581deda 05/05/2010 06:32 pm Paul Brook

Better default guest_base

Avoid loading linux-user applications in address space already used/reserved
by the host.

Signed-off-by: Paul Brook <>

7983f435 03/28/2010 05:52 pm Rob Landley

linux-user/ppc: use the Linux register layout

The dynamic linker converts the Linux layout to the AIX layout and is
reentrant so it won't do it a second time if it's already been
converted. In short it work just fine with either register layout.

OTOH, statically linked binaries expect a Linux layout....

703e0e89 03/27/2010 03:16 pm Richard Henderson

linux-user: Use RLIMIT_STACK for default stack size.

The current default stack limit of 512kB is far too small; a fair
number of gcc testsuite failures (for all guests) are directly
attributable to this. Using the -s option in every invocation of
the emulator is annoying to say the least....

b480d9b7 03/13/2010 01:25 am Paul Brook

Fix usermode virtual address type

Usermode virtual addresses are abi_ulong, not target_ulong.

Signed-off-by: Paul Brook <>

9f9f0309 03/01/2010 06:39 am Paul Brook

Disassembler symbol lookup fix

Fix function signature for userspace disassembler symbol lookup.

Signed-off-by: Paul Brook <>

0ddbc96e 01/17/2010 10:51 am Mike Frysinger

fix linux-user microblaze ELF_ARCH definition

Signed-off-by: Mike Frysinger <>
Signed-off-by: Edgar E. Iglesias <>

49995e17 12/19/2009 09:29 pm Aurelien Jarno

linux-user: use TARGET_ABI_FMT_lx to print abi_ulong types

Signed-off-by: Aurelien Jarno <>

dd0a3651 12/19/2009 09:29 pm Nathan Froyd

linux-user: fix ELF_USE_CORE_DUMP/USE_ELF_CORE_DUMP confusion

Signed-off-by: Nathan Froyd <>
Signed-off-by: Aurelien Jarno <>

21e807fa 12/19/2009 09:29 pm Nathan Froyd

linux-user: commonify definitions of target typedefs

There's no sense in separately declaring target_{elf_greg,uid,gid,pid}_t
for every architecture. Just declare them once with appropriate
USE_UID16 handling.

Signed-off-by: Nathan Froyd <>...

d049e626 12/19/2009 09:29 pm Nathan Froyd

linux-user: fix ARM core dumps on opposite-endian hosts

Signed-off-by: Nathan Froyd <>
Signed-off-by: Aurelien Jarno <>

e2f3e741 12/19/2009 09:29 pm Nathan Froyd

linux-user: add core dump support for PPC

Signed-off-by: Nathan Froyd <>
Signed-off-by: Aurelien Jarno <>

51e52606 12/19/2009 09:29 pm Nathan Froyd

linux-user: add core dump support for MIPS

Signed-off-by: Nathan Froyd <>
Signed-off-by: Aurelien Jarno <>

7a93cc55 12/19/2009 09:29 pm Nathan Froyd

linux-user: add core dump support for M68K

Signed-off-by: Nathan Froyd <>
Signed-off-by: Aurelien Jarno <>

7631c97e 12/19/2009 09:29 pm Nathan Froyd

linux-user: add core dump support for SH

Signed-off-by: Nathan Froyd <>
Signed-off-by: Aurelien Jarno <>

8a57a6c7 12/13/2009 09:32 pm Richard Henderson

target-alpha: Drop bogus UNIQ initial value on Linux.

Signed-off-by: Richard Henderson <>
Signed-off-by: Aurelien Jarno <>

cf6de34a 10/16/2009 02:37 pm Riku Voipio

linux-user: Update ARM hwcaps

Update ARM hwcaps to match Linux kernel 2.6.31 state

Signed-off-by: Riku Voipio <>

3bc0bdca 10/04/2009 02:24 pm Paul Bolle

linux-user: fix "#if 0"'d printf()

Make an "#if 0"'d printf() in load_elf_binary(), probably left to aid in
debugging, reflect what the actual code does. The current printf() will
only confuse those who "#if 1" it (it certainly confused me enough to
write this trivial patch)....

c227f099 10/02/2009 12:12 am Anthony Liguori

Revert "Get rid of _t suffix"

In the very least, a change like this requires discussion on the list.

The naming convention is goofy and it causes a massive merge problem. Something
like this must be presented on the list first so people can provide input...

99a0949b 10/01/2009 09:45 pm malc

Get rid of _t suffix

Some not so obvious bits, slirp and Xen were left alone for the time

Signed-off-by: malc <>

6ece4df6 09/30/2009 09:45 pm Michael S. Tsirkin

elfload: fix coding style nit

Put space between = and * when dereferencing a pointer,
to avoid confusion with old-style "*="

Signed-off-by: Michael S. Tsirkin <>
Signed-off-by: Blue Swirl <>

ca20cf32 09/20/2009 05:58 pm Blue Swirl

Compile loader only once

Callers must pass ELF machine, byte swapping and symbol LSB clearing
information to ELF loader. A.out loader needs page size information, pass
that too as a parameter.

Extract prototypes to a separate file. Move loader.[ch] and elf_ops.h under hw....

72cf2d4f 09/12/2009 10:36 am Blue Swirl

Fix sys-queue.h conflict for good

Problem: Our file sys-queue.h is a copy of the BSD file, but there are
some additions and it's not entirely compatible. Because of that, there have
been conflicts with system headers on BSD systems. Some hacks have been
introduced in the commits 15cc9235840a22c289edbe064a9b3c19c5f49896,...

ec822001 08/10/2009 09:05 pm Laurent Desnogues

Fix symfind.

this patch fixes an issue in symfind.

Assume you have the following symbols:

Address Size
0045bca0 00000080 T s0
0045bd20 00000112 T s1

You'll notice that s1 is s0 + size.

So the current symfind will find that address 0045bd20 belongs to s0...

7cba04f6 08/01/2009 01:13 pm Blue Swirl

More NULL pointer fixes

Signed-off-by: Blue Swirl <>

9fdca5aa 07/18/2009 12:17 pm malc

Use correct byteswap routine for elf_note

All elf64_note structure members are Elf64_Word (which is 32bit value)
hence using bswaptls to byteswap it on 64bit platforms is incorrect.

Signed-off-by: malc <>

3efa9a67 07/18/2009 12:16 pm malc

Avoid name clashes with symbols that leak from system headers

Signed-off-by: malc <>

a2547a13 07/17/2009 03:33 pm Laurent Desnogues

ELF codedump build failures

Rename ELF coredump types to avoid conflict with the corresponding host types.

Signed-off-by: Laurent Desnogues <>

379f6698 07/17/2009 03:12 pm Paul Brook

Userspace guest address offsetting

Re-implement GUEST_BASE support.
Offset guest ddress space by default if the guest binary contains
regions below the host mmap_min_addr.
Implement support for i386, x86-64 and arm hosts.

Signed-off-by: Riku Voipio <>...

edf8e2af 06/16/2009 04:56 pm Mika Westerberg

linux-user: implemented ELF coredump support for ARM target

When target process is killed with signal (such signal that
should dump core) a coredump file is created. This file is
similar than coredump generated by Linux (there are few exceptions

9edc5d79 06/16/2009 04:56 pm Mika Westerberg

linux-user: added x86 and x86_64 support for ELF coredump

Signed-off-by: Mika Westerberg <>
Signed-off-by: Riku Voipio <>

b779e29e 05/26/2009 10:10 pm Edgar E. Iglesias

microblaze: linux-user support.

Signed-off-by: Edgar E. Iglesias <>

df84e4f3 05/16/2009 12:36 am Nathan Froyd

support ELF_HWCAP for PPPC

Signed-off-by: Nathan Froyd <>
Signed-off-by: malc <>

93fcfe39 01/16/2009 12:34 am aliguori

Convert references to logfile/loglevel to use qemu_log*() macros

This is a large patch that changes all occurrences of logfile/loglevel
global variables to use the new qemu_log*() macros.

Signed-off-by: Eduardo Habkost <>
Signed-off-by: Anthony Liguori <>...

e58ffeb3 01/14/2009 08:39 pm malc

Remove all traces of powerpc

According to $GCC/gcc/config/rs6000/rs6000-c.c _ARCH_PPC is the
ubiquitous define which should be used to test whether gcc targets
PowerPC, on 64bit platforms _ARCH_PPC64 will be also defined.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

49918a75 10/22/2008 06:11 pm pbrook
  • Use function pointers for symbol lookup (currently for elf32 and elf64,
    could be expanded). This also fixes the bug with mips elf64 symbols
    in current Qemu trunk.
  • Use quicksort and binary search for symbol lookup.
  • Remove unneeded entries from symbol table. This reduced a typical table...
440c7e85 10/05/2008 02:05 pm blueswir1

Export x86_stack_size in qemu.h

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

98448f58 09/30/2008 09:16 pm blueswir1

Silence some warnings about uninitialized variables

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

b55266b5 09/20/2008 11:07 am blueswir1

Suppress gcc 4.x -Wpointer-sign (included in -Wall) warnings

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

a6cc84f4 08/21/2008 01:39 am malc

Kludge to support linux-user on a PPC64

Some headers (e.g. signal.h) include asm/elf.h and the chaos of macro
redefinitions ensues, this kludge avoids it.

Alternative way to fight that would be to change all ELF_XXX and some
other definitions to QEMU_ELF_XXX or something to that effect....

d5975363 06/07/2008 11:50 pm pbrook

Multithreaded locking fixes.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

a07c67df 03/27/2008 01:31 am pbrook

Implement AT_CLKTCK.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

2f619698 11/16/2007 12:46 pm bellard

suppressed tgetx and tputx (initial patch by Thayne Harbaugh)

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

579a97f7 11/11/2007 04:26 pm bellard

Linux user memory access API change (initial patch by Thayne Harbaugh)

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

623a930e 10/28/2007 09:45 pm ths

Implement missing MIPS supervisor mode bits.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

a32ff1ad 10/27/2007 08:29 pm j_mayer

PowerPC user-mode fix: MSR is now entirelly set-up in the cpu_reset routine.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

e85e7c6e 10/18/2007 10:59 pm j_mayer

Use the new TARGET_ABI32 feature to implement a ppc64abi32-linux-user target
(PowerPC 64 running in 32 bits mode).
Use the new TARGET_ABI_DIR feature to implement a ppcemb-linux-user target
(PowerPC 32 with 64 bits GPRs and vector extensions).

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

992f48a0 10/14/2007 07:27 pm blueswir1

Support for 32 bit ABI on 64 bit targets (only enabled Sparc64)

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

cb33da57 10/09/2007 07:34 pm blueswir1

Support for executing 32 bit SPARC32PLUS files for Sparc64 user emulator

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

48733d19 10/08/2007 04:36 pm ths

CRIS Linux userland emulation, part 2. By Edgar E. Iglesias.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

863cf0b7 10/07/2007 06:59 pm j_mayer

Fix confusions between host and target long types.
Fix start_data computation.
Fix auxiliary infos setup.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

4118a970 09/27/2007 07:10 am j_mayer

memset string pages to zero to avoid putting random data on the stack
that may make some program crash at startup.
Fix unsigned long / target_ulong confusion (more to do).
Fix missing g2h macros.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

92a343da 09/27/2007 04:14 am j_mayer

New ppc64-linux-user target.
Allow use of PowerPC 970 for debugging (softmmu would not run, for now).

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

3b46e624 09/17/2007 11:09 am ths

find -type f | xargs sed -i 's/[\t ]*$//g' # Yes, again. Note the star in the regex.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

5fafdf24 09/17/2007 12:08 am ths

find -type f | xargs sed -i 's/[\t ]$//g' # on most files

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

0774bed1 07/05/2007 04:23 pm blueswir1

Fix 64 bit ELF file symbol lookup

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

072ae847 06/22/2007 01:13 pm ths

Setup stack properly, fixes wrong argc value problem, by Magnus Damm.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

e91c8a77 06/03/2007 04:35 pm ths

Spelling fixes, by Stefan Weil.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

388bb21a 05/13/2007 04:58 pm ths

MIPS linux-user update.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

84409ddb 04/06/2007 11:56 am j_mayer

Code provision for x86_64 and PowerPC 64 linux user mode support.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

7a3148a9 04/05/2007 10:13 am j_mayer

Preliminary patch for Alpha Linux user mode emulation support.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

768a4a36 12/14/2006 03:32 pm ths

Fix userland ELF loader for zero sized BSS.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

e6e5906b 10/22/2006 03:18 am pbrook

ColdFire target.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

5ef54116 07/19/2006 12:14 am bellard

Sparc64 user emulator fixes (Blue Swirl)

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

e5fe0c52 06/11/2006 04:32 pm pbrook

bFLT loader (for uClinux binaries).

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

fdf9b3e8 04/28/2006 12:07 am bellard

sh4 target (Samuel Tardieu)

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

53a5960a 03/25/2006 09:31 pm pbrook

Avoid accessing guest memory directly in usermode emulation.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

e89f07d3 02/04/2006 10:46 pm pbrook

Make target_mmap always return -1 on failure.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

0240ded8 02/04/2006 09:30 pm pbrook

Correctly initialize Arm CPU for Thumb entry points.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

048f6b4d 11/26/2005 08:47 pm bellard

mips user emulation

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

15338fd7 11/26/2005 01:41 pm bellard

added AT_PLATFORM and AT_HWCAP for x86 (initial patch by Gwenole Beauchesne)

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

afce2927 10/30/2005 10:58 pm bellard

Arm AT_HWCAP AUXV entry (Paul Brook)

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

0bccf03d 08/21/2005 01:12 pm bellard

fix AUX vector entries (Paul Brook)

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

92a31b1f 02/11/2005 12:00 am bellard

64 bit support

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

a315a145 01/31/2005 12:59 am bellard

initial sparc64 support

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

e80cfcfc 12/20/2004 01:18 am bellard

SPARC merge

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

83fb7adf 07/06/2004 12:25 am bellard

Darwin patch (initial patch by Pierre d'Herbemont)

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

eba2af63 06/19/2004 08:23 pm bellard

buffer overflow fix

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162