History log of /art/runtime/elf_file.cc
Revision Date Author Comments
afa6b8e93a0dc0de33c9d404945c7c5621e20b1a 13-Sep-2014 Andreas Gampe <agampe@google.com> ART: Make elf loading not abort

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
Change-Id: I50fdd2edacd86f25d4dacf2180ce2a6105eaf4af
1b2140c9bf46388e4f59ecf3d62d99cd78fed12c 09-Sep-2014 Andreas Gampe <agampe@google.com> ART: Better error reporting on broken oat file

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
Change-Id: I3b890dd1c31c08b1ccc0f7f668afcceee95f8d00
ac304133ab4b988777bcc5ad12257cbb99c3871e 28-Apr-2014 Jim_Guo <jim_guo@htc.com> ART: Fix memory unmapped twice issue in ElfFile::Load(bool)

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

(cherry picked from commit a62a588a9202f69e53fbeb3045ea8ea5ec2587f8)

Change-Id: Icb83c8e87fa168027d9d8adb34925000399d3d2a
a62a588a9202f69e53fbeb3045ea8ea5ec2587f8 28-Apr-2014 Jim_Guo <jim_guo@htc.com> ART: Fix memory unmapped twice issue in ElfFile::Load(bool)

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
35e1e6ad4b50f1adbe9f93fe467766f042491896 30-Jul-2014 Tong Shen <endlessroad@google.com> 1. Fix CFI for quick compiled code in x86 & x86_64;
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
53cb16b98acf3cf6f3a1e2204ad4958ecf1b5a3c 12-Jun-2014 Alex Light <allight@google.com> Add patchoat tool to Art.

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
3470ab4011b5e18d590d5375e2f13a1e3bd69222 18-Jun-2014 Alex Light <allight@google.com> Fixed gdb support and added some ElfFile functions

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
576ca0cd692c0b6ae70e776de91015b8ff000a08 07-Jun-2014 Ian Rogers <irogers@google.com> Reduce header files including header files.

Main focus is getting heap.h out of runtime.h.

Change-Id: I8d13dce8512816db2820a27b24f5866cc871a04b
700a402244a1a423da4f3ba8032459f4b65fa18f 20-May-2014 Ian Rogers <irogers@google.com> Now we have a proper C++ library, use std::unique_ptr.

Also remove the Android.libcxx.mk and other bits of stlport compatibility
mechanics.

Change-Id: Icdf7188ba3c79cdf5617672c1cfd0a68ae596a61
91268c1afd6c0d4fad55b7c86d907233d4660205 04-Apr-2014 Andreas Gampe <agampe@google.com> Check the machine type of an ELF file when loading.

This ensures that we reject wrong target ELF files,
and should result in a recompile for the right
target.

Change-Id: I898dddc4f2bb9b1607a7436083d0ba7619b6007b
4fb5df8453367aa3f160ac230c03a7a98a28e562 13-Mar-2014 Hiroshi Yamauchi <yamauchi@google.com> Make MemMap::MapAnonymous() fail if the requested address is not available.

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
1a5706611bffa5d6ed6843ee5e320f504590e097 12-Mar-2014 Ian Rogers <irogers@google.com> A few 64bit fixes.

Change-Id: I1fe189d638b9cb5127b897da6cecdad6902db930
a7f198cd77fe420d65fde3b80e0d84b043b65bc4 10-Mar-2014 Nicolas Geoffray <ngeoffray@google.com> Add includes to fix gcc 4.7 build.

Change-Id: Idf84f156047270b81c5d10a55a3a1c96b415cddc
6243e0e5ae78acfa10a197d727db96c8a7f27622 03-Mar-2014 Kenny Root <kroot@google.com> GDB JIT support: move .text segment check earlier

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
3d3f249a63b54503b2babda69c0a50077f35a743 03-Mar-2014 Andreas Gampe <agampe@google.com> Fix 64-bit build

Change-Id: I14b84424f804120edf11f3d9b2bb2b9e497b429f
ae9fd93c39a341e2dffe15c61cc7d9e841fa92c4 11-Feb-2014 Mark Mendell <mark.p.mendell@intel.com> Tell GDB about Quick ART generated code

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>
659d87d4a61f83f5582d816ee0bc94f00e19b46c 27-Feb-2014 Dmitry Petrochenko <dmitry.petrochenko@intel.com> art: Fix build errors for x86_64 target

Fixes build issues introduced by multilib, CompilerOptions and ElfFile patches.

Change-Id: Ic05d149e3c7a1e644d0cb50cc7c3599025c90bdf
Signed-off-by: Dmitry Petrochenko <dmitry.petrochenko@intel.com>
c1409450dece36852a6e67ec8d843f3da148faf3 26-Feb-2014 Brian Carlstrom <bdc@google.com> ElfFile should protect itself from bad input

Bug: 13207536
Change-Id: Ia0406a7e8fce4030570503471e003d4da581652f
50cfe74daaece80853cb3b45d4338329b7d0345b 19-Feb-2014 Nicolas Geoffray <ngeoffray@google.com> Remove dependency on llvm/Support/ELF.h by using linux's elf.h.

Change-Id: Iefe66af9958641ac7f08fdc22f438d976e5b4d54
ef7d42fca18c16fbaf103822ad16f23246e2905d 06-Jan-2014 Ian Rogers <irogers@google.com> Object model changes to support 64bit.

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
cdfcf37aed7f436d32846a58e9a0a0b13e22e0af 24-Jan-2014 Ian Rogers <irogers@google.com> 64bit fixes for elf file.

Force size to signed once errno isn't in play, to solve signed/unsigned
comparisons. Fix printf formatting flags.

Change-Id: Iabf1554c9903a4389ed38f8b1b889bb44778d9d6
d0c09dc2177d132099a05af8537bdb9a8225af8c 07-Nov-2013 Brian Carlstrom <bdc@google.com> Add missing error message propagation to ElfFile::SetMap

Change-Id: I085e23cd4728e10a7efca3586270c6cffed9e8d4
8d31bbd3d6536de12bc20e3d29cfe03fe848f9da 13-Oct-2013 Ian Rogers <irogers@google.com> Throw IOException at source of failing to open a dex file.

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
3a22361a4d7bb7ae5558640873c375692f1e242a 11-Oct-2013 Brian Carlstrom <bdc@google.com> Validate ELF file segment lengths against file length when loading

Bug: 11152153
Change-Id: I31047b9bb607aac478b79dea4ed9a72abe1bd775
eeb9888421b696990f45b89286ad9d0908c70a69 04-Oct-2013 Brian Carlstrom <bdc@google.com> Use ElfFile instead of dlopen for Quick

Bug: 10614658
Change-Id: I6a7e2cb0960a5d468a55d220c3fafa80bc239fa9
02c8cc6d1312a2b55533f02f6369dc7c94672f90 19-Jul-2013 Brian Carlstrom <bdc@google.com> Fixing cpplint whitespace/blank_line, whitespace/end_of_line, whitespace/labels, whitespace/semicolon issues

Change-Id: Ide4f8ea608338b3fed528de7582cfeb2011997b6
df62950e7a32031b82360c407d46a37b94188fbb 18-Jul-2013 Brian Carlstrom <bdc@google.com> Fix cpplint whitespace/parens issues

Change-Id: Ifc678d59a8bed24ffddde5a0e543620b17b0aba9
f1d3455064792ac1c486a4a9c24279a37b4af473 13-Jul-2013 Brian Carlstrom <bdc@google.com> Do not mark pages executable unnecessarily to play nice with selinux

Change-Id: Ief4a5da38ac7c2cf7bf6f7a640cb63c5e8ed03bd
7940e44f4517de5e2634a7e07d58d0fb26160513 12-Jul-2013 Brian Carlstrom <bdc@google.com> Create separate Android.mk for main build targets

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