summaryrefslogtreecommitdiffstats
path: root/runtime/elf_file.cc
Commit message (Collapse)AuthorAgeFilesLines
* Some code clean-up.Ian Rogers2014-10-161-64/+55
| | | | Change-Id: I4b745fd5298cd61c793e3b57514b48347bd66c0e
* stdint types all the way!Ian Rogers2014-10-091-51/+51
| | | | Change-Id: I4e4ef3a2002fc59ebd9097087f150eaf3f2a7e08
* ART: Prepare for ELF64.Tong Shen2014-10-031-144/+907
| | | | | | Only expose necessary interface in ElfFile, and move all details into template class ElfFileImpl. Change-Id: I9df2bbc55f32ba0ba91f4f3d5d0009e84a2ddf74
* ART: Make elf loading not abortAndreas Gampe2014-09-151-114/+351
| | | | | | | | | | | | | | Changes elf_file code to use less CHECKs and instead return error values (usually nullptr). This avoids aborts. In oat_file, when loading an oat file fails, try to unlink at. If this succeeds, on the next run we may compile again. Bug: 17491333 (cherry picked from commit afa6b8e93a0dc0de33c9d404945c7c5621e20b1a) Change-Id: I50fdd2edacd86f25d4dacf2180ce2a6105eaf4af
* ART: Better error reporting on broken oat fileAndreas Gampe2014-09-091-0/+4
| | | | | | | | | | | | Do not blow up when in GetHashBucket if GetHashBucketNum is zero. Instead back-step to ElfFileOpen, which prints which symbol was missing from which file. Bug: 17422404 (cherry picked from commit 1b2140c9bf46388e4f59ecf3d62d99cd78fed12c) Change-Id: I3b890dd1c31c08b1ccc0f7f668afcceee95f8d00
* ART source line debug info in OAT filesYevgeny Rouban2014-08-151-42/+226
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | OAT files have source line information enough for ART runtime needs like jump to/from interpreter and thread suspension. But this information is not enough for finer grained source level debugging and low-level profiling (VTune or perf). This patch adds to OAT files two additional sections: .debug_line - DWARF formatted Elf32 section with detailed source line information (mapping from native PC to Java source lines). In addition to the debugging symbols added using the dex2oat option --include-debug-symbols, the source line information is added to the section .debug_line. The source line info can be read by many Elf reading tools like objdump, readelf, dwarfdump, gdb, perf, VTune, ... gdb can use this debug line information in x86. In 64-bit mode the information can be used if the oat file is mapped in the lower address space (address has higher 32 bits zeroed). Relocation works. Testing: 1. art/test/run-test --host --gdb [--64] 001-HelloWorld 2. in gdb: break Main.java:19 3. in gdb: break Runtime.java:111 4. in gdb: run - stops at void java.lang.Runtime.<init>() 5. in gdb: backtrace - shows call stack down to main() 6. in gdb: continue - stops at void Main.main() (only in 32-bit mode) 7. in gdb: backtrace - shows call stack down to main() 8. objdump -W <oat-file> - addresses are from VMA range of .text section reported by objdump -h <file> 9. dwarfdump -ka <oat-file> - no errors expected Size of aosp-x86-eng boot.oat increased by 11% from 80.5Mb to 89.2Mb with two sections added .debug_line (7.2Mb) and .rel.debug (1.5Mb). Change-Id: Ib8828832686e49782a63d5529008ff4814ed9cda Signed-off-by: Yevgeny Rouban <yevgeny.y.rouban@intel.com>
* Make gdb fixup work with multiple DWARF Compilation UnitsAlex Light2014-08-151-8/+38
| | | | Change-Id: I83042362fc199ca48c8452230709a377e52a2cf5
* ART: Fix memory unmapped twice issue in ElfFile::Load(bool)Jim_Guo2014-08-041-9/+15
| | | | | | | | | | | | | | | | | Root Cause: The overlapped memory region will be unmapped by (1) ~MemMap() of reservation MemMap (reserve) and (2) ~MemMap() of "reuse" MemMap (segment). Someone takes the memory region after (1) and it will be unmapped in (2). So, SIGSEGV occurs when using the unmapped memory region. Solution: Fixes this issue by skip unmap "reuse" MemMap in destructor. And always create reservation MemMap before "reuse" MemMap. (It also solved the fixupELF case which does not reserve the whole needed memory region). Bug: 16486685 Change-Id: I8f2538861d5c3fa7b9a04d2c3f516319cc060291
* 1. Fix CFI for quick compiled code in x86 & x86_64;Tong Shen2014-07-301-19/+9
| | | | | | | | | | | | | | | | 2. Emit CFI in .eh_frame instead of .debug_frame. With CFI, we can correctly unwind past quick generated code. Now gdb should unwind to main() for both x86 & x86_64 host-side ART. Note that it does not work with relocation yet. Testing: 1. art/test/run-test --host --gdb [--64] --no-relocate 005 2. In gdb, run 'b art_quick_invoke_stub', then 'r', then 'c' a few times 3. In gdb, run 'bt'. You should see stack frames down to main() Change-Id: I5350d4097dc3d360a60cb17c94f1d02b99bc58bb
* Add patchoat tool to Art.Alex Light2014-07-071-5/+14
| | | | | | | | | | | | | Add a new executable called patchoat to art. This tool takes already compiled images and oat files and changes their base address, acting as a cheap form of relocation. Add a --include-patch-information flag to dex2oat and code to add required patch information to oat files created with the quick compiler. Bug: 15358152 Change-Id: Ie0c580db45bb14ec180deb84930def6c3628d97d
* Fixed gdb support and added some ElfFile functionsAlex Light2014-06-271-295/+417
| | | | | | | | | | | | | | | | | | Fixed gdb support so that it would continue working even when debug symbols or other sections are included in the elf file. Also made it actually read parts of the DWARF information so it should work even if there are minor changes to how and where DWARF information is written out. Added a dwarf.h file with the dwarf constants. Added a FindSectionByName function, a FindDynamicSymbol function, and the ability to specify the mmap protection and flags directly if we are mapping in the whole file. Modified elf_writer_quick.cc to use the dwarf constants from dwarf.h. Change-Id: I09e15c425fab252b331a2e4719863552e8b6b137
* Reduce header files including header files.Ian Rogers2014-06-061-0/+1
| | | | | | Main focus is getting heap.h out of runtime.h. Change-Id: I8d13dce8512816db2820a27b24f5866cc871a04b
* Now we have a proper C++ library, use std::unique_ptr.Ian Rogers2014-05-191-4/+4
| | | | | | | Also remove the Android.libcxx.mk and other bits of stlport compatibility mechanics. Change-Id: Icdf7188ba3c79cdf5617672c1cfd0a68ae596a61
* Check the machine type of an ELF file when loading.Andreas Gampe2014-04-041-0/+35
| | | | | | | This ensures that we reject wrong target ELF files, and should result in a recompile for the right target. Change-Id: I898dddc4f2bb9b1607a7436083d0ba7619b6007b
* Make MemMap::MapAnonymous() fail if the requested address is not available.Hiroshi Yamauchi2014-03-141-2/+2
| | | | | | | | | | | | | | | | | | Change MapAnonymous() so that a requested address vs. actual map address mismatch will cause a failure. The existing MapAnonymous() call sites do not check this. This should prevent potential rare case bugs where mmap does not happen to map a region at an specified address. There's a potential bug that if MapAnonymous() does not guarantee the requested address (and there's a gap between the image/oat files and the zygote/malloc space), then GC could in theory allocate a large object space in the gap. This would break the GC notion of the immune space. This change will prevent this by causing all non-moving spaces to be (really) adjacent, with no gaps in between, which CL 87711 missed. Change-Id: Id4adb0e30adbad497334d7e00def4c0c66b15719
* A few 64bit fixes.Ian Rogers2014-03-121-1/+5
| | | | Change-Id: I1fe189d638b9cb5127b897da6cecdad6902db930
* Add includes to fix gcc 4.7 build.Nicolas Geoffray2014-03-101-0/+3
| | | | Change-Id: Idf84f156047270b81c5d10a55a3a1c96b415cddc
* GDB JIT support: move .text segment check earlierKenny Root2014-03-031-10/+13
| | | | | | | | | If the file is to be purely interpreted, the .text segment will be of zero length and won't get a segment mapped. Currently this will cause a check failure, but we should just exit if the GDB JIT support cannot be enabled. Change-Id: Iea3834ee5c1313837ebcbe3b58ecd2dc924c1b1e
* Fix 64-bit buildAndreas Gampe2014-03-031-1/+1
| | | | Change-Id: I14b84424f804120edf11f3d9b2bb2b9e497b429f
* Tell GDB about Quick ART generated codeMark Mendell2014-03-021-1/+354
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is actually a lot of work. To do this, we need: .debug_info .debug_abbrev .debug_frame .debug_str These are generated into the OAT file by OatWriter and ElfWriterQuick. Since the Quick ART runtime doesn't use dlopen to load the OAT files, GDB can't find this information. Use the alternate GDB JIT interface, which can be invoked at runtime. To use this interface, an ELF image needs to be built in memory. Read the information from the OAT file, fixup the addresses to point to the real locations, add a symbol table to hold the .text symbol, and then let GDB know about the information, which will be read from the runtime address space. This is quite primitive now, and could be cleaned up considerably. It probably needs symbol table entries for the methods, and descriptions of parameters and return types. Currently only supported for X86. This defaults to enabled for debug builds. Added dexoat --gen-gdb-info and --no-gen-gdb-info flags to override. Change-Id: I4d18b2370f6dfaa00c8cc1925f10717be3bd1a62 Signed-off-by: Mark Mendell <mark.p.mendell@intel.com>
* art: Fix build errors for x86_64 targetDmitry Petrochenko2014-02-271-2/+2
| | | | | | | Fixes build issues introduced by multilib, CompilerOptions and ElfFile patches. Change-Id: Ic05d149e3c7a1e644d0cb50cc7c3599025c90bdf Signed-off-by: Dmitry Petrochenko <dmitry.petrochenko@intel.com>
* ElfFile should protect itself from bad inputBrian Carlstrom2014-02-261-83/+205
| | | | | Bug: 13207536 Change-Id: Ia0406a7e8fce4030570503471e003d4da581652f
* Remove dependency on llvm/Support/ELF.h by using linux's elf.h.Nicolas Geoffray2014-02-191-132/+131
| | | | Change-Id: Iefe66af9958641ac7f08fdc22f438d976e5b4d54
* Object model changes to support 64bit.Ian Rogers2014-02-061-1/+2
| | | | | | | | | | | | | | | | | | | | | | | Modify mirror objects so that references between them use an ObjectReference value type rather than an Object* so that functionality to compress larger references can be captured in the ObjectRefererence implementation. ObjectReferences are 32bit and all other aspects of object layout remain as they are currently. Expand fields in objects holding pointers so they can hold 64bit pointers. Its expected the size of these will come down by improving where we hold compiler meta-data. Stub out x86_64 architecture specific runtime implementation. Modify OutputStream so that reads and writes are of unsigned quantities. Make the use of portable or quick code more explicit. Templatize AtomicInteger to support more than just int32_t as a type. Add missing, and fix issues relating to, missing annotalysis information on the mutator lock. Refactor and share implementations for array copy between System and uses elsewhere in the runtime. Fix numerous 64bit build issues. Change-Id: I1a5694c251a42c9eff71084dfdd4b51fff716822
* 64bit fixes for elf file.Ian Rogers2014-01-231-7/+15
| | | | | | | Force size to signed once errno isn't in play, to solve signed/unsigned comparisons. Fix printf formatting flags. Change-Id: Iabf1554c9903a4389ed38f8b1b889bb44778d9d6
* Add missing error message propagation to ElfFile::SetMapBrian Carlstrom2013-11-061-11/+15
| | | | Change-Id: I085e23cd4728e10a7efca3586270c6cffed9e8d4
* Throw IOException at source of failing to open a dex file.Ian Rogers2013-10-211-28/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before is: java.lang.ClassNotFoundException: Didn't find class "GCBench" on path: DexPathList[[zip file "/disk2/dalvik-dev/out/host/linux-x86/framework/GCBench.jar"],nativeLibraryDirectories=[/disk2/dalvik-dev/out/host/linux-x86/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) Suppressed: java.lang.ClassNotFoundException: GCBench at java.lang.Class.classForName(Native Method) at java.lang.BootClassLoader.findClass(ClassLoader.java:781) at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) at java.lang.ClassLoader.loadClass(ClassLoader.java:504) ... 1 more Caused by: java.lang.NoClassDefFoundError: Class "LGCBench;" not found ... 5 more And after is: java.lang.ClassNotFoundException: Didn't find class "GCBench" on path: DexPathList[[zip file "/disk2/dalvik-dev/out/host/linux-x86/framework/GCBench.jar"],nativeLibraryDirectories=[/disk2/dalvik-dev/out/host/linux-x86/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) Suppressed: java.io.IOException: Zip archive '/disk2/dalvik-dev/out/host/linux-x86/framework/GCBench.jar' doesn't contain classes.dex at dalvik.system.DexFile.openDexFile(Native Method) at dalvik.system.DexFile.<init>(DexFile.java:80) at dalvik.system.DexFile.<init>(DexFile.java:59) at dalvik.system.DexPathList.loadDexFile(DexPathList.java:268) at dalvik.system.DexPathList.makeDexElements(DexPathList.java:235) at dalvik.system.DexPathList.<init>(DexPathList.java:113) at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:48) at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:38) at java.lang.ClassLoader.createSystemClassLoader(ClassLoader.java:128) at java.lang.ClassLoader.access$000(ClassLoader.java:65) at java.lang.ClassLoader$SystemClassLoader.<clinit>(ClassLoader.java:81) at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:137) Suppressed: java.lang.ClassNotFoundException: GCBench at java.lang.Class.classForName(Native Method) at java.lang.BootClassLoader.findClass(ClassLoader.java:781) at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) at java.lang.ClassLoader.loadClass(ClassLoader.java:504) ... 1 more Caused by: java.lang.NoClassDefFoundError: Class "LGCBench;" not found ... 5 more Also, move dex file verifier messages out of logs. In the process the ClassLinker::dex_lock_ needed tidying to cover a smaller scope. Bug 11301553. Change-Id: I80058652e11e7ea63457cc01a0cb48afe1c15543
* Validate ELF file segment lengths against file length when loadingBrian Carlstrom2013-10-101-2/+17
| | | | | Bug: 11152153 Change-Id: I31047b9bb607aac478b79dea4ed9a72abe1bd775
* Use ElfFile instead of dlopen for QuickBrian Carlstrom2013-10-031-2/+4
| | | | | Bug: 10614658 Change-Id: I6a7e2cb0960a5d468a55d220c3fafa80bc239fa9
* Fixing cpplint whitespace/blank_line, whitespace/end_of_line, ↵Brian Carlstrom2013-07-181-17/+17
| | | | | | whitespace/labels, whitespace/semicolon issues Change-Id: Ide4f8ea608338b3fed528de7582cfeb2011997b6
* Fix cpplint whitespace/parens issuesBrian Carlstrom2013-07-181-1/+1
| | | | Change-Id: Ifc678d59a8bed24ffddde5a0e543620b17b0aba9
* Do not mark pages executable unnecessarily to play nice with selinuxBrian Carlstrom2013-07-121-2/+2
| | | | Change-Id: Ief4a5da38ac7c2cf7bf6f7a640cb63c5e8ed03bd
* Create separate Android.mk for main build targetsBrian Carlstrom2013-07-121-0/+688
The runtime, compiler, dex2oat, and oatdump now are in seperate trees to prevent dependency creep. They can now be individually built without rebuilding the rest of the art projects. dalvikvm and jdwpspy were already this way. Builds in the art directory should behave as before, building everything including tests. Change-Id: Ic6b1151e5ed0f823c3dd301afd2b13eb2d8feb81