summaryrefslogtreecommitdiffstats
path: root/linux-user/elfload.c
Commit message (Collapse)AuthorAgeFilesLines
* unicore32: necessary modifications for other files to support unicore32Guan Xuetao2011-04-121-0/+74
| | | | | Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* linux-user: correct core dump formatLaurent Vivier2011-02-171-16/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: BEFORE: 0x1000000 off 0x00200000 vaddr 0x00000400 paddr 0x00000000 align 2**21 filesz 0x00000000 memsz 0x00100000 flags --- 0x1000000 off 0x00200000 vaddr 0x00100400 paddr 0x00000000 align 2**21 filesz 0x00000000 memsz 0x00080000 flags --- 6000000 AFTER: LOAD off 0x00002000 vaddr 0x00040000 paddr 0x00000000 align 2**13 filesz 0x00000000 memsz 0x00001000 flags --- LOAD off 0x00002000 vaddr 0x00041000 paddr 0x00000000 align 2**13 filesz 0x00000000 memsz 0x00000800 flags rw- - it doesn't pad the note size to sizeof(int32_t). On m68k the NT_PRSTATUS note size is 154 and must not be rounded up to 156, because this value is checked by objdump and gdb. "gdb" symptoms: "warning: Couldn't find general-purpose registers in core file." "objdump -x" sample: BEFORE: Sections: Idx Name Size VMA LMA File off Algn 0 note0 000001c4 00000000 00000000 000003b4 2**0 CONTENTS, READONLY 1 .auxv 00000070 00000000 00000000 00000508 2**2 CONTENTS 2 proc1 00100000 00000400 00000000 00200000 2**10 READONLY AFTER: Sections: Idx Name Size VMA LMA File off Algn 0 note0 000001c4 00000000 00000000 000003b4 2**0 CONTENTS, READONLY 1 .reg/19022 00000050 00000000 00000000 0000040e 2**2 CONTENTS 2 .reg 00000050 00000000 00000000 0000040e 2**2 CONTENTS 3 .auxv 00000070 00000000 00000000 00000508 2**2 CONTENTS 4 load1 00000000 00040000 00000000 00002000 2**13 ALLOC, READONLY Signed-off-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
* linux-user/elfload: add FDPIC supportMike Frysinger2011-02-091-0/+71
| | | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
* linux-user: Fix possible realloc memory leakStefan Weil2011-02-091-3/+5
| | | | | | | | | | | | 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 <riku.voipio@iki.fi> Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
* linux-user: Protect against allocation failure in load_symbols.Richard Henderson2010-07-291-0/+10
| | | | | | Cc: malc <av1474@comtv.ru> Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: malc <av1474@comtv.ru>
* linux-user: Re-use load_elf_image for the main binary.Richard Henderson2010-07-291-277/+103
| | | | | | | | | 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 <rth@twiddle.net> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
* linux-user: Extract load_elf_image from load_elf_interp.Richard Henderson2010-07-291-174/+167
| | | | | | | | | | | | | | 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 values from load_elf_interp; always exit(-1) with a message to stderr. Collect elf_interpreter handling in load_elf_binary to a common spot. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
* linux-user: Remove partial support for a.out interpreters.Richard Henderson2010-07-291-70/+9
| | | | | | | | | | | 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 that the support for such interpreters has been removed from binfmt_elf. There doesn't seem to be any reason to keep this broken support in qemu. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
* linux-user: Put the stack guard page at the top.Richard Henderson2010-07-291-14/+17
| | | | | | | | | 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 <rth@twiddle.net> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
* linux-user: Improve consistency checking in elf headers.Richard Henderson2010-07-291-24/+33
| | | | | | | | | 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 <rth@twiddle.net> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
* linux-user: Load symbols from the interpreter.Richard Henderson2010-07-291-88/+101
| | | | | | | | | | | | | | | 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 allocated structures on error exit paths. Second, adjust load_elf_interp to compute load_bias. This requires finding out the built-in load addresses. Which allows us to honor a pre-linked interpreter image when possible, and eliminate the hard-coded INTERP_MAP_SIZE value. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
* linux-user: Clean up byte-swapping in elfload.c.Richard Henderson2010-07-291-71/+48
| | | | | | | | | 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 <rth@twiddle.net> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
* linux-user: Define ELF_DATA generically.Richard Henderson2010-07-291-24/+6
| | | | | | | | The only consideration on this value is the target endianness. The existing defines were incorrect for alpha and sh4eb. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
* linux-user: Reduce lseek+reads while loading elf files.Richard Henderson2010-07-291-60/+44
| | | | | | | | | 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 <rth@twiddle.net> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
* linux-user: Reindent elfload.c.Richard Henderson2010-07-291-510/+518
| | | | | Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
* Add more DT_* and AT_* constants to qemu's copy of elf.h.Richard Henderson2010-07-291-9/+0
| | | | | | | Moving some PPC AT_* constants from elfload.c at the same time. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
* linux-user: Handle filesz < memsz for any PT_LOAD segment.Richard Henderson2010-07-291-97/+55
| | | | | | | | | | | | | | 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. Legally, an ELF program need not have just a single .bss; and PT_LOAD segment can have memsz > filesz. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
* Usermode exec-stack fixPaul Brook2010-06-161-0/+1
| | | | | | | | | 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. Signed-off-by: Paul Brook <paul@codesourcery.com>
* Pre-allocate guest address spacePaul Brook2010-05-291-1/+1
| | | | | | Allow pre-allocation of the guest virtual address space in usermode emulation. Signed-off-by: Paul Brook <paul@codesourcery.com>
* microblaze: Update elf machine nums.Edgar E. Iglesias2010-05-191-2/+2
| | | | | | | | | | | 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 <edgar.iglesias@gmail.com>
* microblaze: Add linux-user core dumping support.Edgar E. Iglesias2010-05-191-0/+18
| | | | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
* Better default guest_basePaul Brook2010-05-051-6/+67
| | | | | | | Avoid loading linux-user applications in address space already used/reserved by the host. Signed-off-by: Paul Brook <paul@codesourcery.com>
* Remove PAGE_RESERVEDPaul Brook2010-05-051-6/+0
| | | | | | | | | 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. Signed-off-by: Paul Brook <paul@codesourcery.com>
* linux-user/ppc: use the Linux register layoutRob Landley2010-03-281-21/+2
| | | | | | | | | | | | | | 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. Remove code converting the Linux layout to AIX layout so that all binaries are presented the Linux Layout. Signed-off-by: Rob Landley <rob@landley.net> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* linux-user: Use RLIMIT_STACK for default stack size.Richard Henderson2010-03-271-1/+1
| | | | | | | | | | | | | | | | | | 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. A reasonable compromise seems to be to honor the system rlimit. At least on two Linux distributions, this is set to 8MB and 10MB respectively. If the system does not limit the stack, then we're no worse off than before. At the same time, rename the variable from x86_stack_size and change the ultimate fallback size from 512kB to 8MB. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* Fix usermode virtual address typePaul Brook2010-03-121-2/+2
| | | | | | Usermode virtual addresses are abi_ulong, not target_ulong. Signed-off-by: Paul Brook <paul@codesourcery.com>
* Disassembler symbol lookup fixPaul Brook2010-03-011-2/+2
| | | | | | Fix function signature for userspace disassembler symbol lookup. Signed-off-by: Paul Brook <paul@codesourcery.com>
* fix linux-user microblaze ELF_ARCH definitionMike Frysinger2010-01-171-1/+1
| | | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
* linux-user: add core dump support for SHNathan Froyd2009-12-191-0/+33
| | | | | Signed-off-by: Nathan Froyd <froydnj@codesourcery.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* linux-user: add core dump support for M68KNathan Froyd2009-12-191-0/+29
| | | | | Signed-off-by: Nathan Froyd <froydnj@codesourcery.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* linux-user: add core dump support for MIPSNathan Froyd2009-12-191-0/+46
| | | | | Signed-off-by: Nathan Froyd <froydnj@codesourcery.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* linux-user: add core dump support for PPCNathan Froyd2009-12-191-0/+26
| | | | | Signed-off-by: Nathan Froyd <froydnj@codesourcery.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* linux-user: fix ARM core dumps on opposite-endian hostsNathan Froyd2009-12-191-19/+19
| | | | | Signed-off-by: Nathan Froyd <froydnj@codesourcery.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* linux-user: commonify definitions of target typedefsNathan Froyd2009-12-191-22/+10
| | | | | | | | | 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 <froydnj@codesourcery.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* linux-user: fix ELF_USE_CORE_DUMP/USE_ELF_CORE_DUMP confusionNathan Froyd2009-12-191-1/+1
| | | | | Signed-off-by: Nathan Froyd <froydnj@codesourcery.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* linux-user: use TARGET_ABI_FMT_lx to print abi_ulong typesAurelien Jarno2009-12-191-1/+1
| | | | Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* target-alpha: Drop bogus UNIQ initial value on Linux.Richard Henderson2009-12-131-3/+0
| | | | | Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* linux-user: Update ARM hwcapsRiku Voipio2009-10-161-1/+8
| | | | | | Update ARM hwcaps to match Linux kernel 2.6.31 state Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
* linux-user: fix "#if 0"'d printf()Paul Bolle2009-10-041-1/+1
| | | | | | | | | | 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). Signed-off-by: Paul Bolle <pebolle@tiscali.nl> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* Revert "Get rid of _t suffix"Anthony Liguori2009-10-011-32/+32
| | | | | | | | | | | | 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 and cope with it. This reverts commit 99a0949b720a0936da2052cb9a46db04ffc6db29. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Get rid of _t suffixmalc2009-10-011-32/+32
| | | | | | | Some not so obvious bits, slirp and Xen were left alone for the time being. Signed-off-by: malc <av1474@comtv.ru>
* elfload: fix coding style nitMichael S. Tsirkin2009-09-301-1/+1
| | | | | | | | Put space between = and * when dereferencing a pointer, to avoid confusion with old-style "*=" Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Compile loader only onceBlue Swirl2009-09-201-2/+2
| | | | | | | | | | | | | 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. Adjust callers. Also use target_phys_addr_t instead of target_ulong for addresses: loader addresses aren't virtual. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Fix sys-queue.h conflict for goodBlue Swirl2009-09-121-14/+14
| | | | | | | | | | | | | | | 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, f40d753718c72693c5f520f0d9899f6e50395e94, 96555a96d724016e13190b28cffa3bc929ac60dc and 3990d09adf4463eca200ad964cc55643c33feb50 but the fixes were fragile. Solution: Avoid the conflict entirely by renaming the functions and the file. Revert the previous hacks. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Fix symfind.Laurent Desnogues2009-08-101-1/+1
| | | | | | | | | | | | | | | | | | | | | 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 instead of s1. Laurent Signed-off-by: Laurent Desnogues <laurent.desnogues@gmail.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Message-Id:
* More NULL pointer fixesBlue Swirl2009-08-011-1/+1
| | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Use correct byteswap routine for elf_notemalc2009-07-181-3/+3
| | | | | | | 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 <av1474@comtv.ru>
* Avoid name clashes with symbols that leak from system headersmalc2009-07-181-37/+37
| | | | Signed-off-by: malc <av1474@comtv.ru>
* ELF codedump build failuresLaurent Desnogues2009-07-171-29/+30
| | | | | | Rename ELF coredump types to avoid conflict with the corresponding host types. Signed-off-by: Laurent Desnogues <laurent.desnogues@gmail.com>
* Userspace guest address offsettingPaul Brook2009-07-171-0/+23
| | | | | | | | | | 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 <riku.voipio@iki.fi> Signed-off-by: Paul Brook <paul@codesourcery.com>
OpenPOWER on IntegriCloud