summaryrefslogtreecommitdiffstats
path: root/compiler/elf_builder.h
Commit message (Collapse)AuthorAgeFilesLines
* ART stack unwinding fixes for libunwind/gdb/lldb.David Srbecky2015-06-191-12/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dex2oat can already generate unwinding and symbol information which allows tools to create backtrace of mixed native and Java code. This is a cherry pick from aosp/master which fixes several issues. Most notably: * It enables generation of ELF-64 on 64-bit systems (in dex2oat, C compilers already produce ELF-64). Libunwind requires ELF-64 on 64-bit systems for backtraces to work. * It enables loading of ELF files with dlopen. This is required for libunwind to be able to generate backtrace of current process (i.e. the process requesting backtrace of itself). * It adds unit test to test the above (32 vs 64 bit, in-proces vs out-of-process, application code vs framework code). * Some other fixes or clean-ups which should not be of much significance but which are easier to include to make the important CLs cherry-pick cleanly. This is squash of the following commits from aosp/master: 7381010 ART: CFI Test e1bbed2 ART: Blacklist CFI test for non-compiled run-tests aab9f73 ART: Blacklist CFI test for JIT 4437219 ART: Blacklist CFI test for Heap Poisoning a3a49fe Switch to using ELF-64 for 64-bit architectures. 297ed22 Write 64-bit address in DWARF if we are on 64-bit architecture. 24981a1 Set correct size of PT_PHDR ELF segment. 1a146bf Link .dynamic to .dynstr 67a0653 Make some parts of ELF more (pointer) aligned. f50fa82 Enable 64-bit CFI tests. 49e1fab Use dlopen to load oat files. 5dedb80 Add more logging output for dlopen. aa03870 Find the dlopened file using address rather than file path. 82e73dc Release dummy MemMaps corresponding to dlopen. 5c40961 Test that we can unwind framework code. 020c543 Add more log output to the CFI test. 88da3b0 ART: Fix CFI test wrt/ PIC a70e5b9 CFI test: kill the other process in native code. ad5fa8c Support generation of CFI in .debug_frame format. 90688ae Fix build - large frame size of ElfWriterQuick<ElfTypes>::Write. 97dabb7 Fix build breakage in dwarf_test. 388d286 Generate just single ARM mapping symbol. f898087 Split .oat_patches to multiple sections. 491a7fe Fix build - large frame size of ElfWriterQuick<ElfTypes>::Write (again). 8363c77 Add --generate-debug-info flag and remove the other two flags. 461d72a Generate debug info for core.oat files. Bug: 21924613 Change-Id: I3f944a08dd2ed1df4d8a807da4fee423fdd35eb7
* ART: Clean up arm64 kNumberOfXRegisters usage.Vladimir Marko2015-05-261-0/+1
| | | | | | | | | | | | | | | | | | | | | Avoid undefined behavior for arm64 stemming from 1u << 32 in loops with upper bound kNumberOfXRegisters. Create iterators for enumerating bits in an integer either from high to low or from low to high and use them for <arch>Context::FillCalleeSaves() on all architectures. Refactor runtime/utils.{h,cc} by moving all bit-fiddling functions to runtime/base/bit_utils.{h,cc} (together with the new bit iterators) and all time-related functions to runtime/base/time_utils.{h,cc}. Improve test coverage and fix some corner cases for the bit-fiddling functions. Bug: 13925192 (cherry picked from commit 80afd02024d20e60b197d3adfbb43cc303cf29e0) Change-Id: I905257a21de90b5860ebe1e39563758f721eab82
* Add binary search table to .eh_frame_hdrDavid Srbecky2015-05-011-37/+20
| | | | | | | | | | | The addresses in the search table must be relative to the start of .eh_frame_hdr which results in yet another pointer type to patch. I have moved the Patch method back to elf_writer_quick where it can be specialized to one of the three pointer types. The .eh_frame_hdr takes around 17% of .eh_frame now. Change-Id: I4770d1355ded6cdff9489c33380f6b06c4e3f9fe
* Move .eh_frame to the end of ELF file.David Srbecky2015-04-301-25/+24
| | | | | | | | Move .eh_frame to the end together with other debug sections. This should make it easier to remove it using standard strip tools. Bug:20556771 Change-Id: I8303ccb053aee50d53fb193819d345c91f1e5b75
* Major refactoring of ElfBuilder.David Srbecky2015-04-301-1041/+604
| | | | | | | | | | | | | | | | | | | | | | Simplify ElfBuilder by removing duplicated or redundant code. Many of the repeated code patterns were replaced by just looping over the list of all sections. Methods Init() and Write() have been merged into one. The split between those was rather arbitrary, but it was there for a reason. It allowed creation of raw sections between the calls which may have depended on layout decisions done in Init(), but not in Write() (e.g. knowing of offset of .text). This has been replaced by more generic solution. All sections are asked about their size first and complete file layout is calculated. Then the sections are asked to write their content (potentially using the layout information). This should be pure refactoring CL - the compiler should produce bit for bit identical output as before. Change-Id: I281d13d469801bd8288b36b360d200d98a3e92d7
* Minor refactoring of ElfBuilder.David Srbecky2015-04-281-460/+452
| | | | | | | | | | | | | * Nest section builder classes within the main builder class to reduce verbosity caused by templates. * Move .eh_frame and .eh_frame_hdr section headers earlier so that the section headers are sorted by file offset. * Do not emit PT_NULL header if .eh_frame_hdr is missing. None of these changes should have any material impact. This CL just prepares ground for the following CL. Change-Id: I56f9825892adb01d413a18ca10cb5c805cb8cd78
* Replace NULL with nullptrMathieu Chartier2015-04-221-3/+3
| | | | | | | Also fixed some lines that were too long, and a few other minor details. Change-Id: I6efba5fb6e03eb5d0a300fddb2a75bf8e2f175cb
* Simplify template parameters of Elf classes.David Srbecky2015-04-221-51/+70
| | | | | | | | | | | The ELF specification defines several types which differ between 32-bit ELF and 64-bit ELF. We used to template all ELF-related methods on all of those types which was very verbose. This CL wraps all the types as typedefs in ElfTypes32 and ElfTypes64. One of those wrappers is then used as the template parameter. Change-Id: I65247c2c79d92a7c4799e988cf3e4a1b10eb4788
* Generate .eh_frame_hdr section and PT_GNU_EH_FRAME segment.David Srbecky2015-04-211-34/+99
| | | | | | | | | | | | | | | Fixes issue 20125400 - ART: Need .eh_frame_hdr and PT_GNU_EH_FRAME for libunwind. .eh_frame_hdr serves two purposes. Firstly, it can optionally contain binary search table for fast eh_frame lookup. This is important for C++ exception handling, but we do not need it so we omit it. Secondly, it contains a relative .eh_frame pointer which makes it easier for run-time code to locate the .eh_frame section. libunwind seems to rely on this relative pointer. Bug: 20125400 Change-Id: I7c1e3f68d914f70781404c508395831a3296a7da
* ART: Enable Clang's -WdeprecatedAndreas Gampe2015-04-061-0/+2
| | | | | | | | | Replace throw() with noexcept. Add default copy constructors and copy assignment constructors for cases with destructors, as the implicit definition is deprecated. Change-Id: Ice306a3f510b072b00bec4d4360f7c8055135c9d
* Add support for .bss section in oat files.Vladimir Marko2015-03-021-23/+86
| | | | Change-Id: I779b80b8139d9afdc28373f8c68edff5df7726ce
* ART: Allow to compile interpret-only mips64 filesAndreas Gampe2015-01-151-0/+8
| | | | | | | | | | | | Include enough infrastructure to allow cross-compiling for mips64, interpret-only. This includes the instruction-set-features, frame size info and utils assembler. Also add a disassembler for oatdump, and support in patchoat. Note: the runtime cannot run mips64, yet. Change-Id: Id106581fa76b478984741c62a8a03be0f370d992
* Instruction set features for ARM64, MIPS and X86.Ian Rogers2014-11-131-1/+1
| | | | | | | | | | | | | Also, refactor how feature strings are handled so they are additive or subtractive. Make MIPS have features for FPU 32-bit and MIPS v2. Use in the quick compiler rather than #ifdefs that wouldn't have worked in cross-compilation. Add SIMD features for x86/x86-64 proposed in: https://android-review.googlesource.com/#/c/112370/ Bug: 18056890 Change-Id: Ic88ff84a714926bd277beb74a430c5c7d5ed7666
* Remove -Wno-unused-parameter and -Wno-sign-promo from base cflags.Ian Rogers2014-11-031-1/+1
| | | | | | | | | | | Fix associated errors about unused paramenters and implict sign conversions. For sign conversion this was largely in the area of enums, so add ostream operators for the effected enums and fix tools/generate-operator-out.py. Tidy arena allocation code and arena allocated data types, rather than fixing new and delete operators. Remove dead code. Change-Id: I5b433e722d2f75baacfacae4d32aef4a828bfe1b
* Tidy ELF builder.Ian Rogers2014-10-091-231/+303
| | | | | | | | | Don't do "if (ptr)". Use const. Use DISALLOW_COPY_AND_ASSIGN. Avoid public member variables. Move ValueObject to base and use in ELF builder. Tidy VectorOutputStream to not use non-const reference arguments. Change-Id: I2c727c3fc61769c3726de7cfb68b2d6eb4477e53
* ART: Prepare for ELF64.Tong Shen2014-10-031-1/+2
| | | | | | Only expose necessary interface in ElfFile, and move all details into template class ElfFileImpl. Change-Id: I9df2bbc55f32ba0ba91f4f3d5d0009e84a2ddf74
* Implement method calls using relative BL on ARM.Vladimir Marko2014-09-251-0/+2
| | | | | | | | | | Store the linker patches with each CompiledMethod instead of keeping them in CompilerDriver. Reorganize oat file creation to apply the patches as we're writing the method code. Add framework for platform-specific relative call patches in the OatWriter. Implement relative call patches for ARM. Change-Id: Ie2effb3d92b61ac8f356140eba09dc37d62290f8
* ART: Refactor elf_writer_quick for elf section orderAndreas Gampe2014-09-241-64/+163
| | | | | | | | | | | | This writes ELF sections in approximate order (debug sections are currently out-of-order) to avoid incompletely written files appearing OK to ART loading code. Bug: 17622827 (cherry picked from commit 3c5ec99e156632a734c2359642ae928102850597) Change-Id: I812fd42fcf2823dbfaf5891bf101d3b59406f263
* ART: Refactor elf_writer_quick, add symbolizerAndreas Gampe2014-09-051-0/+1069
Refactors some classes in elf_writer_quick.h to elf_builder.h to be more friendly for re-use. Use this in oatdump to add a symtab to an oat file. Bug: 17187621, 17322125 Change-Id: I2333291334fd98bd09cc5717fb83cb18efe3a029