├── Extract ├── Extract.sln └── Extract │ ├── Extract.vcxproj │ ├── Extract.vcxproj.filters │ ├── Extract.vcxproj.user │ ├── Header.h │ ├── LibraryLoader.cpp │ ├── LibraryLoader.h │ ├── TEA.c │ ├── TEA.h │ ├── file.cpp │ ├── file.h │ ├── includes │ ├── android │ │ ├── api-level.h │ │ └── dlext.h │ ├── asm-generic │ │ ├── auxvec.h │ │ ├── bitsperlong.h │ │ ├── int-ll64.h │ │ ├── mman-common.h │ │ ├── mman.h │ │ ├── param.h │ │ ├── posix_types.h │ │ └── types.h │ ├── asm │ │ ├── auxvec.h │ │ ├── bitsperlong.h │ │ ├── mman.h │ │ ├── param.h │ │ ├── posix_types.h │ │ └── types.h │ ├── dlfcn.h │ ├── elf.h │ ├── limits.h │ ├── link.h │ ├── linked_list.h │ ├── linker.h │ ├── linker_phdr.h │ ├── linux │ │ ├── auxvec.h │ │ ├── compiler.h │ │ ├── elf-em.h │ │ ├── elf.h │ │ ├── limits.h │ │ ├── mman.h │ │ ├── param.h │ │ ├── posix_types.h │ │ ├── stddef.h │ │ └── types.h │ ├── machine │ │ ├── elf_machdep.h │ │ ├── posix_limits.h │ │ └── wchar_limits.h │ ├── private │ │ └── bionic_macros.h │ └── sys │ │ ├── cdefs.h │ │ ├── limits.h │ │ ├── mman.h │ │ ├── param.h │ │ ├── syslimits.h │ │ └── sysmacros.h │ ├── linker.cpp │ ├── linker_phdr.cpp │ ├── main.cpp │ ├── zconf.h │ ├── zlib.h │ └── zlib.lib ├── LICENSE ├── README.md ├── shell ├── Extract.exe ├── finally.cpp ├── finally.h ├── include │ ├── linker.h │ ├── linker_relocs.h │ └── visibility.h ├── ldscript ├── libGoodBoy.so ├── makefile ├── public.h ├── run_make.bat ├── settings.h ├── shell.so └── shell_bak.so └── test.png /Extract/Extract.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28010.2046 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Extract", "Extract\Extract.vcxproj", "{3F87E681-B467-4450-A580-88A3432EF7C4}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {3F87E681-B467-4450-A580-88A3432EF7C4}.Debug|x64.ActiveCfg = Debug|x64 17 | {3F87E681-B467-4450-A580-88A3432EF7C4}.Debug|x64.Build.0 = Debug|x64 18 | {3F87E681-B467-4450-A580-88A3432EF7C4}.Debug|x86.ActiveCfg = Debug|Win32 19 | {3F87E681-B467-4450-A580-88A3432EF7C4}.Debug|x86.Build.0 = Debug|Win32 20 | {3F87E681-B467-4450-A580-88A3432EF7C4}.Release|x64.ActiveCfg = Release|x64 21 | {3F87E681-B467-4450-A580-88A3432EF7C4}.Release|x64.Build.0 = Release|x64 22 | {3F87E681-B467-4450-A580-88A3432EF7C4}.Release|x86.ActiveCfg = Release|Win32 23 | {3F87E681-B467-4450-A580-88A3432EF7C4}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {6051E41D-6C4A-4E63-A781-DB9C90703A8B} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /Extract/Extract/Extract.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {3F87E681-B467-4450-A580-88A3432EF7C4} 24 | Extract 25 | 10.0.17763.0 26 | 27 | 28 | 29 | Application 30 | true 31 | v141 32 | MultiByte 33 | 34 | 35 | Application 36 | false 37 | v141 38 | true 39 | MultiByte 40 | 41 | 42 | Application 43 | true 44 | v141 45 | MultiByte 46 | 47 | 48 | Application 49 | false 50 | v141 51 | true 52 | MultiByte 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Level3 76 | Disabled 77 | true 78 | true 79 | __work_around_b_19059885__;__arm__;_CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions) 80 | $(SolutionDir)$(ProjectName)\includes 81 | false 82 | Sync 83 | 84 | false 85 | 86 | 87 | MultiThreadedDebugDLL 88 | 89 | 90 | 91 | 92 | Level3 93 | Disabled 94 | true 95 | true 96 | __work_around_b_19059885__;__arm__;_CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions) 97 | $(SolutionDir)$(ProjectName)\includes 98 | false 99 | 100 | 101 | 102 | false 103 | 104 | 105 | MultiThreadedDebugDLL 106 | 107 | 108 | 109 | 110 | Level3 111 | MaxSpeed 112 | true 113 | true 114 | true 115 | true 116 | __work_around_b_19059885__;__arm__;_CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions) 117 | $(SolutionDir)$(ProjectName)\includes 118 | false 119 | Sync 120 | 121 | false 122 | 123 | 124 | MultiThreadedDLL 125 | 126 | 127 | true 128 | true 129 | 130 | 131 | 132 | 133 | Level3 134 | MaxSpeed 135 | true 136 | true 137 | true 138 | true 139 | __work_around_b_19059885__;__arm__;_CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions) 140 | $(SolutionDir)$(ProjectName)\includes 141 | false 142 | 143 | 144 | 145 | false 146 | 147 | 148 | MultiThreadedDLL 149 | 150 | 151 | true 152 | true 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | -------------------------------------------------------------------------------- /Extract/Extract/Extract.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {0b7ac7c4-fa81-43d1-b661-58e5b23efc63} 18 | 19 | 20 | 21 | 22 | 源文件 23 | 24 | 25 | 源文件 26 | 27 | 28 | 源文件 29 | 30 | 31 | 源文件 32 | 33 | 34 | 源文件 35 | 36 | 37 | 源文件 38 | 39 | 40 | 41 | 42 | 头文件 43 | 44 | 45 | includes 46 | 47 | 48 | includes 49 | 50 | 51 | 头文件 52 | 53 | 54 | 头文件 55 | 56 | 57 | 头文件 58 | 59 | 60 | 头文件 61 | 62 | 63 | 头文件 64 | 65 | 66 | 头文件 67 | 68 | 69 | 70 | 71 | 资源文件 72 | 73 | 74 | -------------------------------------------------------------------------------- /Extract/Extract/Extract.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | libDiag_bmw_org.so 5 | WindowsLocalDebugger 6 | 7 | -------------------------------------------------------------------------------- /Extract/Extract/Header.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CCint3/LLeGu/c3b4c31709e5759c943d3fa07345555c2c650bdd/Extract/Extract/Header.h -------------------------------------------------------------------------------- /Extract/Extract/LibraryLoader.cpp: -------------------------------------------------------------------------------- 1 | #include "LibraryLoader.h" 2 | #include "file.h" 3 | 4 | 5 | LibraryLoader::LibraryLoader(const char *name) 6 | : name_(name), fd_(NULL), mapping_(NULL), header_({ 0 }) { 7 | } 8 | 9 | 10 | LibraryLoader::~LibraryLoader() { 11 | } 12 | 13 | 14 | bool LibraryLoader::Load(off64_t file_offset) { 15 | fd_ = CreateFile(name_, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); 16 | if (fd_ == INVALID_HANDLE_VALUE) { 17 | DL_ERR("can't open file \"%s\": %s", name_, my_strerror(GetLastError())); 18 | return false; 19 | } 20 | 21 | if (_stat64(name_, &file_stat_) != 0) { 22 | DL_ERR("can't _stat64 file \"%s\"", name_); 23 | return false; 24 | } 25 | 26 | mapping_ = CreateFileMapping(fd_, NULL, PAGE_READWRITE, 0, 0, NULL); 27 | if (mapping_ == NULL) { 28 | DL_ERR("can't mapping file \"%s\": %s", name_, my_strerror(GetLastError())); 29 | return false; 30 | } 31 | file_base_ = (ElfW(Addr))mmap64(0, 0, 0, 0, mapping_, 0); 32 | 33 | elf_reader_ = new ElfReader(name_, fd_, mapping_, file_offset, file_stat_.st_size); 34 | if (elf_reader_->Load(NULL) == false) { 35 | DL_ERR("elf reader failed."); 36 | return false; 37 | } 38 | 39 | for (size_t i = 0; i < elf_reader_->phdr_count(); i++) { 40 | const ElfW(Phdr) &phdr = elf_reader_->loaded_phdr()[i]; 41 | if (phdr.p_type != PT_LOAD) { 42 | continue; 43 | } 44 | header_.load_seg_num_++; 45 | Loadable load; 46 | load.p_vaddr = phdr.p_vaddr; 47 | load.p_offset = phdr.p_offset; 48 | load.p_filesz = phdr.p_filesz; 49 | load.p_memsz = phdr.p_memsz; 50 | load.p_flags = phdr.p_flags; 51 | load.data = (uint8_t *)malloc(phdr.p_filesz); 52 | ssize_t rc = pread64(fd_, load.data, phdr.p_filesz, file_offset + phdr.p_offset); 53 | if (rc == -1 || rc != phdr.p_filesz) { 54 | DL_ERR("read loadable data failed, index: %d.", i); 55 | return false; 56 | } 57 | vload_.push_back(load); 58 | } 59 | 60 | si_ = soinfo_alloc(name_, &file_stat_, file_offset, 0); 61 | if (si_ == nullptr) { 62 | DL_ERR("can't alloc space for soinfo."); 63 | return false; 64 | } 65 | 66 | si_->base = elf_reader_->load_start(); 67 | si_->size = elf_reader_->load_size(); 68 | si_->load_bias = elf_reader_->load_bias(); 69 | si_->phnum = elf_reader_->phdr_count(); 70 | si_->phdr = elf_reader_->loaded_phdr(); 71 | 72 | si_->prelink_image(header_); 73 | 74 | header_.min_vaddr = elf_reader_->min_vaddr(); 75 | header_.load_size_ = elf_reader_->load_size(); 76 | 77 | return true; 78 | } -------------------------------------------------------------------------------- /Extract/Extract/LibraryLoader.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef LIBRARY_LOADER_H_ 3 | #define LIBRARY_LOADER_H_ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "Header.h" 12 | 13 | class LibraryLoader { 14 | public: 15 | LibraryLoader(const char *name); 16 | ~LibraryLoader(); 17 | 18 | bool Load(off64_t file_offset); 19 | 20 | public: 21 | const char *name_; 22 | HANDLE fd_; 23 | HANDLE mapping_; 24 | ElfW(Addr) file_base_; 25 | struct _stat64 file_stat_; 26 | ElfReader* elf_reader_; 27 | soinfo* si_; 28 | Header header_; 29 | std::vector vload_; 30 | }; 31 | 32 | #endif -------------------------------------------------------------------------------- /Extract/Extract/TEA.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CCint3/LLeGu/c3b4c31709e5759c943d3fa07345555c2c650bdd/Extract/Extract/TEA.c -------------------------------------------------------------------------------- /Extract/Extract/TEA.h: -------------------------------------------------------------------------------- 1 | #ifndef TEA_H_ 2 | #define TEA_H_ 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | __declspec(dllexport) 11 | void __stdcall decrypt(uint32_t *key_, uint32_t *buf_, int buf_size_, int round_count_); 12 | 13 | __declspec(dllexport) 14 | void __stdcall encrypt(uint32_t *key_, uint32_t *buf_, int buf_size_, int round_count_); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | #endif -------------------------------------------------------------------------------- /Extract/Extract/file.cpp: -------------------------------------------------------------------------------- 1 | #include "file.h" 2 | #include 3 | 4 | ssize_t pread64(HANDLE __fd, void* __buf, size_t __count, off64_t __offset) { 5 | DWORD rc = 0; 6 | off64_t file_offset = __offset; 7 | rc = SetFilePointer(__fd, *(PLONG)&__offset, ((PLONG)&__offset) + 1, FILE_BEGIN); 8 | *(DWORD *)&__offset = rc; 9 | if (file_offset != __offset) { 10 | return -1; 11 | } 12 | return ReadFile(__fd, __buf, __count, &rc, NULL) != 0 ? rc : -1; 13 | } 14 | 15 | ssize_t pwrite64(HANDLE __fd, const void* __buf, size_t __count, off64_t __offset) { 16 | DWORD rc = 0; 17 | off64_t file_offset = __offset; 18 | rc = SetFilePointer(__fd, *(PLONG)&__offset, ((PLONG)&__offset) + 1, FILE_BEGIN); 19 | *(DWORD *)&__offset = rc; 20 | if (file_offset != __offset) { 21 | return -1; 22 | } 23 | return WriteFile(__fd, __buf, __count, &rc, NULL) != 0 ? rc : -1; 24 | } 25 | 26 | void* mmap(void* __addr, size_t __size, int __prot, int __flags, HANDLE __fd, off_t __offset) { 27 | return mmap64(__addr, __size, __prot, __flags, __fd, __offset); 28 | } 29 | 30 | void* mmap64(void* __addr, size_t __size, int __prot, int __flags, HANDLE mapping, off64_t __offset) { 31 | return MapViewOfFile(mapping, FILE_MAP_READ|FILE_MAP_WRITE, ((uint32_t *)&__offset)[1], ((uint32_t *)&__offset)[0], __size); 32 | } 33 | 34 | LPTSTR g_buf = NULL; 35 | DWORD g_buf_len = 0; 36 | 37 | LPTSTR my_strerror(DWORD errno_) { 38 | LPTSTR buf; 39 | if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER 40 | | FORMAT_MESSAGE_IGNORE_INSERTS 41 | | FORMAT_MESSAGE_FROM_SYSTEM 42 | | FORMAT_MESSAGE_MAX_WIDTH_MASK, 43 | NULL, 44 | errno_, 45 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 46 | (LPTSTR)&buf, 47 | 0, 48 | NULL)) { 49 | DWORD len = strlen(buf); 50 | if (g_buf == NULL) { 51 | g_buf = (LPTSTR)malloc(len * 2); 52 | g_buf_len = len * 2; 53 | } 54 | if (g_buf_len <= len) { 55 | g_buf = (LPTSTR)realloc(g_buf, len * 2); 56 | g_buf_len = len * 2; 57 | } 58 | strcpy(g_buf, buf); 59 | LocalFree(buf); 60 | return g_buf; 61 | } 62 | return NULL; 63 | } -------------------------------------------------------------------------------- /Extract/Extract/file.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | #define DL_ERR(fmt, ...) fprintf(stderr, "DL_ERR: " ## fmt ## "\r\n", __VA_ARGS__) 11 | 12 | #define DL_WARN(fmt, ...) fprintf(stdout, "DL_WARN: " ## fmt ## "\r\n", __VA_ARGS__) 13 | 14 | #define INFO(fmt, ...) fprintf(stdout, "INFO: " ## fmt ## "\r\n", __VA_ARGS__) 15 | 16 | #define DEBUG(fmt, ...) fprintf(stdout, "DEBUG: " ## fmt ## "\r\n", __VA_ARGS__) 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | ssize_t pread64(HANDLE __fd, void* __buf, size_t __count, off64_t __offset); 23 | 24 | void* mmap(void* __addr, size_t __size, int __prot, int __flags, HANDLE __fd, off_t __offset); 25 | 26 | void* mmap64(void* __addr, size_t __size, int __prot, int __flags, HANDLE __fd, off64_t __offset); 27 | 28 | LPTSTR my_strerror(DWORD errno_); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif -------------------------------------------------------------------------------- /Extract/Extract/includes/android/api-level.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in 12 | * the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef ANDROID_API_LEVEL_H 30 | #define ANDROID_API_LEVEL_H 31 | 32 | /* 33 | * Magic version number for a current development build, which has 34 | * not yet turned into an official release. 35 | */ 36 | #define __ANDROID_API__ 10000 37 | 38 | #endif /* ANDROID_API_LEVEL_H */ 39 | -------------------------------------------------------------------------------- /Extract/Extract/includes/android/dlext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __ANDROID_DLEXT_H__ 18 | #define __ANDROID_DLEXT_H__ 19 | 20 | #include 21 | #include 22 | #include 23 | #include /* for off64_t */ 24 | 25 | __BEGIN_DECLS 26 | 27 | /* bitfield definitions for android_dlextinfo.flags */ 28 | enum { 29 | /* When set, the reserved_addr and reserved_size fields must point to an 30 | * already-reserved region of address space which will be used to load the 31 | * library if it fits. If the reserved region is not large enough, the load 32 | * will fail. 33 | */ 34 | ANDROID_DLEXT_RESERVED_ADDRESS = 0x1, 35 | 36 | /* As DLEXT_RESERVED_ADDRESS, but if the reserved region is not large enough, 37 | * the linker will choose an available address instead. 38 | */ 39 | ANDROID_DLEXT_RESERVED_ADDRESS_HINT = 0x2, 40 | 41 | /* When set, write the GNU RELRO section of the mapped library to relro_fd 42 | * after relocation has been performed, to allow it to be reused by another 43 | * process loading the same library at the same address. This implies 44 | * ANDROID_DLEXT_USE_RELRO. 45 | */ 46 | ANDROID_DLEXT_WRITE_RELRO = 0x4, 47 | 48 | /* When set, compare the GNU RELRO section of the mapped library to relro_fd 49 | * after relocation has been performed, and replace any relocated pages that 50 | * are identical with a version mapped from the file. 51 | */ 52 | ANDROID_DLEXT_USE_RELRO = 0x8, 53 | 54 | /* Instruct dlopen to use library_fd instead of opening file by name. 55 | * The filename parameter is still used to identify the library. 56 | */ 57 | ANDROID_DLEXT_USE_LIBRARY_FD = 0x10, 58 | 59 | /* If opening a library using library_fd read it starting at library_fd_offset. 60 | * This flag is only valid when ANDROID_DLEXT_USE_LIBRARY_FD is set. 61 | */ 62 | ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET = 0x20, 63 | 64 | /* When set, do not check if the library has already been loaded by file stat(2)s. 65 | * 66 | * This flag allows forced loading of the library in the case when for some 67 | * reason multiple ELF files share the same filename (because the already-loaded 68 | * library has been removed and overwritten, for example). 69 | * 70 | * Note that if the library has the same dt_soname as an old one and some other 71 | * library has the soname in DT_NEEDED list, the first one will be used to resolve any 72 | * dependencies. 73 | */ 74 | ANDROID_DLEXT_FORCE_LOAD = 0x40, 75 | 76 | /* When set, if the minimum p_vaddr of the ELF file's PT_LOAD segments is non-zero, 77 | * the dynamic linker will load it at that address. 78 | * 79 | * This flag is for ART internal use only. 80 | */ 81 | ANDROID_DLEXT_FORCE_FIXED_VADDR = 0x80, 82 | 83 | /* Mask of valid bits */ 84 | ANDROID_DLEXT_VALID_FLAG_BITS = ANDROID_DLEXT_RESERVED_ADDRESS | 85 | ANDROID_DLEXT_RESERVED_ADDRESS_HINT | 86 | ANDROID_DLEXT_WRITE_RELRO | 87 | ANDROID_DLEXT_USE_RELRO | 88 | ANDROID_DLEXT_USE_LIBRARY_FD | 89 | ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET | 90 | ANDROID_DLEXT_FORCE_LOAD | 91 | ANDROID_DLEXT_FORCE_FIXED_VADDR, 92 | }; 93 | 94 | typedef struct { 95 | uint64_t flags; 96 | void* reserved_addr; 97 | size_t reserved_size; 98 | int relro_fd; 99 | int library_fd; 100 | off64_t library_fd_offset; 101 | } android_dlextinfo; 102 | 103 | extern void* android_dlopen_ext(const char* filename, int flag, const android_dlextinfo* extinfo); 104 | 105 | __END_DECLS 106 | 107 | #endif /* __ANDROID_DLEXT_H__ */ 108 | -------------------------------------------------------------------------------- /Extract/Extract/includes/asm-generic/auxvec.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #ifndef __ASM_GENERIC_AUXVEC_H 20 | #define __ASM_GENERIC_AUXVEC_H 21 | #endif 22 | -------------------------------------------------------------------------------- /Extract/Extract/includes/asm-generic/bitsperlong.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #ifndef _UAPI__ASM_GENERIC_BITS_PER_LONG 20 | #define _UAPI__ASM_GENERIC_BITS_PER_LONG 21 | #ifndef __BITS_PER_LONG 22 | #define __BITS_PER_LONG 32 23 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 24 | #endif 25 | #endif 26 | -------------------------------------------------------------------------------- /Extract/Extract/includes/asm-generic/int-ll64.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #ifndef _UAPI_ASM_GENERIC_INT_LL64_H 20 | #define _UAPI_ASM_GENERIC_INT_LL64_H 21 | #include 22 | #ifndef __ASSEMBLY__ 23 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 24 | typedef signed char __s8; 25 | typedef unsigned char __u8; 26 | typedef signed short __s16; 27 | typedef unsigned short __u16; 28 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 29 | typedef signed int __s32; 30 | typedef unsigned int __u32; 31 | #ifdef __GNUC__ 32 | __extension__ typedef signed long long __s64; 33 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 34 | __extension__ typedef unsigned long long __u64; 35 | #else 36 | typedef signed long long __s64; 37 | typedef unsigned long long __u64; 38 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 39 | #endif 40 | #endif 41 | #endif 42 | -------------------------------------------------------------------------------- /Extract/Extract/includes/asm-generic/mman-common.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #ifndef __ASM_GENERIC_MMAN_COMMON_H 20 | #define __ASM_GENERIC_MMAN_COMMON_H 21 | #define PROT_READ 0x1 22 | #define PROT_WRITE 0x2 23 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 24 | #define PROT_EXEC 0x4 25 | #define PROT_SEM 0x8 26 | #define PROT_NONE 0x0 27 | #define PROT_GROWSDOWN 0x01000000 28 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 29 | #define PROT_GROWSUP 0x02000000 30 | #define MAP_SHARED 0x01 31 | #define MAP_PRIVATE 0x02 32 | #define MAP_TYPE 0x0f 33 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 34 | #define MAP_FIXED 0x10 35 | #define MAP_ANONYMOUS 0x20 36 | #define MAP_UNINITIALIZED 0x0 37 | #define MS_ASYNC 1 38 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 39 | #define MS_INVALIDATE 2 40 | #define MS_SYNC 4 41 | #define MADV_NORMAL 0 42 | #define MADV_RANDOM 1 43 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 44 | #define MADV_SEQUENTIAL 2 45 | #define MADV_WILLNEED 3 46 | #define MADV_DONTNEED 4 47 | #define MADV_REMOVE 9 48 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 49 | #define MADV_DONTFORK 10 50 | #define MADV_DOFORK 11 51 | #define MADV_HWPOISON 100 52 | #define MADV_SOFT_OFFLINE 101 53 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 54 | #define MADV_MERGEABLE 12 55 | #define MADV_UNMERGEABLE 13 56 | #define MADV_HUGEPAGE 14 57 | #define MADV_NOHUGEPAGE 15 58 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 59 | #define MADV_DONTDUMP 16 60 | #define MADV_DODUMP 17 61 | #define MAP_FILE 0 62 | #define MAP_HUGE_SHIFT 26 63 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 64 | #define MAP_HUGE_MASK 0x3f 65 | #endif 66 | -------------------------------------------------------------------------------- /Extract/Extract/includes/asm-generic/mman.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #ifndef __ASM_GENERIC_MMAN_H 20 | #define __ASM_GENERIC_MMAN_H 21 | #include 22 | #define MAP_GROWSDOWN 0x0100 23 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 24 | #define MAP_DENYWRITE 0x0800 25 | #define MAP_EXECUTABLE 0x1000 26 | #define MAP_LOCKED 0x2000 27 | #define MAP_NORESERVE 0x4000 28 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 29 | #define MAP_POPULATE 0x8000 30 | #define MAP_NONBLOCK 0x10000 31 | #define MAP_STACK 0x20000 32 | #define MAP_HUGETLB 0x40000 33 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 34 | #define MCL_CURRENT 1 35 | #define MCL_FUTURE 2 36 | #endif 37 | -------------------------------------------------------------------------------- /Extract/Extract/includes/asm-generic/param.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #ifndef _UAPI__ASM_GENERIC_PARAM_H 20 | #define _UAPI__ASM_GENERIC_PARAM_H 21 | #ifndef HZ 22 | #define HZ 100 23 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 24 | #endif 25 | #ifndef EXEC_PAGESIZE 26 | #define EXEC_PAGESIZE 4096 27 | #endif 28 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 29 | #ifndef NOGROUP 30 | #define NOGROUP (- 1) 31 | #endif 32 | #define MAXHOSTNAMELEN 64 33 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 34 | #endif 35 | -------------------------------------------------------------------------------- /Extract/Extract/includes/asm-generic/posix_types.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #ifndef __ASM_GENERIC_POSIX_TYPES_H 20 | #define __ASM_GENERIC_POSIX_TYPES_H 21 | #include 22 | #ifndef __kernel_long_t 23 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 24 | typedef long __kernel_long_t; 25 | typedef unsigned long __kernel_ulong_t; 26 | #endif 27 | #ifndef __kernel_ino_t 28 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 29 | typedef __kernel_ulong_t __kernel_ino_t; 30 | #endif 31 | #ifndef __kernel_mode_t 32 | typedef unsigned int __kernel_mode_t; 33 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 34 | #endif 35 | #ifndef __kernel_pid_t 36 | typedef int __kernel_pid_t; 37 | #endif 38 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 39 | #ifndef __kernel_ipc_pid_t 40 | typedef int __kernel_ipc_pid_t; 41 | #endif 42 | #ifndef __kernel_uid_t 43 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 44 | typedef unsigned int __kernel_uid_t; 45 | typedef unsigned int __kernel_gid_t; 46 | #endif 47 | #ifndef __kernel_suseconds_t 48 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 49 | typedef __kernel_long_t __kernel_suseconds_t; 50 | #endif 51 | #ifndef __kernel_daddr_t 52 | typedef int __kernel_daddr_t; 53 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 54 | #endif 55 | #ifndef __kernel_uid32_t 56 | typedef unsigned int __kernel_uid32_t; 57 | typedef unsigned int __kernel_gid32_t; 58 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 59 | #endif 60 | #ifndef __kernel_old_uid_t 61 | typedef __kernel_uid_t __kernel_old_uid_t; 62 | typedef __kernel_gid_t __kernel_old_gid_t; 63 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 64 | #endif 65 | #ifndef __kernel_old_dev_t 66 | typedef unsigned int __kernel_old_dev_t; 67 | #endif 68 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 69 | #ifndef __kernel_size_t 70 | #if __BITS_PER_LONG != 64 71 | typedef unsigned int __kernel_size_t; 72 | typedef int __kernel_ssize_t; 73 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 74 | typedef int __kernel_ptrdiff_t; 75 | #else 76 | typedef __kernel_ulong_t __kernel_size_t; 77 | typedef __kernel_long_t __kernel_ssize_t; 78 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 79 | typedef __kernel_long_t __kernel_ptrdiff_t; 80 | #endif 81 | #endif 82 | #ifndef __kernel_fsid_t 83 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 84 | typedef struct { 85 | int val[2]; 86 | } __kernel_fsid_t; 87 | #endif 88 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 89 | typedef __kernel_long_t __kernel_off_t; 90 | typedef long long __kernel_loff_t; 91 | typedef __kernel_long_t __kernel_time_t; 92 | typedef __kernel_long_t __kernel_clock_t; 93 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 94 | typedef int __kernel_timer_t; 95 | typedef int __kernel_clockid_t; 96 | typedef char * __kernel_caddr_t; 97 | typedef unsigned short __kernel_uid16_t; 98 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 99 | typedef unsigned short __kernel_gid16_t; 100 | 101 | #if defined(__USE_FILE_OFFSET64) || defined(__LP64__) 102 | typedef int64_t off_t; 103 | typedef off_t loff_t; 104 | typedef loff_t off64_t; 105 | #else 106 | /* This historical accident means that we had a 32-bit off_t on 32-bit architectures. */ 107 | typedef __kernel_off_t off_t; 108 | typedef __kernel_loff_t loff_t; 109 | typedef loff_t off64_t; 110 | #endif 111 | 112 | #ifndef _SSIZE_T_DEFINED_ 113 | #define _SSIZE_T_DEFINED_ 114 | /* Traditionally, bionic's ssize_t was "long int". This caused GCC to emit warnings when you 115 | * pass a ssize_t to a printf-style function. The correct type is __kernel_ssize_t, which is 116 | * "int", which isn't an ABI change for C code (because they're the same size) but is an ABI 117 | * change for C++ because "int" and "long int" mangle to "i" and "l" respectively. So until 118 | * we can fix the ABI, this change should not be propagated to the NDK. http://b/8253769. */ 119 | typedef __kernel_ssize_t ssize_t; 120 | #endif 121 | 122 | #endif 123 | -------------------------------------------------------------------------------- /Extract/Extract/includes/asm-generic/types.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #ifndef _ASM_GENERIC_TYPES_H 20 | #define _ASM_GENERIC_TYPES_H 21 | #include 22 | #endif 23 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 24 | -------------------------------------------------------------------------------- /Extract/Extract/includes/asm/auxvec.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #include 20 | -------------------------------------------------------------------------------- /Extract/Extract/includes/asm/bitsperlong.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #include 20 | -------------------------------------------------------------------------------- /Extract/Extract/includes/asm/mman.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #include 20 | #define arch_mmap_check(addr,len,flags) (((flags) & MAP_FIXED && (addr) < FIRST_USER_ADDRESS) ? - EINVAL : 0) 21 | -------------------------------------------------------------------------------- /Extract/Extract/includes/asm/param.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #include 20 | -------------------------------------------------------------------------------- /Extract/Extract/includes/asm/posix_types.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #ifndef __ARCH_ARM_POSIX_TYPES_H 20 | #define __ARCH_ARM_POSIX_TYPES_H 21 | typedef unsigned short __kernel_mode_t; 22 | #define __kernel_mode_t __kernel_mode_t 23 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 24 | typedef unsigned short __kernel_ipc_pid_t; 25 | #define __kernel_ipc_pid_t __kernel_ipc_pid_t 26 | typedef unsigned short __kernel_uid_t; 27 | typedef unsigned short __kernel_gid_t; 28 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 29 | #define __kernel_uid_t __kernel_uid_t 30 | typedef unsigned short __kernel_old_dev_t; 31 | #define __kernel_old_dev_t __kernel_old_dev_t 32 | #include 33 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 34 | #endif 35 | -------------------------------------------------------------------------------- /Extract/Extract/includes/asm/types.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #include 20 | -------------------------------------------------------------------------------- /Extract/Extract/includes/dlfcn.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in 12 | * the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | #ifndef __DLFCN_H__ 29 | #define __DLFCN_H__ 30 | 31 | #include 32 | 33 | __BEGIN_DECLS 34 | 35 | typedef struct { 36 | const char *dli_fname; /* Pathname of shared object that 37 | contains address */ 38 | void *dli_fbase; /* Address at which shared object 39 | is loaded */ 40 | const char *dli_sname; /* Name of nearest symbol with address 41 | lower than addr */ 42 | void *dli_saddr; /* Exact address of symbol named 43 | in dli_sname */ 44 | } Dl_info; 45 | 46 | extern void* dlopen(const char* filename, int flag); 47 | extern int dlclose(void* handle); 48 | extern const char* dlerror(void); 49 | extern void* dlsym(void* handle, const char* symbol); 50 | extern int dladdr(const void* addr, Dl_info *info); 51 | 52 | enum { 53 | #if defined(__LP64__) 54 | RTLD_NOW = 2, 55 | #else 56 | RTLD_NOW = 0, 57 | #endif 58 | RTLD_LAZY = 1, 59 | 60 | RTLD_LOCAL = 0, 61 | #if defined(__LP64__) 62 | RTLD_GLOBAL = 0x00100, 63 | #else 64 | RTLD_GLOBAL = 2, 65 | #endif 66 | RTLD_NOLOAD = 4, 67 | RTLD_NODELETE = 0x01000, 68 | }; 69 | 70 | #if defined (__LP64__) 71 | #define RTLD_DEFAULT ((void*) 0) 72 | #define RTLD_NEXT ((void*) -1L) 73 | #else 74 | #define RTLD_DEFAULT ((void*) 0xffffffff) 75 | #define RTLD_NEXT ((void*) 0xfffffffe) 76 | #endif 77 | 78 | __END_DECLS 79 | 80 | #endif /* __DLFCN_H */ 81 | 82 | 83 | -------------------------------------------------------------------------------- /Extract/Extract/includes/elf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in 12 | * the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | #ifndef _ELF_H 29 | #define _ELF_H 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #include 36 | 37 | #define ELF32_R_INFO(sym, type) ((((Elf32_Word)sym) << 8) | ((type) & 0xff)) 38 | #define ELF64_R_INFO(sym, type) ((((Elf64_Xword)sym) << 32) | ((type) & 0xffffffff)) 39 | 40 | typedef __s64 Elf32_Sxword; 41 | 42 | typedef struct { 43 | __u32 a_type; 44 | union { 45 | __u32 a_val; 46 | } a_un; 47 | } Elf32_auxv_t; 48 | 49 | typedef struct { 50 | __u64 a_type; 51 | union { 52 | __u64 a_val; 53 | } a_un; 54 | } Elf64_auxv_t; 55 | 56 | typedef Elf32_Half Elf32_Versym; 57 | typedef Elf64_Half Elf64_Versym; 58 | 59 | typedef struct { 60 | Elf32_Half vd_version; 61 | Elf32_Half vd_flags; 62 | Elf32_Half vd_ndx; 63 | Elf32_Half vd_cnt; 64 | Elf32_Word vd_hash; 65 | Elf32_Word vd_aux; 66 | Elf32_Word vd_next; 67 | } Elf32_Verdef; 68 | 69 | typedef struct { 70 | Elf32_Word vda_name; 71 | Elf32_Word vda_next; 72 | } Elf32_Verdaux; 73 | 74 | typedef struct { 75 | Elf64_Half vd_version; 76 | Elf64_Half vd_flags; 77 | Elf64_Half vd_ndx; 78 | Elf64_Half vd_cnt; 79 | Elf64_Word vd_hash; 80 | Elf64_Word vd_aux; 81 | Elf64_Word vd_next; 82 | } Elf64_Verdef; 83 | 84 | typedef struct { 85 | Elf64_Word vda_name; 86 | Elf64_Word vda_next; 87 | } Elf64_Verdaux; 88 | 89 | typedef struct { 90 | Elf32_Half vn_version; 91 | Elf32_Half vn_cnt; 92 | Elf32_Word vn_file; 93 | Elf32_Word vn_aux; 94 | Elf32_Word vn_next; 95 | } Elf32_Verneed; 96 | 97 | typedef struct { 98 | Elf32_Word vna_hash; 99 | Elf32_Half vna_flags; 100 | Elf32_Half vna_other; 101 | Elf32_Word vna_name; 102 | Elf32_Word vna_next; 103 | } Elf32_Vernaux; 104 | 105 | typedef struct { 106 | Elf64_Half vn_version; 107 | Elf64_Half vn_cnt; 108 | Elf64_Word vn_file; 109 | Elf64_Word vn_aux; 110 | Elf64_Word vn_next; 111 | } Elf64_Verneed; 112 | 113 | typedef struct { 114 | Elf64_Word vna_hash; 115 | Elf64_Half vna_flags; 116 | Elf64_Half vna_other; 117 | Elf64_Word vna_name; 118 | Elf64_Word vna_next; 119 | } Elf64_Vernaux; 120 | 121 | #define DF_ORIGIN 0x00000001 122 | #define DF_SYMBOLIC 0x00000002 123 | #define DF_TEXTREL 0x00000004 124 | #define DF_BIND_NOW 0x00000008 125 | #define DF_STATIC_TLS 0x00000010 126 | 127 | #define DF_1_NOW 0x00000001 /* Perform complete relocation processing. */ 128 | #define DF_1_GLOBAL 0x00000002 /* implies RTLD_GLOBAL */ 129 | #define DF_1_GROUP 0x00000004 130 | #define DF_1_NODELETE 0x00000008 /* implies RTLD_NODELETE */ 131 | #define DF_1_LOADFLTR 0x00000010 132 | #define DF_1_INITFIRST 0x00000020 133 | #define DF_1_NOOPEN 0x00000040 /* Object can not be used with dlopen(3) */ 134 | #define DF_1_ORIGIN 0x00000080 135 | #define DF_1_DIRECT 0x00000100 136 | #define DF_1_TRANS 0x00000200 137 | #define DF_1_INTERPOSE 0x00000400 138 | #define DF_1_NODEFLIB 0x00000800 139 | #define DF_1_NODUMP 0x00001000 /* Object cannot be dumped with dldump(3) */ 140 | #define DF_1_CONFALT 0x00002000 141 | #define DF_1_ENDFILTEE 0x00004000 142 | #define DF_1_DISPRELDNE 0x00008000 143 | #define DF_1_DISPRELPND 0x00010000 144 | #define DF_1_NODIRECT 0x00020000 145 | #define DF_1_IGNMULDEF 0x00040000 /* Internal use */ 146 | #define DF_1_NOKSYMS 0x00080000 /* Internal use */ 147 | #define DF_1_NOHDR 0x00100000 /* Internal use */ 148 | #define DF_1_EDITED 0x00200000 149 | #define DF_1_NORELOC 0x00400000 /* Internal use */ 150 | #define DF_1_SYMINTPOSE 0x00800000 151 | #define DF_1_GLOBAUDIT 0x01000000 152 | #define DF_1_SINGLETON 0x02000000 153 | #define DF_1_STUB 0x04000000 154 | #define DF_1_PIE 0x08000000 155 | 156 | #define DT_BIND_NOW 24 157 | #define DT_INIT_ARRAY 25 158 | #define DT_FINI_ARRAY 26 159 | #define DT_INIT_ARRAYSZ 27 160 | #define DT_FINI_ARRAYSZ 28 161 | #define DT_RUNPATH 29 162 | #define DT_FLAGS 30 163 | /* glibc and BSD disagree for DT_ENCODING; glibc looks wrong. */ 164 | #define DT_PREINIT_ARRAY 32 165 | #define DT_PREINIT_ARRAYSZ 33 166 | 167 | /* Android compressed rel/rela sections */ 168 | #define DT_ANDROID_REL (DT_LOOS + 2) 169 | #define DT_ANDROID_RELSZ (DT_LOOS + 3) 170 | 171 | #define DT_ANDROID_RELA (DT_LOOS + 4) 172 | #define DT_ANDROID_RELASZ (DT_LOOS + 5) 173 | 174 | /* gnu hash entry */ 175 | #define DT_GNU_HASH 0x6ffffef5 176 | 177 | #define ELFOSABI_SYSV 0 /* Synonym for ELFOSABI_NONE used by valgrind. */ 178 | 179 | #define PT_GNU_RELRO 0x6474e552 180 | 181 | #define STB_LOOS 10 182 | #define STB_HIOS 12 183 | #define STB_LOPROC 13 184 | #define STB_HIPROC 15 185 | 186 | #define SHT_LOOS 0x60000000 187 | #define SHT_HIOS 0x6fffffff 188 | 189 | #define STT_GNU_IFUNC 10 190 | #define STT_LOOS 10 191 | #define STT_HIOS 12 192 | #define STT_LOPROC 13 193 | #define STT_HIPROC 15 194 | 195 | #define STV_DEFAULT 0 196 | #define STV_INTERNAL 1 197 | #define STV_HIDDEN 2 198 | #define STV_PROTECTED 3 199 | 200 | /* The kernel uses NT_PRFPREG but glibc also offers NT_FPREGSET */ 201 | #define NT_FPREGSET NT_PRFPREG 202 | 203 | #define ELF_NOTE_GNU "GNU" 204 | 205 | #define NT_GNU_BUILD_ID 3 206 | 207 | #define VER_FLG_BASE 0x1 208 | #define VER_FLG_WEAK 0x2 209 | 210 | #define VER_NDX_LOCAL 0 211 | #define VER_NDX_GLOBAL 1 212 | 213 | #endif /* _ELF_H */ 214 | -------------------------------------------------------------------------------- /Extract/Extract/includes/limits.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: limits.h,v 1.13 2005/12/31 19:29:38 millert Exp $ */ 2 | /* $NetBSD: limits.h,v 1.7 1994/10/26 00:56:00 cgd Exp $ */ 3 | 4 | /* 5 | * Copyright (c) 1988 The Regents of the University of California. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 3. Neither the name of the University nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | * 32 | * @(#)limits.h 5.9 (Berkeley) 4/3/91 33 | */ 34 | 35 | #ifndef _LIMITS_H_ 36 | #define _LIMITS_H_ 37 | 38 | #include 39 | 40 | #if __XPG_VISIBLE 41 | #define PASS_MAX 128 /* _PASSWORD_LEN from */ 42 | 43 | #define NL_ARGMAX 9 44 | #define NL_LANGMAX 14 45 | #define NL_MSGMAX 32767 46 | #define NL_NMAX 1 47 | #define NL_SETMAX 255 48 | #define NL_TEXTMAX 255 49 | 50 | //#define TMP_MAX 308915776 51 | #endif /* __XPG_VISIBLE */ 52 | 53 | #include 54 | 55 | #if __POSIX_VISIBLE 56 | #include 57 | #endif 58 | 59 | /* GLibc compatibility definitions. 60 | Note that these are defined by GCC's 61 | only when __GNU_LIBRARY__ is defined, i.e. when 62 | targetting GLibc. */ 63 | #ifndef LONG_LONG_MIN 64 | #define LONG_LONG_MIN LLONG_MIN 65 | #endif 66 | 67 | #ifndef LONG_LONG_MAX 68 | #define LONG_LONG_MAX LLONG_MAX 69 | #endif 70 | 71 | #ifndef ULONG_LONG_MAX 72 | #define ULONG_LONG_MAX ULLONG_MAX 73 | #endif 74 | 75 | /* BSD compatibility definitions. */ 76 | #if __BSD_VISIBLE 77 | #define SIZE_T_MAX ULONG_MAX 78 | #endif /* __BSD_VISIBLE */ 79 | 80 | #define SSIZE_MAX LONG_MAX 81 | 82 | #define MB_LEN_MAX 4 83 | 84 | /* New code should use sysconf(_SC_PAGE_SIZE) instead. */ 85 | #ifndef PAGE_SIZE 86 | #define PAGE_SIZE 4096 87 | #endif 88 | #ifndef PAGESIZE 89 | #define PAGESIZE PAGE_SIZE 90 | #endif 91 | 92 | /* glibc's PAGE_MASK is the bitwise negation of BSD's! TODO: remove? */ 93 | #define PAGE_MASK (~(PAGE_SIZE - 1)) 94 | 95 | #define SEM_VALUE_MAX 0x3fffffff 96 | 97 | /* POSIX says these belong in but BSD has some in . */ 98 | #include 99 | 100 | #define HOST_NAME_MAX _POSIX_HOST_NAME_MAX 101 | #endif /* !_LIMITS_H_ */ 102 | -------------------------------------------------------------------------------- /Extract/Extract/includes/link.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The Android Open Source Project 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in 12 | * the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | #ifndef _LINK_H_ 29 | #define _LINK_H_ 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | __BEGIN_DECLS 36 | 37 | #if __LP64__ 38 | #define ElfW(type) Elf64_ ## type 39 | #else 40 | #define ElfW(type) Elf32_ ## type 41 | #endif 42 | 43 | struct dl_phdr_info { 44 | ElfW(Addr) dlpi_addr; 45 | const char* dlpi_name; 46 | const ElfW(Phdr)* dlpi_phdr; 47 | ElfW(Half) dlpi_phnum; 48 | }; 49 | 50 | int dl_iterate_phdr(int (*)(struct dl_phdr_info*, size_t, void*), void*); 51 | 52 | #ifdef __arm__ 53 | typedef long unsigned int* _Unwind_Ptr; 54 | _Unwind_Ptr dl_unwind_find_exidx(_Unwind_Ptr, int*); 55 | #endif 56 | 57 | /* Used by the dynamic linker to communicate with the debugger. */ 58 | struct link_map { 59 | ElfW(Addr) l_addr; 60 | char* l_name; 61 | ElfW(Dyn)* l_ld; 62 | struct link_map* l_next; 63 | struct link_map* l_prev; 64 | }; 65 | 66 | /* Used by the dynamic linker to communicate with the debugger. */ 67 | struct r_debug { 68 | //int32_t r_version; 69 | struct link_map* r_map; 70 | ElfW(Addr) r_brk; 71 | enum { 72 | RT_CONSISTENT, 73 | RT_ADD, 74 | RT_DELETE 75 | } r_state; 76 | ElfW(Addr) r_ldbase; 77 | }; 78 | 79 | __END_DECLS 80 | 81 | #endif /* _LINK_H_ */ 82 | -------------------------------------------------------------------------------- /Extract/Extract/includes/linked_list.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __LINKED_LIST_H 18 | #define __LINKED_LIST_H 19 | 20 | #include "private/bionic_macros.h" 21 | 22 | template 23 | struct LinkedListEntry { 24 | LinkedListEntry* next; 25 | T* element; 26 | }; 27 | 28 | /* 29 | * Represents linked list of objects of type T 30 | */ 31 | template 32 | class LinkedList { 33 | public: 34 | LinkedList() : head_(nullptr), tail_(nullptr) {} 35 | ~LinkedList() { 36 | clear(); 37 | } 38 | 39 | LinkedList(LinkedList&& that) { 40 | this->head_ = that.head_; 41 | this->tail_ = that.tail_; 42 | that.head_ = that.tail_ = nullptr; 43 | } 44 | 45 | void push_front(T* const element) { 46 | LinkedListEntry* new_entry = Allocator::alloc(); 47 | new_entry->next = head_; 48 | new_entry->element = element; 49 | head_ = new_entry; 50 | if (tail_ == nullptr) { 51 | tail_ = new_entry; 52 | } 53 | } 54 | 55 | void push_back(T* const element) { 56 | LinkedListEntry* new_entry = Allocator::alloc(); 57 | new_entry->next = nullptr; 58 | new_entry->element = element; 59 | if (tail_ == nullptr) { 60 | tail_ = head_ = new_entry; 61 | } else { 62 | tail_->next = new_entry; 63 | tail_ = new_entry; 64 | } 65 | } 66 | 67 | T* pop_front() { 68 | if (head_ == nullptr) { 69 | return nullptr; 70 | } 71 | 72 | LinkedListEntry* entry = head_; 73 | T* element = entry->element; 74 | head_ = entry->next; 75 | Allocator::free(entry); 76 | 77 | if (head_ == nullptr) { 78 | tail_ = nullptr; 79 | } 80 | 81 | return element; 82 | } 83 | 84 | T* front() const { 85 | if (head_ == nullptr) { 86 | return nullptr; 87 | } 88 | 89 | return head_->element; 90 | } 91 | 92 | void clear() { 93 | while (head_ != nullptr) { 94 | LinkedListEntry* p = head_; 95 | head_ = head_->next; 96 | Allocator::free(p); 97 | } 98 | 99 | tail_ = nullptr; 100 | } 101 | 102 | template 103 | void for_each(F action) const { 104 | visit([&] (T* si) { 105 | action(si); 106 | return true; 107 | }); 108 | } 109 | 110 | template 111 | bool visit(F action) const { 112 | for (LinkedListEntry* e = head_; e != nullptr; e = e->next) { 113 | if (!action(e->element)) { 114 | return false; 115 | } 116 | } 117 | return true; 118 | } 119 | 120 | template 121 | void remove_if(F predicate) { 122 | for (LinkedListEntry* e = head_, *p = nullptr; e != nullptr;) { 123 | if (predicate(e->element)) { 124 | LinkedListEntry* next = e->next; 125 | if (p == nullptr) { 126 | head_ = next; 127 | } else { 128 | p->next = next; 129 | } 130 | Allocator::free(e); 131 | e = next; 132 | } else { 133 | p = e; 134 | e = e->next; 135 | } 136 | } 137 | } 138 | 139 | template 140 | T* find_if(F predicate) const { 141 | for (LinkedListEntry* e = head_; e != nullptr; e = e->next) { 142 | if (predicate(e->element)) { 143 | return e->element; 144 | } 145 | } 146 | 147 | return nullptr; 148 | } 149 | 150 | size_t copy_to_array(T* array[], size_t array_length) const { 151 | size_t sz = 0; 152 | for (LinkedListEntry* e = head_; sz < array_length && e != nullptr; e = e->next) { 153 | array[sz++] = e->element; 154 | } 155 | 156 | return sz; 157 | } 158 | 159 | bool contains(const T* el) const { 160 | for (LinkedListEntry* e = head_; e != nullptr; e = e->next) { 161 | if (e->element == el) { 162 | return true; 163 | } 164 | } 165 | return false; 166 | } 167 | 168 | static LinkedList make_list(T* const element) { 169 | LinkedList one_element_list; 170 | one_element_list.push_back(element); 171 | return one_element_list; 172 | } 173 | 174 | private: 175 | LinkedListEntry* head_; 176 | LinkedListEntry* tail_; 177 | DISALLOW_COPY_AND_ASSIGN(LinkedList); 178 | }; 179 | 180 | #endif // __LINKED_LIST_H 181 | -------------------------------------------------------------------------------- /Extract/Extract/includes/linker.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in 12 | * the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef _LINKER_H_ 30 | #define _LINKER_H_ 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | #include "linked_list.h" 37 | 38 | #include 39 | #include 40 | 41 | #include 42 | #include 43 | #include "Header.h" 44 | 45 | #if defined(__LP64__) 46 | #define ELFW(what) ELF64_ ## what 47 | #else 48 | #define ELFW(what) ELF32_ ## what 49 | #endif 50 | 51 | // mips64 interprets Elf64_Rel structures' r_info field differently. 52 | // bionic (like other C libraries) has macros that assume regular ELF files, 53 | // but the dynamic linker needs to be able to load mips64 ELF files. 54 | #if defined(__mips__) && defined(__LP64__) 55 | #undef ELF64_R_SYM 56 | #undef ELF64_R_TYPE 57 | #undef ELF64_R_INFO 58 | #define ELF64_R_SYM(info) (((info) >> 0) & 0xffffffff) 59 | #define ELF64_R_SSYM(info) (((info) >> 32) & 0xff) 60 | #define ELF64_R_TYPE3(info) (((info) >> 40) & 0xff) 61 | #define ELF64_R_TYPE2(info) (((info) >> 48) & 0xff) 62 | #define ELF64_R_TYPE(info) (((info) >> 56) & 0xff) 63 | #endif 64 | 65 | // Returns the address of the page containing address 'x'. 66 | #define PAGE_START(x) ((x) & PAGE_MASK) 67 | 68 | // Returns the offset of address 'x' in its page. 69 | #define PAGE_OFFSET(x) ((x) & ~PAGE_MASK) 70 | 71 | // Returns the address of the next page after address 'x', unless 'x' is 72 | // itself at the start of a page. 73 | #define PAGE_END(x) PAGE_START((x) + (PAGE_SIZE-1)) 74 | 75 | #define FLAG_LINKED 0x00000001 76 | #define FLAG_EXE 0x00000004 // The main executable 77 | #define FLAG_LINKER 0x00000010 // The linker itself 78 | #define FLAG_GNU_HASH 0x00000040 // uses gnu hash 79 | #define FLAG_NEW_SOINFO 0x40000000 // new soinfo format 80 | 81 | #define SUPPORTED_DT_FLAGS_1 (DF_1_NOW | DF_1_GLOBAL | DF_1_NODELETE) 82 | 83 | #define SOINFO_VERSION 2 84 | 85 | #if defined(__work_around_b_19059885__) 86 | #define SOINFO_NAME_LEN 128 87 | #endif 88 | 89 | typedef void(*linker_function_t)(); 90 | 91 | // Android uses RELA for aarch64 and x86_64. mips64 still uses REL. 92 | #if defined(__aarch64__) || defined(__x86_64__) 93 | #define USE_RELA 1 94 | #endif 95 | 96 | struct soinfo; 97 | 98 | class SoinfoListAllocator { 99 | public: 100 | static LinkedListEntry* alloc(); 101 | static void free(LinkedListEntry* entry); 102 | 103 | private: 104 | // unconstructable 105 | DISALLOW_IMPLICIT_CONSTRUCTORS(SoinfoListAllocator); 106 | }; 107 | 108 | class SymbolName { 109 | public: 110 | explicit SymbolName(const char* name) 111 | : name_(name), has_elf_hash_(false), has_gnu_hash_(false), 112 | elf_hash_(0), gnu_hash_(0) { 113 | } 114 | 115 | const char* get_name() { 116 | return name_; 117 | } 118 | 119 | uint32_t elf_hash(); 120 | uint32_t gnu_hash(); 121 | 122 | private: 123 | const char* name_; 124 | bool has_elf_hash_; 125 | bool has_gnu_hash_; 126 | uint32_t elf_hash_; 127 | uint32_t gnu_hash_; 128 | 129 | DISALLOW_IMPLICIT_CONSTRUCTORS(SymbolName); 130 | }; 131 | 132 | struct version_info { 133 | version_info() : elf_hash(0), name(nullptr), target_si(nullptr) {} 134 | 135 | uint32_t elf_hash; 136 | const char* name; 137 | const soinfo* target_si; 138 | }; 139 | 140 | // Class used construct version dependency graph. 141 | class VersionTracker { 142 | public: 143 | VersionTracker() = default; 144 | bool init(const soinfo* si_from); 145 | 146 | const version_info* get_version_info(ElfW(Versym) source_symver) const; 147 | private: 148 | bool init_verneed(const soinfo* si_from); 149 | bool init_verdef(const soinfo* si_from); 150 | void add_version_info(size_t source_index, ElfW(Word) elf_hash, 151 | const char* ver_name, const soinfo* target_si); 152 | 153 | std::vector version_infos; 154 | 155 | DISALLOW_COPY_AND_ASSIGN(VersionTracker); 156 | }; 157 | 158 | struct soinfo { 159 | public: 160 | typedef LinkedList soinfo_list_t; 161 | #if defined(__work_around_b_19059885__) 162 | private: 163 | char old_name_[SOINFO_NAME_LEN]; 164 | #endif 165 | public: 166 | const ElfW(Phdr)* phdr; 167 | size_t phnum; 168 | ElfW(Addr) entry; 169 | ElfW(Addr) base; 170 | size_t size; 171 | 172 | #if defined(__work_around_b_19059885__) 173 | uint32_t unused1; // DO NOT USE, maintained for compatibility. 174 | #endif 175 | 176 | ElfW(Dyn)* dynamic; 177 | 178 | #if defined(__work_around_b_19059885__) 179 | uint32_t unused2; // DO NOT USE, maintained for compatibility 180 | uint32_t unused3; // DO NOT USE, maintained for compatibility 181 | #endif 182 | 183 | soinfo* next; 184 | private: 185 | uint32_t flags_; 186 | 187 | const char* strtab_; 188 | ElfW(Sym)* symtab_; 189 | 190 | size_t nbucket_; 191 | size_t nchain_; 192 | uint32_t* bucket_; 193 | uint32_t* chain_; 194 | 195 | #if defined(__mips__) || !defined(__LP64__) 196 | // This is only used by mips and mips64, but needs to be here for 197 | // all 32-bit architectures to preserve binary compatibility. 198 | ElfW(Addr)** plt_got_; 199 | #endif 200 | 201 | #if defined(USE_RELA) 202 | ElfW(Rela)* plt_rela_; 203 | size_t plt_rela_count_; 204 | 205 | ElfW(Rela)* rela_; 206 | size_t rela_count_; 207 | #else 208 | ElfW(Rel)* plt_rel_; 209 | size_t plt_rel_count_; 210 | 211 | ElfW(Rel)* rel_; 212 | size_t rel_count_; 213 | #endif 214 | 215 | linker_function_t* preinit_array_; 216 | size_t preinit_array_count_; 217 | 218 | linker_function_t* init_array_; 219 | size_t init_array_count_; 220 | linker_function_t* fini_array_; 221 | size_t fini_array_count_; 222 | 223 | linker_function_t init_func_; 224 | linker_function_t fini_func_; 225 | 226 | #if defined(__arm__) 227 | public: 228 | // ARM EABI section used for stack unwinding. 229 | uint32_t* ARM_exidx; 230 | size_t ARM_exidx_count; 231 | private: 232 | #elif defined(__mips__) 233 | uint32_t mips_symtabno_; 234 | uint32_t mips_local_gotno_; 235 | uint32_t mips_gotsym_; 236 | bool mips_relocate_got(const VersionTracker& version_tracker, 237 | const soinfo_list_t& global_group, 238 | const soinfo_list_t& local_group); 239 | 240 | #endif 241 | size_t ref_count_; 242 | public: 243 | link_map link_map_head; 244 | 245 | bool constructors_called; 246 | 247 | // When you read a virtual address from the ELF file, add this 248 | // value to get the corresponding address in the process' address space. 249 | ElfW(Addr) load_bias; 250 | 251 | #if !defined(__LP64__) 252 | bool has_text_relocations; 253 | #endif 254 | bool has_DT_SYMBOLIC; 255 | 256 | public: 257 | soinfo(const char* name, const struct _stat64* file_stat, off64_t file_offset, int rtld_flags); 258 | 259 | void call_constructors(); 260 | void call_destructors(); 261 | void call_pre_init_constructors(); 262 | bool prelink_image(Header &header); 263 | bool link_image(const soinfo_list_t& global_group, const soinfo_list_t& local_group, const android_dlextinfo* extinfo); 264 | 265 | void add_child(soinfo* child); 266 | void remove_all_links(); 267 | 268 | ino_t get_st_ino() const; 269 | dev_t get_st_dev() const; 270 | off64_t get_file_offset() const; 271 | 272 | uint32_t get_rtld_flags() const; 273 | uint32_t get_dt_flags_1() const; 274 | void set_dt_flags_1(uint32_t dt_flags_1); 275 | 276 | soinfo_list_t& get_children(); 277 | const soinfo_list_t& get_children() const; 278 | 279 | soinfo_list_t& get_parents(); 280 | 281 | bool find_symbol_by_name(SymbolName& symbol_name, const version_info* vi, const ElfW(Sym)** symbol) const; 282 | 283 | ElfW(Sym)* find_symbol_by_address(const void* addr); 284 | ElfW(Addr) resolve_symbol_address(const ElfW(Sym)* s) const; 285 | 286 | const char* get_string(ElfW(Word) index) const; 287 | bool can_unload() const; 288 | bool is_gnu_hash() const; 289 | 290 | bool inline has_min_version(uint32_t min_version __unused) const { 291 | #if defined(__work_around_b_19059885__) 292 | return (flags_ & FLAG_NEW_SOINFO) != 0 && version_ >= min_version; 293 | #else 294 | return true; 295 | #endif 296 | } 297 | 298 | bool is_linked() const; 299 | bool is_main_executable() const; 300 | 301 | void set_linked(); 302 | void set_linker_flag(); 303 | void set_main_executable(); 304 | 305 | void increment_ref_count(); 306 | size_t decrement_ref_count(); 307 | 308 | soinfo* get_local_group_root() const; 309 | 310 | const char* get_soname() const; 311 | const char* get_realpath() const; 312 | const ElfW(Versym)* get_versym(size_t n) const; 313 | ElfW(Addr) get_verneed_ptr() const; 314 | size_t get_verneed_cnt() const; 315 | ElfW(Addr) get_verdef_ptr() const; 316 | size_t get_verdef_cnt() const; 317 | 318 | bool find_verdef_version_index(const version_info* vi, ElfW(Versym)* versym) const; 319 | 320 | uint32_t get_target_sdk_version() const; 321 | 322 | private: 323 | bool elf_lookup(SymbolName& symbol_name, const version_info* vi, uint32_t* symbol_index) const; 324 | ElfW(Sym)* elf_addr_lookup(const void* addr); 325 | bool gnu_lookup(SymbolName& symbol_name, const version_info* vi, uint32_t* symbol_index) const; 326 | ElfW(Sym)* gnu_addr_lookup(const void* addr); 327 | 328 | bool lookup_version_info(const VersionTracker& version_tracker, ElfW(Word) sym, const char* sym_name, const version_info** vi); 329 | 330 | void call_array(const char* array_name, linker_function_t* functions, size_t count, bool reverse); 331 | void call_function(const char* function_name, linker_function_t function); 332 | template 333 | bool relocate(const VersionTracker& version_tracker, ElfRelIteratorT&& rel_iterator, const soinfo_list_t& global_group, const soinfo_list_t& local_group); 334 | 335 | private: 336 | // This part of the structure is only available 337 | // when FLAG_NEW_SOINFO is set in this->flags. 338 | uint32_t version_; 339 | 340 | // version >= 0 341 | dev_t st_dev_; 342 | ino_t st_ino_; 343 | 344 | // dependency graph 345 | soinfo_list_t children_; 346 | soinfo_list_t parents_; 347 | 348 | // version >= 1 349 | off64_t file_offset_; 350 | uint32_t rtld_flags_; 351 | uint32_t dt_flags_1_; 352 | size_t strtab_size_; 353 | 354 | // version >= 2 355 | 356 | size_t gnu_nbucket_; 357 | uint32_t* gnu_bucket_; 358 | uint32_t* gnu_chain_; 359 | uint32_t gnu_maskwords_; 360 | uint32_t gnu_shift2_; 361 | ElfW(Addr)* gnu_bloom_filter_; 362 | 363 | soinfo* local_group_root_; 364 | 365 | uint8_t* android_relocs_; 366 | size_t android_relocs_size_; 367 | 368 | const char* soname_; 369 | const char* realpath_; 370 | 371 | const ElfW(Versym)* versym_; 372 | 373 | ElfW(Addr) verdef_ptr_; 374 | size_t verdef_cnt_; 375 | 376 | ElfW(Addr) verneed_ptr_; 377 | size_t verneed_cnt_; 378 | 379 | uint32_t target_sdk_version_; 380 | 381 | friend soinfo* get_libdl_info(); 382 | }; 383 | 384 | bool soinfo_do_lookup(soinfo* si_from, const char* name, const version_info* vi, 385 | soinfo** si_found_in, const soinfo::soinfo_list_t& global_group, 386 | const soinfo::soinfo_list_t& local_group, const ElfW(Sym)** symbol); 387 | 388 | enum RelocationKind { 389 | kRelocAbsolute = 0, 390 | kRelocRelative, 391 | kRelocCopy, 392 | kRelocSymbol, 393 | kRelocMax 394 | }; 395 | 396 | void count_relocation(RelocationKind kind); 397 | 398 | soinfo* get_libdl_info(); 399 | 400 | void do_android_get_LD_LIBRARY_PATH(char*, size_t); 401 | void do_android_update_LD_LIBRARY_PATH(const char* ld_library_path); 402 | soinfo* do_dlopen(const char* name, int flags, const android_dlextinfo* extinfo); 403 | void do_dlclose(soinfo* si); 404 | 405 | int do_dl_iterate_phdr(int(*cb)(dl_phdr_info* info, size_t size, void* data), void* data); 406 | 407 | const ElfW(Sym)* dlsym_linear_lookup(const char* name, soinfo** found, soinfo* caller, void* handle); 408 | soinfo* find_containing_library(const void* addr); 409 | 410 | const ElfW(Sym)* dlsym_handle_lookup(soinfo* si, soinfo** found, const char* name); 411 | 412 | void debuggerd_init(); 413 | extern "C" void notify_gdb_of_libraries(); 414 | 415 | char* linker_get_error_buffer(); 416 | size_t linker_get_error_buffer_size(); 417 | 418 | void set_application_target_sdk_version(uint32_t target); 419 | uint32_t get_application_target_sdk_version(); 420 | 421 | 422 | soinfo* soinfo_alloc(const char* name, struct _stat64* file_stat, off64_t file_offset, uint32_t rtld_flags); 423 | 424 | template 425 | void for_each_dt_needed(const soinfo* si, F action); 426 | #endif 427 | -------------------------------------------------------------------------------- /Extract/Extract/includes/linker_phdr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The Android Open Source Project 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in 12 | * the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | #ifndef LINKER_PHDR_H 29 | #define LINKER_PHDR_H 30 | 31 | /* Declarations related to the ELF program header table and segments. 32 | * 33 | * The design goal is to provide an API that is as close as possible 34 | * to the ELF spec, and does not depend on linker-specific data 35 | * structures (e.g. the exact layout of struct soinfo). 36 | */ 37 | 38 | #include "linker.h" 39 | #include 40 | #include 41 | #include "Header.h" 42 | 43 | /* New code should use sysconf(_SC_PAGE_SIZE) instead. */ 44 | #ifndef WINDOWS_PAGE_SIZE 45 | #define WINDOWS_PAGE_SIZE 65536 46 | #endif 47 | #ifndef WINDOWS_PAGE_SIZE 48 | #define WINDOWS_PAGE_SIZE WINDOWS_PAGE_SIZE 49 | #endif 50 | 51 | /* glibc's PAGE_MASK is the bitwise negation of BSD's! TODO: remove? */ 52 | #define WINDOWS_PAGE_MASK (~(WINDOWS_PAGE_SIZE - 1)) 53 | 54 | 55 | // Returns the address of the page containing address 'x'. 56 | #define WINDOWS_PAGE_START(x) ((x) & WINDOWS_PAGE_MASK) 57 | 58 | // Returns the offset of address 'x' in its page. 59 | #define WINDOWS_PAGE_OFFSET(x) ((x) & ~WINDOWS_PAGE_MASK) 60 | 61 | // Returns the address of the next page after address 'x', unless 'x' is 62 | // itself at the start of a page. 63 | #define WINDOWS_PAGE_END(x) WINDOWS_PAGE_START((x) + (WINDOWS_PAGE_SIZE-1)) 64 | 65 | class ElfReader { 66 | public: 67 | ElfReader(const char* name, HANDLE fd, HANDLE mapping, off64_t file_offset, off64_t file_size); 68 | ~ElfReader(); 69 | 70 | bool Load(const android_dlextinfo* extinfo); 71 | 72 | size_t phdr_count() { return phdr_num_; } 73 | ElfW(Addr) load_start() { return reinterpret_cast(load_start_); } 74 | size_t load_size() { return load_size_; } 75 | ElfW(Addr) load_bias() { return load_bias_; } 76 | const ElfW(Phdr)* loaded_phdr() { return loaded_phdr_; } 77 | 78 | // add by zwp 79 | ElfW(Addr) min_vaddr() { return min_vaddr_; } 80 | const char* name() { return name_; } 81 | void get_section_table(SectionTable &s_table); 82 | ElfW(Phdr)* phdr_table() { return phdr_table_; } 83 | ElfW(Shdr)* shdr_table() { return shdr_table_; } 84 | size_t shdr_count() { return shdr_num_; } 85 | ElfW(Shdr)* section_table_find(ElfW(Addr) file_base, ElfW(Word) sht_type, const char *name); 86 | ElfW(Ehdr)& header() { return header_; } 87 | 88 | private: 89 | bool ReadElfHeader(); 90 | bool VerifyElfHeader(); 91 | bool ReadProgramHeader(); 92 | bool ReadSectionHeader(); 93 | bool ReserveAddressSpace(const android_dlextinfo* extinfo); 94 | bool LoadSegments(); 95 | bool FindPhdr(); 96 | bool CheckPhdr(ElfW(Addr) loaded); 97 | 98 | const char* name_; 99 | HANDLE fd_; // update by zwp 100 | off64_t file_offset_; 101 | off64_t file_size_; 102 | 103 | ElfW(Ehdr) header_; 104 | size_t phdr_num_; 105 | size_t shdr_num_; // zwp 106 | 107 | void* phdr_mmap_; 108 | void* shdr_mmap_; // zwp 109 | 110 | ElfW(Phdr)* phdr_table_; 111 | ElfW(Shdr)* shdr_table_; // zwp 112 | 113 | ElfW(Addr) phdr_size_; 114 | ElfW(Addr) shdr_size_; // zwp 115 | 116 | // First page of reserved address space. 117 | void* load_start_; 118 | // Size in bytes of reserved address space. 119 | size_t load_size_; 120 | // Load bias. 121 | ElfW(Addr) load_bias_; 122 | 123 | // Loaded phdr. 124 | const ElfW(Phdr)* loaded_phdr_; 125 | 126 | // add by zwp 127 | ElfW(Addr) min_vaddr_; 128 | HANDLE mapping_; 129 | HANDLE mapping_reserve_space_; 130 | }; 131 | 132 | size_t phdr_table_get_load_size(const ElfW(Phdr)* phdr_table, size_t phdr_count, ElfW(Addr)* min_vaddr = nullptr, ElfW(Addr)* max_vaddr = nullptr); 133 | 134 | int phdr_table_protect_segments(const ElfW(Phdr)* phdr_table, size_t phdr_count, ElfW(Addr) load_bias); 135 | 136 | int phdr_table_unprotect_segments(const ElfW(Phdr)* phdr_table, size_t phdr_count, ElfW(Addr) load_bias); 137 | 138 | int phdr_table_protect_gnu_relro(const ElfW(Phdr)* phdr_table, size_t phdr_count, ElfW(Addr) load_bias); 139 | 140 | int phdr_table_serialize_gnu_relro(const ElfW(Phdr)* phdr_table, size_t phdr_count, ElfW(Addr) load_bias, int fd); 141 | 142 | int phdr_table_map_gnu_relro(const ElfW(Phdr)* phdr_table, size_t phdr_count, ElfW(Addr) load_bias, int fd); 143 | 144 | #if defined(__arm__) 145 | int phdr_table_get_arm_exidx(const ElfW(Phdr)* phdr_table, size_t phdr_count, ElfW(Addr) load_bias, ElfW(Addr)** arm_exidx, size_t* arm_exidix_count); 146 | #endif 147 | 148 | void phdr_table_get_dynamic_section(const ElfW(Phdr)* phdr_table, size_t phdr_count, ElfW(Addr) load_bias, ElfW(Dyn)** dynamic, ElfW(Word)* dynamic_flags); 149 | 150 | 151 | #endif /* LINKER_PHDR_H */ 152 | -------------------------------------------------------------------------------- /Extract/Extract/includes/linux/auxvec.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #ifndef _UAPI_LINUX_AUXVEC_H 20 | #define _UAPI_LINUX_AUXVEC_H 21 | #include 22 | #define AT_NULL 0 23 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 24 | #define AT_IGNORE 1 25 | #define AT_EXECFD 2 26 | #define AT_PHDR 3 27 | #define AT_PHENT 4 28 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 29 | #define AT_PHNUM 5 30 | #define AT_PAGESZ 6 31 | #define AT_BASE 7 32 | #define AT_FLAGS 8 33 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 34 | #define AT_ENTRY 9 35 | #define AT_NOTELF 10 36 | #define AT_UID 11 37 | #define AT_EUID 12 38 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 39 | #define AT_GID 13 40 | #define AT_EGID 14 41 | #define AT_PLATFORM 15 42 | #define AT_HWCAP 16 43 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 44 | #define AT_CLKTCK 17 45 | #define AT_SECURE 23 46 | #define AT_BASE_PLATFORM 24 47 | #define AT_RANDOM 25 48 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 49 | #define AT_HWCAP2 26 50 | #define AT_EXECFN 31 51 | #endif 52 | -------------------------------------------------------------------------------- /Extract/Extract/includes/linux/compiler.h: -------------------------------------------------------------------------------- 1 | #ifndef _UAPI_LINUX_COMPILER_H 2 | #define _UAPI_LINUX_COMPILER_H 3 | 4 | /* 5 | * This file is not currently in the Linux kernel tree. 6 | * Upstream uapi headers refer to but there is 7 | * no such uapi file. We've sent this upstream, and are optimistically 8 | * adding it to bionic in the meantime. This should be replaced by 9 | * a scrubbed header from external/kernel-headers when possible. 10 | * 11 | * An alternative to this file is to check in a symbolic link to the 12 | * non-uapi . That's fine for building bionic too. 13 | */ 14 | 15 | #define __user 16 | #define __force 17 | 18 | #endif /* _UAPI_LINUX_COMPILER_H */ 19 | -------------------------------------------------------------------------------- /Extract/Extract/includes/linux/elf-em.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #ifndef _LINUX_ELF_EM_H 20 | #define _LINUX_ELF_EM_H 21 | #define EM_NONE 0 22 | #define EM_M32 1 23 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 24 | #define EM_SPARC 2 25 | #define EM_386 3 26 | #define EM_68K 4 27 | #define EM_88K 5 28 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 29 | #define EM_486 6 30 | #define EM_860 7 31 | #define EM_MIPS 8 32 | #define EM_MIPS_RS3_LE 10 33 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 34 | #define EM_MIPS_RS4_BE 10 35 | #define EM_PARISC 15 36 | #define EM_SPARC32PLUS 18 37 | #define EM_PPC 20 38 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 39 | #define EM_PPC64 21 40 | #define EM_SPU 23 41 | #define EM_ARM 40 42 | #define EM_SH 42 43 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 44 | #define EM_SPARCV9 43 45 | #define EM_IA_64 50 46 | #define EM_X86_64 62 47 | #define EM_S390 22 48 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 49 | #define EM_CRIS 76 50 | #define EM_V850 87 51 | #define EM_M32R 88 52 | #define EM_MN10300 89 53 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 54 | #define EM_OPENRISC 92 55 | #define EM_BLACKFIN 106 56 | #define EM_TI_C6000 140 57 | #define EM_AARCH64 183 58 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 59 | #define EM_FRV 0x5441 60 | #define EM_AVR32 0x18ad 61 | #define EM_ALPHA 0x9026 62 | #define EM_CYGNUS_V850 0x9080 63 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 64 | #define EM_CYGNUS_M32R 0x9041 65 | #define EM_S390_OLD 0xA390 66 | #define EM_CYGNUS_MN10300 0xbeef 67 | #endif 68 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 69 | -------------------------------------------------------------------------------- /Extract/Extract/includes/linux/elf.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #ifndef _UAPI_LINUX_ELF_H 20 | #define _UAPI_LINUX_ELF_H 21 | #include 22 | #include 23 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 24 | typedef __u32 Elf32_Addr; 25 | typedef __u16 Elf32_Half; 26 | typedef __u32 Elf32_Off; 27 | typedef __s32 Elf32_Sword; 28 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 29 | typedef __u32 Elf32_Word; 30 | typedef __u64 Elf64_Addr; 31 | typedef __u16 Elf64_Half; 32 | typedef __s16 Elf64_SHalf; 33 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 34 | typedef __u64 Elf64_Off; 35 | typedef __s32 Elf64_Sword; 36 | typedef __u32 Elf64_Word; 37 | typedef __u64 Elf64_Xword; 38 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 39 | typedef __s64 Elf64_Sxword; 40 | #define PT_NULL 0 41 | #define PT_LOAD 1 42 | #define PT_DYNAMIC 2 43 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 44 | #define PT_INTERP 3 45 | #define PT_NOTE 4 46 | #define PT_SHLIB 5 47 | #define PT_PHDR 6 48 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 49 | #define PT_TLS 7 50 | #define PT_LOOS 0x60000000 51 | #define PT_HIOS 0x6fffffff 52 | #define PT_LOPROC 0x70000000 53 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 54 | #define PT_HIPROC 0x7fffffff 55 | #define PT_GNU_EH_FRAME 0x6474e550 56 | #define PT_GNU_STACK (PT_LOOS + 0x474e551) 57 | #define PN_XNUM 0xffff 58 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 59 | #define ET_NONE 0 60 | #define ET_REL 1 61 | #define ET_EXEC 2 62 | #define ET_DYN 3 63 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 64 | #define ET_CORE 4 65 | #define ET_LOPROC 0xff00 66 | #define ET_HIPROC 0xffff 67 | #define DT_NULL 0 68 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 69 | #define DT_NEEDED 1 70 | #define DT_PLTRELSZ 2 71 | #define DT_PLTGOT 3 72 | #define DT_HASH 4 73 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 74 | #define DT_STRTAB 5 75 | #define DT_SYMTAB 6 76 | #define DT_RELA 7 77 | #define DT_RELASZ 8 78 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 79 | #define DT_RELAENT 9 80 | #define DT_STRSZ 10 81 | #define DT_SYMENT 11 82 | #define DT_INIT 12 83 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 84 | #define DT_FINI 13 85 | #define DT_SONAME 14 86 | #define DT_RPATH 15 87 | #define DT_SYMBOLIC 16 88 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 89 | #define DT_REL 17 90 | #define DT_RELSZ 18 91 | #define DT_RELENT 19 92 | #define DT_PLTREL 20 93 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 94 | #define DT_DEBUG 21 95 | #define DT_TEXTREL 22 96 | #define DT_JMPREL 23 97 | #define DT_ENCODING 32 98 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 99 | #define OLD_DT_LOOS 0x60000000 100 | #define DT_LOOS 0x6000000d 101 | #define DT_HIOS 0x6ffff000 102 | #define DT_VALRNGLO 0x6ffffd00 103 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 104 | #define DT_VALRNGHI 0x6ffffdff 105 | #define DT_ADDRRNGLO 0x6ffffe00 106 | #define DT_ADDRRNGHI 0x6ffffeff 107 | #define DT_VERSYM 0x6ffffff0 108 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 109 | #define DT_RELACOUNT 0x6ffffff9 110 | #define DT_RELCOUNT 0x6ffffffa 111 | #define DT_FLAGS_1 0x6ffffffb 112 | #define DT_VERDEF 0x6ffffffc 113 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 114 | #define DT_VERDEFNUM 0x6ffffffd 115 | #define DT_VERNEED 0x6ffffffe 116 | #define DT_VERNEEDNUM 0x6fffffff 117 | #define OLD_DT_HIOS 0x6fffffff 118 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 119 | #define DT_LOPROC 0x70000000 120 | #define DT_HIPROC 0x7fffffff 121 | #define STB_LOCAL 0 122 | #define STB_GLOBAL 1 123 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 124 | #define STB_WEAK 2 125 | #define STT_NOTYPE 0 126 | #define STT_OBJECT 1 127 | #define STT_FUNC 2 128 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 129 | #define STT_SECTION 3 130 | #define STT_FILE 4 131 | #define STT_COMMON 5 132 | #define STT_TLS 6 133 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 134 | #define ELF_ST_BIND(x) ((x) >> 4) 135 | #define ELF_ST_TYPE(x) (((unsigned int) x) & 0xf) 136 | #define ELF32_ST_BIND(x) ELF_ST_BIND(x) 137 | #define ELF32_ST_TYPE(x) ELF_ST_TYPE(x) 138 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 139 | #define ELF64_ST_BIND(x) ELF_ST_BIND(x) 140 | #define ELF64_ST_TYPE(x) ELF_ST_TYPE(x) 141 | typedef struct dynamic { 142 | Elf32_Sword d_tag; 143 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 144 | union { 145 | Elf32_Sword d_val; 146 | Elf32_Addr d_ptr; 147 | } d_un; 148 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 149 | } Elf32_Dyn; 150 | typedef struct { 151 | Elf64_Sxword d_tag; 152 | union { 153 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 154 | Elf64_Xword d_val; 155 | Elf64_Addr d_ptr; 156 | } d_un; 157 | } Elf64_Dyn; 158 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 159 | #define ELF32_R_SYM(x) ((x) >> 8) 160 | #define ELF32_R_TYPE(x) ((x) & 0xff) 161 | #define ELF64_R_SYM(i) ((i) >> 32) 162 | #define ELF64_R_TYPE(i) ((i) & 0xffffffff) 163 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 164 | typedef struct elf32_rel { 165 | Elf32_Addr r_offset; 166 | Elf32_Word r_info; 167 | } Elf32_Rel; 168 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 169 | typedef struct elf64_rel { 170 | Elf64_Addr r_offset; 171 | Elf64_Xword r_info; 172 | } Elf64_Rel; 173 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 174 | typedef struct elf32_rela { 175 | Elf32_Addr r_offset; 176 | Elf32_Word r_info; 177 | Elf32_Sword r_addend; 178 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 179 | } Elf32_Rela; 180 | typedef struct elf64_rela { 181 | Elf64_Addr r_offset; 182 | Elf64_Xword r_info; 183 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 184 | Elf64_Sxword r_addend; 185 | } Elf64_Rela; 186 | typedef struct elf32_sym { 187 | Elf32_Word st_name; 188 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 189 | Elf32_Addr st_value; 190 | Elf32_Word st_size; 191 | unsigned char st_info; 192 | unsigned char st_other; 193 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 194 | Elf32_Half st_shndx; 195 | } Elf32_Sym; 196 | typedef struct elf64_sym { 197 | Elf64_Word st_name; 198 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 199 | unsigned char st_info; 200 | unsigned char st_other; 201 | Elf64_Half st_shndx; 202 | Elf64_Addr st_value; 203 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 204 | Elf64_Xword st_size; 205 | } Elf64_Sym; 206 | #define EI_NIDENT 16 207 | typedef struct elf32_hdr { 208 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 209 | unsigned char e_ident[EI_NIDENT]; 210 | Elf32_Half e_type; 211 | Elf32_Half e_machine; 212 | Elf32_Word e_version; 213 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 214 | Elf32_Addr e_entry; 215 | Elf32_Off e_phoff; 216 | Elf32_Off e_shoff; 217 | Elf32_Word e_flags; 218 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 219 | Elf32_Half e_ehsize; 220 | Elf32_Half e_phentsize; 221 | Elf32_Half e_phnum; 222 | Elf32_Half e_shentsize; 223 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 224 | Elf32_Half e_shnum; 225 | Elf32_Half e_shstrndx; 226 | } Elf32_Ehdr; 227 | typedef struct elf64_hdr { 228 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 229 | unsigned char e_ident[EI_NIDENT]; 230 | Elf64_Half e_type; 231 | Elf64_Half e_machine; 232 | Elf64_Word e_version; 233 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 234 | Elf64_Addr e_entry; 235 | Elf64_Off e_phoff; 236 | Elf64_Off e_shoff; 237 | Elf64_Word e_flags; 238 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 239 | Elf64_Half e_ehsize; 240 | Elf64_Half e_phentsize; 241 | Elf64_Half e_phnum; 242 | Elf64_Half e_shentsize; 243 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 244 | Elf64_Half e_shnum; 245 | Elf64_Half e_shstrndx; 246 | } Elf64_Ehdr; 247 | #define PF_R 0x4 248 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 249 | #define PF_W 0x2 250 | #define PF_X 0x1 251 | typedef struct elf32_phdr { 252 | Elf32_Word p_type; 253 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 254 | Elf32_Off p_offset; 255 | Elf32_Addr p_vaddr; 256 | Elf32_Addr p_paddr; 257 | Elf32_Word p_filesz; 258 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 259 | Elf32_Word p_memsz; 260 | Elf32_Word p_flags; 261 | Elf32_Word p_align; 262 | } Elf32_Phdr; 263 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 264 | typedef struct elf64_phdr { 265 | Elf64_Word p_type; 266 | Elf64_Word p_flags; 267 | Elf64_Off p_offset; 268 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 269 | Elf64_Addr p_vaddr; 270 | Elf64_Addr p_paddr; 271 | Elf64_Xword p_filesz; 272 | Elf64_Xword p_memsz; 273 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 274 | Elf64_Xword p_align; 275 | } Elf64_Phdr; 276 | #define SHT_NULL 0 277 | #define SHT_PROGBITS 1 278 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 279 | #define SHT_SYMTAB 2 280 | #define SHT_STRTAB 3 281 | #define SHT_RELA 4 282 | #define SHT_HASH 5 283 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 284 | #define SHT_DYNAMIC 6 285 | #define SHT_NOTE 7 286 | #define SHT_NOBITS 8 287 | #define SHT_REL 9 288 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 289 | #define SHT_SHLIB 10 290 | #define SHT_DYNSYM 11 291 | #define SHT_NUM 12 292 | #define SHT_LOPROC 0x70000000 293 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 294 | #define SHT_HIPROC 0x7fffffff 295 | #define SHT_LOUSER 0x80000000 296 | #define SHT_HIUSER 0xffffffff 297 | #define SHF_WRITE 0x1 298 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 299 | #define SHF_ALLOC 0x2 300 | #define SHF_EXECINSTR 0x4 301 | #define SHF_MASKPROC 0xf0000000 302 | #define SHN_UNDEF 0 303 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 304 | #define SHN_LORESERVE 0xff00 305 | #define SHN_LOPROC 0xff00 306 | #define SHN_HIPROC 0xff1f 307 | #define SHN_ABS 0xfff1 308 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 309 | #define SHN_COMMON 0xfff2 310 | #define SHN_HIRESERVE 0xffff 311 | typedef struct elf32_shdr { 312 | Elf32_Word sh_name; 313 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 314 | Elf32_Word sh_type; 315 | Elf32_Word sh_flags; 316 | Elf32_Addr sh_addr; 317 | Elf32_Off sh_offset; 318 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 319 | Elf32_Word sh_size; 320 | Elf32_Word sh_link; 321 | Elf32_Word sh_info; 322 | Elf32_Word sh_addralign; 323 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 324 | Elf32_Word sh_entsize; 325 | } Elf32_Shdr; 326 | typedef struct elf64_shdr { 327 | Elf64_Word sh_name; 328 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 329 | Elf64_Word sh_type; 330 | Elf64_Xword sh_flags; 331 | Elf64_Addr sh_addr; 332 | Elf64_Off sh_offset; 333 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 334 | Elf64_Xword sh_size; 335 | Elf64_Word sh_link; 336 | Elf64_Word sh_info; 337 | Elf64_Xword sh_addralign; 338 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 339 | Elf64_Xword sh_entsize; 340 | } Elf64_Shdr; 341 | #define EI_MAG0 0 342 | #define EI_MAG1 1 343 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 344 | #define EI_MAG2 2 345 | #define EI_MAG3 3 346 | #define EI_CLASS 4 347 | #define EI_DATA 5 348 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 349 | #define EI_VERSION 6 350 | #define EI_OSABI 7 351 | #define EI_PAD 8 352 | #define ELFMAG0 0x7f 353 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 354 | #define ELFMAG1 'E' 355 | #define ELFMAG2 'L' 356 | #define ELFMAG3 'F' 357 | #define ELFMAG "\177ELF" 358 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 359 | #define SELFMAG 4 360 | #define ELFCLASSNONE 0 361 | #define ELFCLASS32 1 362 | #define ELFCLASS64 2 363 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 364 | #define ELFCLASSNUM 3 365 | #define ELFDATANONE 0 366 | #define ELFDATA2LSB 1 367 | #define ELFDATA2MSB 2 368 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 369 | #define EV_NONE 0 370 | #define EV_CURRENT 1 371 | #define EV_NUM 2 372 | #define ELFOSABI_NONE 0 373 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 374 | #define ELFOSABI_LINUX 3 375 | #ifndef ELF_OSABI 376 | #define ELF_OSABI ELFOSABI_NONE 377 | #endif 378 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 379 | #define NT_PRSTATUS 1 380 | #define NT_PRFPREG 2 381 | #define NT_PRPSINFO 3 382 | #define NT_TASKSTRUCT 4 383 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 384 | #define NT_AUXV 6 385 | #define NT_SIGINFO 0x53494749 386 | #define NT_FILE 0x46494c45 387 | #define NT_PRXFPREG 0x46e62b7f 388 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 389 | #define NT_PPC_VMX 0x100 390 | #define NT_PPC_SPE 0x101 391 | #define NT_PPC_VSX 0x102 392 | #define NT_386_TLS 0x200 393 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 394 | #define NT_386_IOPERM 0x201 395 | #define NT_X86_XSTATE 0x202 396 | #define NT_S390_HIGH_GPRS 0x300 397 | #define NT_S390_TIMER 0x301 398 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 399 | #define NT_S390_TODCMP 0x302 400 | #define NT_S390_TODPREG 0x303 401 | #define NT_S390_CTRS 0x304 402 | #define NT_S390_PREFIX 0x305 403 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 404 | #define NT_S390_LAST_BREAK 0x306 405 | #define NT_S390_SYSTEM_CALL 0x307 406 | #define NT_S390_TDB 0x308 407 | #define NT_S390_VXRS_LOW 0x309 408 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 409 | #define NT_S390_VXRS_HIGH 0x30a 410 | #define NT_ARM_VFP 0x400 411 | #define NT_ARM_TLS 0x401 412 | #define NT_ARM_HW_BREAK 0x402 413 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 414 | #define NT_ARM_HW_WATCH 0x403 415 | #define NT_METAG_CBUF 0x500 416 | #define NT_METAG_RPIPE 0x501 417 | #define NT_METAG_TLS 0x502 418 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 419 | typedef struct elf32_note { 420 | Elf32_Word n_namesz; 421 | Elf32_Word n_descsz; 422 | Elf32_Word n_type; 423 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 424 | } Elf32_Nhdr; 425 | typedef struct elf64_note { 426 | Elf64_Word n_namesz; 427 | Elf64_Word n_descsz; 428 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 429 | Elf64_Word n_type; 430 | } Elf64_Nhdr; 431 | #endif 432 | -------------------------------------------------------------------------------- /Extract/Extract/includes/linux/limits.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #ifndef _LINUX_LIMITS_H 20 | #define _LINUX_LIMITS_H 21 | #define NR_OPEN 1024 22 | #define NGROUPS_MAX 65536 23 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 24 | #define ARG_MAX 131072 25 | #define LINK_MAX 127 26 | #define MAX_CANON 255 27 | #define MAX_INPUT 255 28 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 29 | #define NAME_MAX 255 30 | #define PATH_MAX 4096 31 | #define PIPE_BUF 4096 32 | #define XATTR_NAME_MAX 255 33 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 34 | #define XATTR_SIZE_MAX 65536 35 | #define XATTR_LIST_MAX 65536 36 | #define RTSIG_MAX 32 37 | #endif 38 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 39 | -------------------------------------------------------------------------------- /Extract/Extract/includes/linux/mman.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #ifndef _UAPI_LINUX_MMAN_H 20 | #define _UAPI_LINUX_MMAN_H 21 | #include 22 | #define MREMAP_MAYMOVE 1 23 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 24 | #define MREMAP_FIXED 2 25 | #define OVERCOMMIT_GUESS 0 26 | #define OVERCOMMIT_ALWAYS 1 27 | #define OVERCOMMIT_NEVER 2 28 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 29 | #endif 30 | -------------------------------------------------------------------------------- /Extract/Extract/includes/linux/param.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #ifndef _LINUX_PARAM_H 20 | #define _LINUX_PARAM_H 21 | #include 22 | #endif 23 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 24 | -------------------------------------------------------------------------------- /Extract/Extract/includes/linux/posix_types.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #ifndef _LINUX_POSIX_TYPES_H 20 | #define _LINUX_POSIX_TYPES_H 21 | #include 22 | #undef __FD_SETSIZE 23 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 24 | #define __FD_SETSIZE 1024 25 | typedef struct { 26 | unsigned long fds_bits[__FD_SETSIZE / (8 * sizeof(long))]; 27 | } __kernel_fd_set; 28 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 29 | typedef void(* __kernel_sighandler_t) (int); 30 | typedef int __kernel_key_t; 31 | typedef int __kernel_mqd_t; 32 | #include 33 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 34 | #endif 35 | -------------------------------------------------------------------------------- /Extract/Extract/includes/linux/stddef.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #include 20 | -------------------------------------------------------------------------------- /Extract/Extract/includes/linux/types.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #ifndef _UAPI_LINUX_TYPES_H 20 | #define _UAPI_LINUX_TYPES_H 21 | #include 22 | #ifndef __ASSEMBLY__ 23 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 24 | #include 25 | #define __bitwise__ 26 | #define __bitwise 27 | typedef __u16 __bitwise __le16; 28 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 29 | typedef __u16 __bitwise __be16; 30 | typedef __u32 __bitwise __le32; 31 | typedef __u32 __bitwise __be32; 32 | typedef __u64 __bitwise __le64; 33 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 34 | typedef __u64 __bitwise __be64; 35 | typedef __u16 __bitwise __sum16; 36 | typedef __u32 __bitwise __wsum; 37 | #define __aligned_u64 __u64 __attribute__((aligned(8))) 38 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 39 | #define __aligned_be64 __be64 __attribute__((aligned(8))) 40 | #define __aligned_le64 __le64 __attribute__((aligned(8))) 41 | #endif 42 | #endif 43 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 44 | -------------------------------------------------------------------------------- /Extract/Extract/includes/machine/elf_machdep.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: elf_machdep.h,v 1.10 2012/08/05 04:12:46 matt Exp $ */ 2 | 3 | #ifndef _ARM_ELF_MACHDEP_H_ 4 | #define _ARM_ELF_MACHDEP_H_ 5 | 6 | #if defined(__ARMEB__) 7 | #define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB 8 | #else 9 | #define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB 10 | #endif 11 | 12 | #define ELF64_MACHDEP_ENDIANNESS XXX /* break compilation */ 13 | #define ELF64_MACHDEP_ID_CASES \ 14 | /* no 64-bit ELF machine types supported */ 15 | 16 | /* Processor specific flags for the ELF header e_flags field. */ 17 | #define EF_ARM_RELEXEC 0x00000001 18 | #define EF_ARM_HASENTRY 0x00000002 19 | #define EF_ARM_INTERWORK 0x00000004 /* GNU binutils 000413 */ 20 | #define EF_ARM_SYMSARESORTED 0x00000004 /* ARM ELF A08 */ 21 | #define EF_ARM_APCS_26 0x00000008 /* GNU binutils 000413 */ 22 | #define EF_ARM_DYNSYMSUSESEGIDX 0x00000008 /* ARM ELF B01 */ 23 | #define EF_ARM_APCS_FLOAT 0x00000010 /* GNU binutils 000413 */ 24 | #define EF_ARM_MAPSYMSFIRST 0x00000010 /* ARM ELF B01 */ 25 | #define EF_ARM_PIC 0x00000020 26 | #define EF_ARM_ALIGN8 0x00000040 /* 8-bit structure alignment. */ 27 | #define EF_ARM_NEW_ABI 0x00000080 28 | #define EF_ARM_OLD_ABI 0x00000100 29 | #define EF_ARM_SOFT_FLOAT 0x00000200 30 | #define EF_ARM_EABIMASK 0xff000000 31 | #define EF_ARM_EABI_VER1 0x01000000 32 | #define EF_ARM_EABI_VER2 0x02000000 33 | #define EF_ARM_EABI_VER3 0x03000000 34 | #define EF_ARM_EABI_VER4 0x04000000 35 | #define EF_ARM_EABI_VER5 0x05000000 36 | 37 | #define ELF32_MACHDEP_ID_CASES \ 38 | case EM_ARM: \ 39 | break; 40 | 41 | #define ELF32_MACHDEP_ID EM_ARM 42 | 43 | #define ARCH_ELFSIZE 32 /* MD native binary size */ 44 | 45 | /* Processor specific relocation types */ 46 | 47 | #define R_ARM_NONE 0 48 | #define R_ARM_PC24 1 49 | #define R_ARM_ABS32 2 50 | #define R_ARM_REL32 3 51 | #define R_ARM_PC13 4 52 | #define R_ARM_ABS16 5 53 | #define R_ARM_ABS12 6 54 | #define R_ARM_THM_ABS5 7 55 | #define R_ARM_ABS8 8 56 | #define R_ARM_SBREL32 9 57 | #define R_ARM_THM_PC22 10 58 | #define R_ARM_THM_PC8 11 59 | #define R_ARM_AMP_VCALL9 12 60 | #define R_ARM_SWI24 13 61 | #define R_ARM_THM_SWI8 14 62 | #define R_ARM_XPC25 15 63 | #define R_ARM_THM_XPC22 16 64 | 65 | /* TLS relocations */ 66 | #define R_ARM_TLS_DTPMOD32 17 /* ID of module containing symbol */ 67 | #define R_ARM_TLS_DTPOFF32 18 /* Offset in TLS block */ 68 | #define R_ARM_TLS_TPOFF32 19 /* Offset in static TLS block */ 69 | 70 | /* 20-31 are reserved for ARM Linux. */ 71 | #define R_ARM_COPY 20 72 | #define R_ARM_GLOB_DAT 21 73 | #define R_ARM_JUMP_SLOT 22 74 | #define R_ARM_RELATIVE 23 75 | #define R_ARM_GOTOFF 24 76 | #define R_ARM_GOTPC 25 77 | #define R_ARM_GOT32 26 78 | #define R_ARM_PLT32 27 79 | 80 | #define R_ARM_ALU_PCREL_7_0 32 81 | #define R_ARM_ALU_PCREL_15_8 33 82 | #define R_ARM_ALU_PCREL_23_15 34 83 | #define R_ARM_ALU_SBREL_11_0 35 84 | #define R_ARM_ALU_SBREL_19_12 36 85 | #define R_ARM_ALU_SBREL_27_20 37 86 | 87 | /* 96-111 are reserved to G++. */ 88 | #define R_ARM_GNU_VTENTRY 100 89 | #define R_ARM_GNU_VTINHERIT 101 90 | #define R_ARM_THM_PC11 102 91 | #define R_ARM_THM_PC9 103 92 | 93 | /* More TLS relocations */ 94 | #define R_ARM_TLS_GD32 104 /* PC-rel 32 bit for global dynamic */ 95 | #define R_ARM_TLS_LDM32 105 /* PC-rel 32 bit for local dynamic */ 96 | #define R_ARM_TLS_LDO32 106 /* 32 bit offset relative to TLS */ 97 | #define R_ARM_TLS_IE32 107 /* PC-rel 32 bit for GOT entry of */ 98 | #define R_ARM_TLS_LE32 108 99 | #define R_ARM_TLS_LDO12 109 100 | #define R_ARM_TLS_LE12 110 101 | #define R_ARM_TLS_IE12GP 111 102 | 103 | /* 112-127 are reserved for private experiments. */ 104 | 105 | #define R_ARM_IRELATIVE 160 106 | 107 | #define R_ARM_RXPC25 249 108 | #define R_ARM_RSBREL32 250 109 | #define R_ARM_THM_RPC22 251 110 | #define R_ARM_RREL32 252 111 | #define R_ARM_RABS32 253 112 | #define R_ARM_RPC24 254 113 | #define R_ARM_RBASE 255 114 | 115 | #define R_TYPE(name) __CONCAT(R_ARM_,name) 116 | 117 | /* Processor specific program header flags */ 118 | #define PF_ARM_SB 0x10000000 119 | #define PF_ARM_PI 0x20000000 120 | #define PF_ARM_ENTRY 0x80000000 121 | 122 | /* Processor specific section header flags */ 123 | #define SHF_ENTRYSECT 0x10000000 124 | #define SHF_COMDEF 0x80000000 125 | 126 | /* Processor specific symbol types */ 127 | #define STT_ARM_TFUNC STT_LOPROC 128 | 129 | #ifdef _KERNEL 130 | #ifdef ELFSIZE 131 | #define ELF_MD_PROBE_FUNC ELFNAME2(arm_netbsd,probe) 132 | #endif 133 | 134 | struct exec_package; 135 | 136 | int arm_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *, char *, 137 | vaddr_t *); 138 | #endif 139 | 140 | #endif /* _ARM_ELF_MACHDEP_H_ */ 141 | -------------------------------------------------------------------------------- /Extract/Extract/includes/machine/posix_limits.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in 12 | * the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef _POSIX_LIMITS_H_ 30 | #define _POSIX_LIMITS_H_ 31 | 32 | 33 | /* Any constant values here other than -1 or 200809L are explicitly specified by POSIX.1-2008. */ 34 | /* Keep it sorted. */ 35 | #define _POSIX_ADVISORY_INFO 200809L 36 | #define _POSIX_AIO_LISTIO_MAX 2 37 | #define _POSIX_AIO_MAX 1 38 | #define _POSIX_ARG_MAX 4096 39 | #define _POSIX_ASYNCHRONOUS_IO -1 /* not implemented */ 40 | #define _POSIX_BARRIERS -1 /* not implemented */ 41 | #define _POSIX_CHILD_MAX 25 42 | #define _POSIX_CHOWN_RESTRICTED 1 /* yes, chown requires appropriate privileges */ 43 | #define _POSIX_CLOCK_SELECTION 200809L 44 | #define _POSIX_CPUTIME 0 /* Use sysconf to detect support at runtime. */ 45 | #define _POSIX_DELAYTIMER_MAX 32 46 | #define _POSIX_FSYNC 200809L /* fdatasync() supported */ 47 | #define _POSIX_HOST_NAME_MAX 255 48 | #define _POSIX_IPV6 200809L 49 | #define _POSIX_JOB_CONTROL 1 /* job control is a Linux feature */ 50 | #define _POSIX_LINK_MAX 8 51 | #define _POSIX_LOGIN_NAME_MAX 9 /* includes trailing NUL */ 52 | #define _POSIX_MAPPED_FILES 200809L /* mmap-ed files supported */ 53 | #define _POSIX_MAX_CANON 255 54 | #define _POSIX_MAX_INPUT 255 55 | #define _POSIX_MEMLOCK 200809L 56 | #define _POSIX_MEMLOCK_RANGE 200809L 57 | #define _POSIX_MEMORY_PROTECTION 200809L 58 | #define _POSIX_MESSAGE_PASSING -1 /* not implemented */ 59 | #define _POSIX_MONOTONIC_CLOCK 0 /* the monotonic clock may be available; ask sysconf */ 60 | #define _POSIX_MQ_OPEN_MAX 8 61 | #define _POSIX_MQ_PRIO_MAX 32 62 | #define _POSIX_NAME_MAX 14 63 | #define _POSIX_NGROUPS_MAX 8 64 | #define _POSIX_NO_TRUNC 1 /* very long pathnames generate an error */ 65 | #define _POSIX_OPEN_MAX 20 66 | #define _POSIX_PATH_MAX 256 67 | #define _POSIX_PIPE_BUF 512 68 | #define _POSIX_PRIORITY_SCHEDULING 200809L /* priority scheduling is a Linux feature */ 69 | #define _POSIX_PRIORITIZED_IO -1 /* not implemented */ 70 | #define _POSIX_RAW_SOCKETS 200809L 71 | #define _POSIX_READER_WRITER_LOCKS 200809L 72 | #define _POSIX_REALTIME_SIGNALS 200809L 73 | #define _POSIX_REGEXP 1 74 | #define _POSIX_RE_DUP_MAX 255 75 | #define _POSIX_SAVED_IDS 1 /* saved user ids is a Linux feature */ 76 | #define _POSIX_SEMAPHORES 200809L 77 | #define _POSIX_SEM_NSEMS_MAX 256 78 | #define _POSIX_SEM_VALUE_MAX 32767 79 | #define _POSIX_SHARED_MEMORY_OBJECTS -1 /* shm_open()/shm_unlink() not implemented */ 80 | #define _POSIX_SHELL 1 /* system() supported */ 81 | #define _POSIX_SIGQUEUE_MAX 32 82 | #define _POSIX_SPAWN -1 /* not implemented */ 83 | #define _POSIX_SPIN_LOCKS -1 /* not implemented */ 84 | #define _POSIX_SPORADIC_SERVER -1 /* not implemented */ 85 | #define _POSIX_SSIZE_MAX 32767 86 | #define _POSIX_STREAM_MAX 8 87 | #define _POSIX_SYMLINK_MAX 255 88 | #define _POSIX_SYMLOOP_MAX 8 89 | #define _POSIX_SYNCHRONIZED_IO 200809L /* synchronized i/o supported */ 90 | #define _POSIX_THREADS 200809L /* we support threads */ 91 | #define _POSIX_THREAD_ATTR_STACKADDR 200809L 92 | #define _POSIX_THREAD_ATTR_STACKSIZE 200809L 93 | #define _POSIX_THREAD_CPUTIME 0 /* Use sysconf to detect support at runtime. */ 94 | #define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 95 | #define _POSIX_THREAD_KEYS_MAX 128 96 | #define _POSIX_THREAD_PRIORITY_SCHEDULING 200809L 97 | #define _POSIX_THREAD_PRIO_INHERIT 200809L /* linux feature */ 98 | #define _POSIX_THREAD_PRIO_PROTECT 200809L /* linux feature */ 99 | #define _POSIX_THREAD_PROCESS_SHARED -1 /* not implemented */ 100 | #define _POSIX_THREAD_ROBUST_PRIO_INHERIT -1 /* not implemented */ 101 | #define _POSIX_THREAD_ROBUST_PRIO_PROTECT -1 /* not implemented */ 102 | #define _POSIX_THREAD_SAFE_FUNCTIONS 200809L 103 | #define _POSIX_THREAD_SPORADIC_SERVER -1 /* not implemented */ 104 | #define _POSIX_THREAD_THREADS_MAX 64 105 | #define _POSIX_TIMEOUTS 200809L 106 | #define _POSIX_TIMERS 200809L /* Posix timers are supported */ 107 | #define _POSIX_TIMER_MAX 32 108 | #define _POSIX_TRACE -1 /* not implemented */ 109 | #define _POSIX_TRACE_EVENT_FILTER -1 /* not implemented */ 110 | #define _POSIX_TRACE_INHERIT -1 /* not implemented */ 111 | #define _POSIX_TRACE_LOG -1 /* not implemented */ 112 | #define _POSIX_TRACE_NAME_MAX 8 113 | #define _POSIX_TRACE_SYS_MAX 8 114 | #define _POSIX_TRACE_USER_EVENT_MAX 32 115 | #define _POSIX_TTY_NAME_MAX 9 /* includes trailing NUL */ 116 | #define _POSIX_TYPED_MEMORY_OBJECTS -1 /* not implemented */ 117 | #define _POSIX_TZNAME_MAX 6 118 | #define _POSIX_VDISABLE '\0' 119 | 120 | #if defined(__LP64__) 121 | #define _POSIX_V7_ILP32_OFF32 -1 122 | #define _POSIX_V7_ILP32_OFFBIG -1 123 | #define _POSIX_V7_LP64_OFF64 1 124 | #define _POSIX_V7_LPBIG_OFFBIG 1 125 | #else 126 | #define _POSIX_V7_ILP32_OFF32 1 127 | #define _POSIX_V7_ILP32_OFFBIG -1 128 | #define _POSIX_V7_LP64_OFF64 -1 129 | #define _POSIX_V7_LPBIG_OFFBIG -1 130 | #endif 131 | 132 | #define _POSIX2_BC_BASE_MAX 99 133 | #define _POSIX2_BC_DIM_MAX 2048 134 | #define _POSIX2_BC_SCALE_MAX 99 135 | #define _POSIX2_BC_STRING_MAX 1000 136 | #define _POSIX2_CHARCLASS_NAME_MAX 14 137 | #define _POSIX2_CHAR_TERM -1 /* not implemented */ 138 | #define _POSIX2_COLL_WEIGHTS_MAX 2 139 | #define _POSIX2_C_BIND _POSIX_VERSION 140 | #define _POSIX2_C_DEV -1 /* c dev utilities not implemented */ 141 | #define _POSIX2_EXPR_NEST_MAX 32 142 | #define _POSIX2_LINE_MAX 2048 143 | #define _POSIX2_LOCALEDEF -1 /* localedef utilitiy not implemented */ 144 | #define _POSIX2_RE_DUP_MAX _POSIX_RE_DUP_MAX 145 | #define _POSIX2_SW_DEV -1 /* software dev utilities not implemented */ 146 | #define _POSIX2_UPE -1 /* user portability utilities not implemented */ 147 | 148 | #define _XOPEN_ENH_I18N -1 /* we don't support internationalization in the C library */ 149 | #define _XOPEN_CRYPT -1 /* don't support X/Open Encryption */ 150 | #define _XOPEN_IOV_MAX 16 151 | #define _XOPEN_LEGACY -1 /* not support all */ 152 | #define _XOPEN_REALTIME -1 /* we don't support all these functions */ 153 | #define _XOPEN_REALTIME_THREADS -1 /* same here */ 154 | #define _XOPEN_SHM -1 155 | #define _XOPEN_UNIX 1 156 | 157 | #endif /* _POSIX_LIMITS_H_ */ 158 | -------------------------------------------------------------------------------- /Extract/Extract/includes/machine/wchar_limits.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in 12 | * the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef _MACHINE_WCHAR_LIMITS_H_ 30 | #define _MACHINE_WCHAR_LIMITS_H_ 31 | 32 | /* Both GCC and clang define __WCHAR_MAX__. */ 33 | #define WCHAR_MAX __WCHAR_MAX__ 34 | 35 | /* As of 3.4, clang still doesn't define __WCHAR_MIN__. */ 36 | #if defined(__WCHAR_UNSIGNED__) 37 | # define WCHAR_MIN L'\0' 38 | #else 39 | # define WCHAR_MIN (-(WCHAR_MAX) - 1) 40 | #endif 41 | 42 | #endif /* _MACHINE_WCHAR_LIMITS_H_ */ 43 | -------------------------------------------------------------------------------- /Extract/Extract/includes/private/bionic_macros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _BIONIC_MACROS_H_ 18 | #define _BIONIC_MACROS_H_ 19 | 20 | // Frameworks OpenGL code currently leaks this header and allows 21 | // collisions with other declarations, e.g., from libnativehelper. 22 | // TODO: Remove once cleaned up. b/18334516 23 | #if !defined(DISALLOW_COPY_AND_ASSIGN) 24 | // DISALLOW_COPY_AND_ASSIGN disallows the copy and operator= functions. 25 | // It goes in the private: declarations in a class. 26 | #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ 27 | TypeName(const TypeName&) = delete; \ 28 | void operator=(const TypeName&) = delete 29 | #endif // !defined(DISALLOW_COPY_AND_ASSIGN) 30 | 31 | // A macro to disallow all the implicit constructors, namely the 32 | // default constructor, copy constructor and operator= functions. 33 | // 34 | // This should be used in the private: declarations for a class 35 | // that wants to prevent anyone from instantiating it. This is 36 | // especially useful for classes containing only static methods. 37 | #define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ 38 | TypeName() = delete; \ 39 | DISALLOW_COPY_AND_ASSIGN(TypeName) 40 | 41 | #define BIONIC_ALIGN(value, alignment) \ 42 | (((value) + (alignment) - 1) & ~((alignment) - 1)) 43 | 44 | #define BIONIC_ROUND_UP_POWER_OF_2(value) \ 45 | (sizeof(value) == 8) \ 46 | ? (1UL << (64 - __builtin_clzl(static_cast(value)))) \ 47 | : (1UL << (32 - __builtin_clz(static_cast(value)))) 48 | 49 | #endif // _BIONIC_MACROS_H_ 50 | -------------------------------------------------------------------------------- /Extract/Extract/includes/sys/limits.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: limits.h,v 1.6 2005/12/13 00:35:23 millert Exp $ */ 2 | /* 3 | * Copyright (c) 2002 Marc Espie. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 15 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 18 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | #ifndef _SYS_LIMITS_H_ 27 | #define _SYS_LIMITS_H_ 28 | 29 | #include 30 | #include 31 | 32 | /* Common definitions for limits.h. */ 33 | 34 | #define CHAR_BIT 8 /* number of bits in a char */ 35 | 36 | #define SCHAR_MAX 0x7f /* max value for a signed char */ 37 | #define SCHAR_MIN (-0x7f-1) /* min value for a signed char */ 38 | 39 | #define UCHAR_MAX 0xffU /* max value for an unsigned char */ 40 | #ifdef __CHAR_UNSIGNED__ 41 | # define CHAR_MIN 0 /* min value for a char */ 42 | # define CHAR_MAX 0xff /* max value for a char */ 43 | #else 44 | # define CHAR_MAX 0x7f 45 | # define CHAR_MIN (-0x7f-1) 46 | #endif 47 | 48 | #define USHRT_MAX 0xffffU /* max value for an unsigned short */ 49 | #define SHRT_MAX 0x7fff /* max value for a short */ 50 | #define SHRT_MIN (-0x7fff-1) /* min value for a short */ 51 | 52 | #define UINT_MAX 0xffffffffU /* max value for an unsigned int */ 53 | #define INT_MAX 0x7fffffff /* max value for an int */ 54 | #define INT_MIN (-0x7fffffff-1) /* min value for an int */ 55 | 56 | #ifdef __LP64__ 57 | # define ULONG_MAX 0xffffffffffffffffUL 58 | /* max value for unsigned long */ 59 | # define LONG_MAX 0x7fffffffffffffffL 60 | /* max value for a signed long */ 61 | # define LONG_MIN (-0x7fffffffffffffffL-1) 62 | /* min value for a signed long */ 63 | #else 64 | # define ULONG_MAX 0xffffffffUL /* max value for an unsigned long */ 65 | # define LONG_MAX 0x7fffffffL /* max value for a long */ 66 | # define LONG_MIN (-0x7fffffffL-1)/* min value for a long */ 67 | #endif 68 | 69 | #if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 70 | # define ULLONG_MAX 0xffffffffffffffffULL 71 | /* max value for unsigned long long */ 72 | # define LLONG_MAX 0x7fffffffffffffffLL 73 | /* max value for a signed long long */ 74 | # define LLONG_MIN (-0x7fffffffffffffffLL-1) 75 | /* min value for a signed long long */ 76 | #endif 77 | 78 | #if __BSD_VISIBLE 79 | # define UID_MAX UINT_MAX /* max value for a uid_t */ 80 | # define GID_MAX UINT_MAX /* max value for a gid_t */ 81 | #endif 82 | 83 | 84 | #ifdef __LP64__ 85 | # define LONG_BIT 64 86 | #else 87 | # define LONG_BIT 32 88 | #endif 89 | 90 | /* float.h defines these as well */ 91 | 92 | /* Bionic: the following has been optimized out from our processed kernel headers */ 93 | 94 | #define CHILD_MAX 999 95 | #define OPEN_MAX 256 96 | 97 | /* Bionic-specific definitions */ 98 | 99 | #define _POSIX_VERSION 200809L /* Posix C language bindings version */ 100 | #define _POSIX2_VERSION -1 /* we don't support Posix command-line tools */ 101 | #define _XOPEN_VERSION 700 /* by Posix definition */ 102 | 103 | 104 | #define PTHREAD_DESTRUCTOR_ITERATIONS 4 // >= _POSIX_THREAD_DESTRUCTOR_ITERATIONS 105 | #define PTHREAD_KEYS_MAX 128 // >= _POSIX_THREAD_KEYS_MAX 106 | #define PTHREAD_THREADS_MAX 2048 // bionic has no specific limit 107 | 108 | #endif 109 | -------------------------------------------------------------------------------- /Extract/Extract/includes/sys/mman.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in 12 | * the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | #ifndef _SYS_MMAN_H_ 29 | #define _SYS_MMAN_H_ 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | __BEGIN_DECLS 36 | 37 | #ifndef MAP_ANON 38 | #define MAP_ANON MAP_ANONYMOUS 39 | #endif 40 | 41 | #define MAP_FAILED ((void *)-1) 42 | 43 | #define MREMAP_MAYMOVE 1 44 | #define MREMAP_FIXED 2 45 | 46 | #define POSIX_MADV_NORMAL MADV_NORMAL 47 | #define POSIX_MADV_RANDOM MADV_RANDOM 48 | #define POSIX_MADV_SEQUENTIAL MADV_SEQUENTIAL 49 | #define POSIX_MADV_WILLNEED MADV_WILLNEED 50 | #define POSIX_MADV_DONTNEED MADV_DONTNEED 51 | 52 | #if defined(__USE_FILE_OFFSET64) 53 | extern void* mmap(void*, size_t, int, int, int, off_t) __RENAME(mmap64); 54 | #else 55 | //extern void* mmap(void*, size_t, int, int, int, off_t); 56 | #endif 57 | //extern void* mmap64(void*, size_t, int, int, int, off64_t); 58 | 59 | extern int munmap(void*, size_t); 60 | extern int msync(const void*, size_t, int); 61 | extern int mprotect(const void*, size_t, int); 62 | extern void* mremap(void*, size_t, size_t, unsigned long); 63 | 64 | extern int mlockall(int); 65 | extern int munlockall(void); 66 | extern int mlock(const void*, size_t); 67 | extern int munlock(const void*, size_t); 68 | extern int madvise(void*, size_t, int); 69 | 70 | extern int mlock(const void*, size_t); 71 | extern int munlock(const void*, size_t); 72 | 73 | extern int mincore(void*, size_t, unsigned char*); 74 | 75 | extern int posix_madvise(void*, size_t, int); 76 | 77 | __END_DECLS 78 | 79 | #endif /* _SYS_MMAN_H_ */ 80 | -------------------------------------------------------------------------------- /Extract/Extract/includes/sys/param.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in 12 | * the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | #ifndef _SYS_PARAM_H_ 29 | #define _SYS_PARAM_H_ 30 | 31 | #include 32 | #include 33 | 34 | #define MAXPATHLEN PATH_MAX 35 | #define MAXSYMLINKS 8 36 | 37 | /* Macros for counting and rounding. */ 38 | #ifndef howmany 39 | #define howmany(x, y) (((x)+((y)-1))/(y)) 40 | #endif 41 | #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) 42 | #define powerof2(x) ((((x)-1)&(x))==0) 43 | 44 | /* Macros for min/max. */ 45 | #define MIN(a,b) (((a)<(b))?(a):(b)) 46 | #define MAX(a,b) (((a)>(b))?(a):(b)) 47 | 48 | #endif /* _SYS_PARAM_H_ */ 49 | -------------------------------------------------------------------------------- /Extract/Extract/includes/sys/syslimits.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CCint3/LLeGu/c3b4c31709e5759c943d3fa07345555c2c650bdd/Extract/Extract/includes/sys/syslimits.h -------------------------------------------------------------------------------- /Extract/Extract/includes/sys/sysmacros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in 12 | * the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | #ifndef _SYS_SYSMACROS_H_ 29 | #define _SYS_SYSMACROS_H_ 30 | 31 | /* some rogue code includes this file directly :-( */ 32 | #ifndef _SYS_TYPES_H_ 33 | # include 34 | #endif 35 | 36 | static __inline int major(dev_t _dev) 37 | { 38 | return (_dev >> 8) & 0xfff; 39 | } 40 | 41 | static __inline int minor(dev_t _dev) 42 | { 43 | return (_dev & 0xff) | ((_dev >> 12) & 0xfff00); 44 | } 45 | 46 | static __inline dev_t makedev(int __ma, int __mi) 47 | { 48 | return ((__ma & 0xfff) << 8) | (__mi & 0xff) | ((__mi & 0xfff00) << 12); 49 | } 50 | 51 | #endif /* _SYS_SYSMACROS_H_ */ 52 | 53 | -------------------------------------------------------------------------------- /Extract/Extract/linker.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "file.h" 9 | 10 | void SoinfoListAllocator::free(LinkedListEntry* entry) { 11 | //g_soinfo_links_allocator.free(entry); 12 | } 13 | 14 | soinfo* soinfo_alloc(const char* name, struct _stat64* file_stat, off64_t file_offset, uint32_t rtld_flags) { 15 | if (strlen(name) >= PATH_MAX) { 16 | DL_ERR("library name \"%s\" too long", name); 17 | return nullptr; 18 | } 19 | 20 | soinfo* si = new struct soinfo(name, file_stat, file_offset, rtld_flags); 21 | 22 | return si; 23 | } 24 | 25 | soinfo::soinfo(const char* realpath, const struct _stat64* file_stat, off64_t file_offset, int rtld_flags) { 26 | memset(this, 0, sizeof(*this)); 27 | 28 | if (realpath != nullptr) { 29 | realpath_ = realpath; 30 | } 31 | 32 | flags_ = FLAG_NEW_SOINFO; 33 | version_ = SOINFO_VERSION; 34 | 35 | if (file_stat != nullptr) { 36 | this->st_dev_ = file_stat->st_dev; 37 | this->st_ino_ = file_stat->st_ino; 38 | this->file_offset_ = file_offset; 39 | } 40 | 41 | this->rtld_flags_ = rtld_flags; 42 | } 43 | 44 | const char* soinfo::get_string(ElfW(Word) index) const { 45 | if (has_min_version(1) && (index >= strtab_size_)) { 46 | //__libc_fatal("%s: strtab out of bounds error; STRSZ=%zd, name=%d", get_realpath(), strtab_size_, index); 47 | } 48 | 49 | return strtab_ + index; 50 | } 51 | 52 | void soinfo::set_dt_flags_1(uint32_t dt_flags_1) { 53 | if (has_min_version(1)) { 54 | if ((dt_flags_1 & DF_1_GLOBAL) != 0) { 55 | rtld_flags_ |= RTLD_GLOBAL; 56 | } 57 | 58 | if ((dt_flags_1 & DF_1_NODELETE) != 0) { 59 | rtld_flags_ |= RTLD_NODELETE; 60 | } 61 | 62 | dt_flags_1_ = dt_flags_1; 63 | } 64 | } 65 | 66 | const char* soinfo::get_realpath() const { 67 | return realpath_; 68 | } 69 | 70 | bool soinfo::prelink_image(Header &header) { 71 | /* Extract dynamic section */ 72 | ElfW(Word) dynamic_flags = 0; 73 | phdr_table_get_dynamic_section(phdr, phnum, load_bias, &dynamic, &dynamic_flags); 74 | 75 | /* We can't log anything until the linker is relocated */ 76 | bool relocating_linker = (flags_ & FLAG_LINKER) != 0; 77 | if (!relocating_linker) { 78 | INFO("[ linking %s ]", get_realpath()); 79 | DEBUG("si->base = %p si->flags = 0x%08x", reinterpret_cast(base), flags_); 80 | } 81 | 82 | if (dynamic == nullptr) { 83 | if (!relocating_linker) { 84 | DL_ERR("missing PT_DYNAMIC in \"%s\"", get_realpath()); 85 | } 86 | return false; 87 | } else { 88 | if (!relocating_linker) { 89 | DEBUG("dynamic = %p", dynamic); 90 | } 91 | } 92 | 93 | #if defined(__arm__) 94 | (void)phdr_table_get_arm_exidx(phdr, phnum, load_bias, &ARM_exidx, &ARM_exidx_count); 95 | header.ARM_exidx = reinterpret_cast(ARM_exidx) - load_bias; 96 | header.ARM_exidx_count = ARM_exidx_count; 97 | #endif 98 | 99 | // Extract useful information from dynamic section. 100 | // Note that: "Except for the DT_NULL element at the end of the array, 101 | // and the relative order of DT_NEEDED elements, entries may appear in any order." 102 | // 103 | // source: http://www.sco.com/developers/gabi/1998-04-29/ch5.dynamic.html 104 | uint32_t needed_count = 0; 105 | for (ElfW(Dyn)* d = dynamic; d->d_tag != DT_NULL; ++d) { 106 | DEBUG("d = %p, d[0](tag) = %p d[1](val) = %p", d, reinterpret_cast(d->d_tag), reinterpret_cast(d->d_un.d_val)); 107 | switch (d->d_tag) { 108 | case DT_SONAME: 109 | // this is parsed after we have strtab initialized (see below). 110 | break; 111 | 112 | case DT_HASH: 113 | nbucket_ = reinterpret_cast(load_bias + d->d_un.d_ptr)[0]; 114 | nchain_ = reinterpret_cast(load_bias + d->d_un.d_ptr)[1]; 115 | bucket_ = reinterpret_cast(load_bias + d->d_un.d_ptr + 8); 116 | chain_ = reinterpret_cast(load_bias + d->d_un.d_ptr + 8 + nbucket_ * 4); 117 | header.nbucket_ = reinterpret_cast(load_bias + d->d_un.d_ptr)[0]; 118 | header.nchain_ = reinterpret_cast(load_bias + d->d_un.d_ptr)[1]; 119 | header.bucket_ = d->d_un.d_ptr + 8; 120 | break; 121 | 122 | case DT_GNU_HASH: 123 | gnu_nbucket_ = reinterpret_cast(load_bias + d->d_un.d_ptr)[0]; 124 | // skip symndx 125 | gnu_maskwords_ = reinterpret_cast(load_bias + d->d_un.d_ptr)[2]; 126 | gnu_shift2_ = reinterpret_cast(load_bias + d->d_un.d_ptr)[3]; 127 | 128 | gnu_bloom_filter_ = reinterpret_cast(load_bias + d->d_un.d_ptr + 16); 129 | gnu_bucket_ = reinterpret_cast(gnu_bloom_filter_ + gnu_maskwords_); 130 | // amend chain for symndx = header[1] 131 | gnu_chain_ = gnu_bucket_ + gnu_nbucket_ - 132 | reinterpret_cast(load_bias + d->d_un.d_ptr)[1]; 133 | 134 | if (!powerof2(gnu_maskwords_)) { 135 | DL_ERR("invalid maskwords for gnu_hash = 0x%x, in \"%s\" expecting power to two", 136 | gnu_maskwords_, get_realpath()); 137 | return false; 138 | } 139 | --gnu_maskwords_; 140 | 141 | flags_ |= FLAG_GNU_HASH; 142 | break; 143 | 144 | case DT_STRTAB: 145 | strtab_ = reinterpret_cast(load_bias + d->d_un.d_ptr); 146 | header.strtab_ = d->d_un.d_ptr; 147 | break; 148 | 149 | case DT_STRSZ: 150 | strtab_size_ = d->d_un.d_val; 151 | header.strtab_size_ = d->d_un.d_val; 152 | break; 153 | 154 | case DT_SYMTAB: 155 | symtab_ = reinterpret_cast(load_bias + d->d_un.d_ptr); 156 | header.symtab_ = d->d_un.d_ptr; 157 | break; 158 | 159 | case DT_SYMENT: 160 | if (d->d_un.d_val != sizeof(ElfW(Sym))) { 161 | DL_ERR("invalid DT_SYMENT: %zd in \"%s\"", static_cast(d->d_un.d_val), get_realpath()); 162 | return false; 163 | } 164 | break; 165 | 166 | case DT_PLTREL: 167 | #if defined(USE_RELA) 168 | if (d->d_un.d_val != DT_RELA) { 169 | DL_ERR("unsupported DT_PLTREL in \"%s\"; expected DT_RELA", get_realpath()); 170 | return false; 171 | } 172 | #else 173 | if (d->d_un.d_val != DT_REL) { 174 | DL_ERR("unsupported DT_PLTREL in \"%s\"; expected DT_REL", get_realpath()); 175 | return false; 176 | } 177 | #endif 178 | break; 179 | 180 | case DT_JMPREL: 181 | #if defined(USE_RELA) 182 | plt_rela_ = reinterpret_cast(load_bias + d->d_un.d_ptr); 183 | #else 184 | plt_rel_ = reinterpret_cast(load_bias + d->d_un.d_ptr); 185 | header.plt_rel_ = d->d_un.d_ptr; 186 | #endif 187 | break; 188 | 189 | case DT_PLTRELSZ: 190 | #if defined(USE_RELA) 191 | plt_rela_count_ = d->d_un.d_val / sizeof(ElfW(Rela)); 192 | #else 193 | plt_rel_count_ = d->d_un.d_val / sizeof(ElfW(Rel)); 194 | header.plt_rel_count_ = d->d_un.d_val / sizeof(ElfW(Rel)); 195 | #endif 196 | break; 197 | 198 | case DT_PLTGOT: 199 | #if defined(__mips__) 200 | // Used by mips and mips64. 201 | plt_got_ = reinterpret_cast(load_bias + d->d_un.d_ptr); 202 | #endif 203 | // Ignore for other platforms... (because RTLD_LAZY is not supported) 204 | break; 205 | 206 | case DT_DEBUG: 207 | // Set the DT_DEBUG entry to the address of _r_debug for GDB 208 | // if the dynamic table is writable 209 | // FIXME: not working currently for N64 210 | // The flags for the LOAD and DYNAMIC program headers do not agree. 211 | // The LOAD section containing the dynamic table has been mapped as 212 | // read-only, but the DYNAMIC header claims it is writable. 213 | #if !(defined(__mips__) && defined(__LP64__)) 214 | if ((dynamic_flags & PF_W) != 0) { 215 | // d->d_un.d_val = reinterpret_cast(&_r_debug); 216 | } 217 | #endif 218 | break; 219 | #if defined(USE_RELA) 220 | case DT_RELA: 221 | rela_ = reinterpret_cast(load_bias + d->d_un.d_ptr); 222 | break; 223 | 224 | case DT_RELASZ: 225 | rela_count_ = d->d_un.d_val / sizeof(ElfW(Rela)); 226 | break; 227 | 228 | case DT_ANDROID_RELA: 229 | android_relocs_ = reinterpret_cast(load_bias + d->d_un.d_ptr); 230 | break; 231 | 232 | case DT_ANDROID_RELASZ: 233 | android_relocs_size_ = d->d_un.d_val; 234 | break; 235 | 236 | case DT_ANDROID_REL: 237 | DL_ERR("unsupported DT_ANDROID_REL in \"%s\"", get_realpath()); 238 | return false; 239 | 240 | case DT_ANDROID_RELSZ: 241 | DL_ERR("unsupported DT_ANDROID_RELSZ in \"%s\"", get_realpath()); 242 | return false; 243 | 244 | case DT_RELAENT: 245 | if (d->d_un.d_val != sizeof(ElfW(Rela))) { 246 | DL_ERR("invalid DT_RELAENT: %zd", static_cast(d->d_un.d_val)); 247 | return false; 248 | } 249 | break; 250 | 251 | // ignored (see DT_RELCOUNT comments for details) 252 | case DT_RELACOUNT: 253 | break; 254 | 255 | case DT_REL: 256 | DL_ERR("unsupported DT_REL in \"%s\"", get_realpath()); 257 | return false; 258 | 259 | case DT_RELSZ: 260 | DL_ERR("unsupported DT_RELSZ in \"%s\"", get_realpath()); 261 | return false; 262 | 263 | #else 264 | case DT_REL: 265 | rel_ = reinterpret_cast(load_bias + d->d_un.d_ptr); 266 | header.rel_ = d->d_un.d_ptr; 267 | break; 268 | 269 | case DT_RELSZ: 270 | rel_count_ = d->d_un.d_val / sizeof(ElfW(Rel)); 271 | header.rel_count_ = d->d_un.d_val / sizeof(ElfW(Rel)); 272 | break; 273 | 274 | case DT_RELENT: 275 | if (d->d_un.d_val != sizeof(ElfW(Rel))) { 276 | DL_ERR("invalid DT_RELENT: %zd", static_cast(d->d_un.d_val)); 277 | return false; 278 | } 279 | break; 280 | 281 | case DT_ANDROID_REL: 282 | android_relocs_ = reinterpret_cast(load_bias + d->d_un.d_ptr); 283 | break; 284 | 285 | case DT_ANDROID_RELSZ: 286 | android_relocs_size_ = d->d_un.d_val; 287 | break; 288 | 289 | case DT_ANDROID_RELA: 290 | DL_ERR("unsupported DT_ANDROID_RELA in \"%s\"", get_realpath()); 291 | return false; 292 | 293 | case DT_ANDROID_RELASZ: 294 | DL_ERR("unsupported DT_ANDROID_RELASZ in \"%s\"", get_realpath()); 295 | return false; 296 | 297 | // "Indicates that all RELATIVE relocations have been concatenated together, 298 | // and specifies the RELATIVE relocation count." 299 | // 300 | // TODO: Spec also mentions that this can be used to optimize relocation process; 301 | // Not currently used by bionic linker - ignored. 302 | case DT_RELCOUNT: 303 | break; 304 | 305 | case DT_RELA: 306 | DL_ERR("unsupported DT_RELA in \"%s\"", get_realpath()); 307 | return false; 308 | 309 | case DT_RELASZ: 310 | DL_ERR("unsupported DT_RELASZ in \"%s\"", get_realpath()); 311 | return false; 312 | 313 | #endif 314 | case DT_INIT: 315 | init_func_ = reinterpret_cast(load_bias + d->d_un.d_ptr); 316 | header.init_func_ = d->d_un.d_ptr; 317 | DEBUG("%s constructors (DT_INIT) found at %p", get_realpath(), init_func_); 318 | break; 319 | 320 | case DT_FINI: 321 | fini_func_ = reinterpret_cast(load_bias + d->d_un.d_ptr); 322 | header.fini_func_ = d->d_un.d_ptr; 323 | DEBUG("%s destructors (DT_FINI) found at %p", get_realpath(), fini_func_); 324 | break; 325 | 326 | case DT_INIT_ARRAY: 327 | init_array_ = reinterpret_cast(load_bias + d->d_un.d_ptr); 328 | header.init_array_ = d->d_un.d_ptr; 329 | DEBUG("%s constructors (DT_INIT_ARRAY) found at %p", get_realpath(), init_array_); 330 | break; 331 | 332 | case DT_INIT_ARRAYSZ: 333 | init_array_count_ = static_cast(d->d_un.d_val) / sizeof(ElfW(Addr)); 334 | header.init_array_count_ = static_cast(d->d_un.d_val) / sizeof(ElfW(Addr)); 335 | break; 336 | 337 | case DT_FINI_ARRAY: 338 | fini_array_ = reinterpret_cast(load_bias + d->d_un.d_ptr); 339 | header.fini_array_ = d->d_un.d_ptr; 340 | DEBUG("%s destructors (DT_FINI_ARRAY) found at %p", get_realpath(), fini_array_); 341 | break; 342 | 343 | case DT_FINI_ARRAYSZ: 344 | fini_array_count_ = static_cast(d->d_un.d_val) / sizeof(ElfW(Addr)); 345 | header.fini_array_count_ = static_cast(d->d_un.d_val) / sizeof(ElfW(Addr)); 346 | break; 347 | 348 | case DT_PREINIT_ARRAY: 349 | preinit_array_ = reinterpret_cast(load_bias + d->d_un.d_ptr); 350 | DEBUG("%s constructors (DT_PREINIT_ARRAY) found at %p", get_realpath(), preinit_array_); 351 | break; 352 | 353 | case DT_PREINIT_ARRAYSZ: 354 | preinit_array_count_ = static_cast(d->d_un.d_val) / sizeof(ElfW(Addr)); 355 | break; 356 | 357 | case DT_TEXTREL: 358 | #if defined(__LP64__) 359 | DL_ERR("text relocations (DT_TEXTREL) found in 64-bit ELF file \"%s\"", get_realpath()); 360 | return false; 361 | #else 362 | has_text_relocations = true; 363 | break; 364 | #endif 365 | 366 | case DT_SYMBOLIC: 367 | has_DT_SYMBOLIC = true; 368 | break; 369 | 370 | case DT_NEEDED: 371 | ++needed_count; 372 | header.needed_count_++; 373 | break; 374 | 375 | case DT_FLAGS: 376 | if (d->d_un.d_val & DF_TEXTREL) { 377 | #if defined(__LP64__) 378 | DL_ERR("text relocations (DF_TEXTREL) found in 64-bit ELF file \"%s\"", get_realpath()); 379 | return false; 380 | #else 381 | has_text_relocations = true; 382 | #endif 383 | } 384 | if (d->d_un.d_val & DF_SYMBOLIC) { 385 | has_DT_SYMBOLIC = true; 386 | } 387 | break; 388 | 389 | case DT_FLAGS_1: 390 | set_dt_flags_1(d->d_un.d_val); 391 | 392 | if ((d->d_un.d_val & ~SUPPORTED_DT_FLAGS_1) != 0) { 393 | DL_WARN("%s: unsupported flags DT_FLAGS_1=%p", get_realpath(), reinterpret_cast(d->d_un.d_val)); 394 | } 395 | break; 396 | #if defined(__mips__) 397 | case DT_MIPS_RLD_MAP: 398 | // Set the DT_MIPS_RLD_MAP entry to the address of _r_debug for GDB. 399 | { 400 | r_debug** dp = reinterpret_cast(load_bias + d->d_un.d_ptr); 401 | *dp = &_r_debug; 402 | } 403 | break; 404 | case DT_MIPS_RLD_MAP2: 405 | // Set the DT_MIPS_RLD_MAP2 entry to the address of _r_debug for GDB. 406 | { 407 | r_debug** dp = reinterpret_cast( 408 | reinterpret_cast(d) + d->d_un.d_val); 409 | *dp = &_r_debug; 410 | } 411 | break; 412 | 413 | case DT_MIPS_RLD_VERSION: 414 | case DT_MIPS_FLAGS: 415 | case DT_MIPS_BASE_ADDRESS: 416 | case DT_MIPS_UNREFEXTNO: 417 | break; 418 | 419 | case DT_MIPS_SYMTABNO: 420 | mips_symtabno_ = d->d_un.d_val; 421 | break; 422 | 423 | case DT_MIPS_LOCAL_GOTNO: 424 | mips_local_gotno_ = d->d_un.d_val; 425 | break; 426 | 427 | case DT_MIPS_GOTSYM: 428 | mips_gotsym_ = d->d_un.d_val; 429 | break; 430 | #endif 431 | // Ignored: "Its use has been superseded by the DF_BIND_NOW flag" 432 | case DT_BIND_NOW: 433 | break; 434 | 435 | case DT_VERSYM: 436 | versym_ = reinterpret_cast(load_bias + d->d_un.d_ptr); 437 | break; 438 | 439 | case DT_VERDEF: 440 | verdef_ptr_ = load_bias + d->d_un.d_ptr; 441 | break; 442 | case DT_VERDEFNUM: 443 | verdef_cnt_ = d->d_un.d_val; 444 | break; 445 | 446 | case DT_VERNEED: 447 | verneed_ptr_ = load_bias + d->d_un.d_ptr; 448 | break; 449 | 450 | case DT_VERNEEDNUM: 451 | verneed_cnt_ = d->d_un.d_val; 452 | break; 453 | 454 | default: 455 | if (!relocating_linker) { 456 | DL_WARN("%s: unused DT entry: type %p arg %p", get_realpath(), 457 | reinterpret_cast(d->d_tag), reinterpret_cast(d->d_un.d_val)); 458 | } 459 | break; 460 | } 461 | } 462 | 463 | DEBUG("si->base = %p, si->strtab = %p, si->symtab = %p", reinterpret_cast(base), strtab_, symtab_); 464 | 465 | // Sanity checks. 466 | if (relocating_linker && needed_count != 0) { 467 | DL_ERR("linker cannot have DT_NEEDED dependencies on other libraries"); 468 | return false; 469 | } 470 | if (nbucket_ == 0 && gnu_nbucket_ == 0) { 471 | DL_ERR("empty/missing DT_HASH/DT_GNU_HASH in \"%s\" " 472 | "(new hash type from the future?)", get_realpath()); 473 | return false; 474 | } 475 | if (strtab_ == 0) { 476 | DL_ERR("empty/missing DT_STRTAB in \"%s\"", get_realpath()); 477 | return false; 478 | } 479 | if (symtab_ == 0) { 480 | DL_ERR("empty/missing DT_SYMTAB in \"%s\"", get_realpath()); 481 | return false; 482 | } 483 | 484 | // second pass - parse entries relying on strtab 485 | for (ElfW(Dyn)* d = dynamic; d->d_tag != DT_NULL; ++d) { 486 | if (d->d_tag == DT_SONAME) { 487 | soname_ = get_string(d->d_un.d_val); 488 | #if defined(__work_around_b_19059885__) 489 | //strlcpy(old_name_, soname_, sizeof(old_name_)); 490 | #endif 491 | break; 492 | } 493 | } 494 | 495 | // Before M release linker was using basename in place of soname. 496 | // In the case when dt_soname is absent some apps stop working 497 | // because they can't find dt_needed library by soname. 498 | // This workaround should keep them working. (applies only 499 | // for apps targeting sdk version <=22). Make an exception for 500 | // the main executable and linker; they do not need to have dt_soname 501 | /* 502 | if (soname_ == nullptr 503 | && this != somain 504 | && (flags_ & FLAG_LINKER) == 0 505 | && get_application_target_sdk_version() <= 22 506 | ) { 507 | soname_ = realpath_; 508 | DL_WARN("%s: is missing DT_SONAME will use basename as a replacement: \"%s\"", get_realpath(), soname_); 509 | } 510 | */ 511 | return true; 512 | } 513 | 514 | template 515 | void for_each_dt_needed(const soinfo* si, F action) { 516 | for (ElfW(Dyn)* d = si->dynamic; d->d_tag != DT_NULL; ++d) { 517 | if (d->d_tag == DT_NEEDED) { 518 | action(fix_dt_needed(si->get_string(d->d_un.d_val), si->get_realpath())); 519 | } 520 | } 521 | } -------------------------------------------------------------------------------- /Extract/Extract/zconf.h: -------------------------------------------------------------------------------- 1 | /* zconf.h -- configuration of the zlib compression library 2 | * Copyright (C) 1995-2005 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #ifndef ZCONF_H 9 | #define ZCONF_H 10 | 11 | /* 12 | * If you *really* need a unique prefix for all types and library functions, 13 | * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. 14 | */ 15 | #ifdef Z_PREFIX 16 | # define deflateInit_ z_deflateInit_ 17 | # define deflate z_deflate 18 | # define deflateEnd z_deflateEnd 19 | # define inflateInit_ z_inflateInit_ 20 | # define inflate z_inflate 21 | # define inflateEnd z_inflateEnd 22 | # define deflateInit2_ z_deflateInit2_ 23 | # define deflateSetDictionary z_deflateSetDictionary 24 | # define deflateCopy z_deflateCopy 25 | # define deflateReset z_deflateReset 26 | # define deflateParams z_deflateParams 27 | # define deflateBound z_deflateBound 28 | # define deflatePrime z_deflatePrime 29 | # define inflateInit2_ z_inflateInit2_ 30 | # define inflateSetDictionary z_inflateSetDictionary 31 | # define inflateSync z_inflateSync 32 | # define inflateSyncPoint z_inflateSyncPoint 33 | # define inflateCopy z_inflateCopy 34 | # define inflateReset z_inflateReset 35 | # define inflateBack z_inflateBack 36 | # define inflateBackEnd z_inflateBackEnd 37 | # define compress z_compress 38 | # define compress2 z_compress2 39 | # define compressBound z_compressBound 40 | # define uncompress z_uncompress 41 | # define adler32 z_adler32 42 | # define crc32 z_crc32 43 | # define get_crc_table z_get_crc_table 44 | # define zError z_zError 45 | 46 | # define alloc_func z_alloc_func 47 | # define free_func z_free_func 48 | # define in_func z_in_func 49 | # define out_func z_out_func 50 | # define Byte z_Byte 51 | # define uInt z_uInt 52 | # define uLong z_uLong 53 | # define Bytef z_Bytef 54 | # define charf z_charf 55 | # define intf z_intf 56 | # define uIntf z_uIntf 57 | # define uLongf z_uLongf 58 | # define voidpf z_voidpf 59 | # define voidp z_voidp 60 | #endif 61 | 62 | #if defined(__MSDOS__) && !defined(MSDOS) 63 | # define MSDOS 64 | #endif 65 | #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) 66 | # define OS2 67 | #endif 68 | #if defined(_WINDOWS) && !defined(WINDOWS) 69 | # define WINDOWS 70 | #endif 71 | #if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) 72 | # ifndef WIN32 73 | # define WIN32 74 | # endif 75 | #endif 76 | #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) 77 | # if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) 78 | # ifndef SYS16BIT 79 | # define SYS16BIT 80 | # endif 81 | # endif 82 | #endif 83 | 84 | /* 85 | * Compile with -DMAXSEG_64K if the alloc function cannot allocate more 86 | * than 64k bytes at a time (needed on systems with 16-bit int). 87 | */ 88 | #ifdef SYS16BIT 89 | # define MAXSEG_64K 90 | #endif 91 | #ifdef MSDOS 92 | # define UNALIGNED_OK 93 | #endif 94 | 95 | #ifdef __STDC_VERSION__ 96 | # ifndef STDC 97 | # define STDC 98 | # endif 99 | # if __STDC_VERSION__ >= 199901L 100 | # ifndef STDC99 101 | # define STDC99 102 | # endif 103 | # endif 104 | #endif 105 | #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) 106 | # define STDC 107 | #endif 108 | #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) 109 | # define STDC 110 | #endif 111 | #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) 112 | # define STDC 113 | #endif 114 | #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) 115 | # define STDC 116 | #endif 117 | 118 | #if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ 119 | # define STDC 120 | #endif 121 | 122 | #ifndef STDC 123 | # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ 124 | # define const /* note: need a more gentle solution here */ 125 | # endif 126 | #endif 127 | 128 | /* Some Mac compilers merge all .h files incorrectly: */ 129 | #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) 130 | # define NO_DUMMY_DECL 131 | #endif 132 | 133 | /* Maximum value for memLevel in deflateInit2 */ 134 | #ifndef MAX_MEM_LEVEL 135 | # ifdef MAXSEG_64K 136 | # define MAX_MEM_LEVEL 8 137 | # else 138 | # define MAX_MEM_LEVEL 9 139 | # endif 140 | #endif 141 | 142 | /* Maximum value for windowBits in deflateInit2 and inflateInit2. 143 | * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files 144 | * created by gzip. (Files created by minigzip can still be extracted by 145 | * gzip.) 146 | */ 147 | #ifndef MAX_WBITS 148 | # define MAX_WBITS 15 /* 32K LZ77 window */ 149 | #endif 150 | 151 | /* The memory requirements for deflate are (in bytes): 152 | (1 << (windowBits+2)) + (1 << (memLevel+9)) 153 | that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) 154 | plus a few kilobytes for small objects. For example, if you want to reduce 155 | the default memory requirements from 256K to 128K, compile with 156 | make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" 157 | Of course this will generally degrade compression (there's no free lunch). 158 | 159 | The memory requirements for inflate are (in bytes) 1 << windowBits 160 | that is, 32K for windowBits=15 (default value) plus a few kilobytes 161 | for small objects. 162 | */ 163 | 164 | /* Type declarations */ 165 | 166 | #ifndef OF /* function prototypes */ 167 | # ifdef STDC 168 | # define OF(args) args 169 | # else 170 | # define OF(args) () 171 | # endif 172 | #endif 173 | 174 | /* The following definitions for FAR are needed only for MSDOS mixed 175 | * model programming (small or medium model with some far allocations). 176 | * This was tested only with MSC; for other MSDOS compilers you may have 177 | * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, 178 | * just define FAR to be empty. 179 | */ 180 | #ifdef SYS16BIT 181 | # if defined(M_I86SM) || defined(M_I86MM) 182 | /* MSC small or medium model */ 183 | # define SMALL_MEDIUM 184 | # ifdef _MSC_VER 185 | # define FAR _far 186 | # else 187 | # define FAR far 188 | # endif 189 | # endif 190 | # if (defined(__SMALL__) || defined(__MEDIUM__)) 191 | /* Turbo C small or medium model */ 192 | # define SMALL_MEDIUM 193 | # ifdef __BORLANDC__ 194 | # define FAR _far 195 | # else 196 | # define FAR far 197 | # endif 198 | # endif 199 | #endif 200 | 201 | #if defined(WINDOWS) || defined(WIN32) 202 | /* If building or using zlib as a DLL, define ZLIB_DLL. 203 | * This is not mandatory, but it offers a little performance increase. 204 | */ 205 | # ifdef ZLIB_DLL 206 | # if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) 207 | # ifdef ZLIB_INTERNAL 208 | # define ZEXTERN extern __declspec(dllexport) 209 | # else 210 | # define ZEXTERN extern __declspec(dllimport) 211 | # endif 212 | # endif 213 | # endif /* ZLIB_DLL */ 214 | /* If building or using zlib with the WINAPI/WINAPIV calling convention, 215 | * define ZLIB_WINAPI. 216 | * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. 217 | */ 218 | # ifdef ZLIB_WINAPI 219 | # ifdef FAR 220 | # undef FAR 221 | # endif 222 | # include 223 | /* No need for _export, use ZLIB.DEF instead. */ 224 | /* For complete Windows compatibility, use WINAPI, not __stdcall. */ 225 | # define ZEXPORT WINAPI 226 | # ifdef WIN32 227 | # define ZEXPORTVA WINAPIV 228 | # else 229 | # define ZEXPORTVA FAR CDECL 230 | # endif 231 | # endif 232 | #endif 233 | 234 | #if defined (__BEOS__) 235 | # ifdef ZLIB_DLL 236 | # ifdef ZLIB_INTERNAL 237 | # define ZEXPORT __declspec(dllexport) 238 | # define ZEXPORTVA __declspec(dllexport) 239 | # else 240 | # define ZEXPORT __declspec(dllimport) 241 | # define ZEXPORTVA __declspec(dllimport) 242 | # endif 243 | # endif 244 | #endif 245 | 246 | #ifndef ZEXTERN 247 | # define ZEXTERN extern 248 | #endif 249 | #ifndef ZEXPORT 250 | # define ZEXPORT 251 | #endif 252 | #ifndef ZEXPORTVA 253 | # define ZEXPORTVA 254 | #endif 255 | 256 | #ifndef FAR 257 | # define FAR 258 | #endif 259 | 260 | #if !defined(__MACTYPES__) 261 | typedef unsigned char Byte; /* 8 bits */ 262 | #endif 263 | typedef unsigned int uInt; /* 16 bits or more */ 264 | typedef unsigned long uLong; /* 32 bits or more */ 265 | 266 | #ifdef SMALL_MEDIUM 267 | /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ 268 | # define Bytef Byte FAR 269 | #else 270 | typedef Byte FAR Bytef; 271 | #endif 272 | typedef char FAR charf; 273 | typedef int FAR intf; 274 | typedef uInt FAR uIntf; 275 | typedef uLong FAR uLongf; 276 | 277 | #ifdef STDC 278 | typedef void const *voidpc; 279 | typedef void FAR *voidpf; 280 | typedef void *voidp; 281 | #else 282 | typedef Byte const *voidpc; 283 | typedef Byte FAR *voidpf; 284 | typedef Byte *voidp; 285 | #endif 286 | 287 | #if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */ 288 | # include /* for off_t */ 289 | # include /* for SEEK_* and off_t */ 290 | # ifdef VMS 291 | # include /* for off_t */ 292 | # endif 293 | # define z_off_t off_t 294 | #endif 295 | #ifndef SEEK_SET 296 | # define SEEK_SET 0 /* Seek from beginning of file. */ 297 | # define SEEK_CUR 1 /* Seek from current position. */ 298 | # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ 299 | #endif 300 | #ifndef z_off_t 301 | # define z_off_t long 302 | #endif 303 | 304 | #if defined(__OS400__) 305 | # define NO_vsnprintf 306 | #endif 307 | 308 | #if defined(__MVS__) 309 | # define NO_vsnprintf 310 | # ifdef FAR 311 | # undef FAR 312 | # endif 313 | #endif 314 | 315 | /* MVS linker does not support external names larger than 8 bytes */ 316 | #if defined(__MVS__) 317 | # pragma map(deflateInit_,"DEIN") 318 | # pragma map(deflateInit2_,"DEIN2") 319 | # pragma map(deflateEnd,"DEEND") 320 | # pragma map(deflateBound,"DEBND") 321 | # pragma map(inflateInit_,"ININ") 322 | # pragma map(inflateInit2_,"ININ2") 323 | # pragma map(inflateEnd,"INEND") 324 | # pragma map(inflateSync,"INSY") 325 | # pragma map(inflateSetDictionary,"INSEDI") 326 | # pragma map(compressBound,"CMBND") 327 | # pragma map(inflate_table,"INTABL") 328 | # pragma map(inflate_fast,"INFA") 329 | # pragma map(inflate_copyright,"INCOPY") 330 | #endif 331 | 332 | #endif /* ZCONF_H */ 333 | -------------------------------------------------------------------------------- /Extract/Extract/zlib.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CCint3/LLeGu/c3b4c31709e5759c943d3fa07345555c2c650bdd/Extract/Extract/zlib.lib -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LLeGu 2 | 3 | LLeGu 是一基于 "腾讯Legu" 的 Android ELF 加壳工具,所以起名为 "Like-LeGu LLeGu"。主要应用于*.so的加壳。 4 | 5 | ## 新特性 6 | 7 | - 没啥新特性:加入了一些加密算法,加密字符串,加密导入表等等。 8 | - 没啥新特性:更多的是希望你能自己编译它,使用它。然后看看它的效果。 9 | - 欢迎各位提出自己的意见和建议。 10 | 11 | ## 兼容性 12 | - 目前仅在Android-6.0.1_r77的系统上做了测试。 13 | - 因为壳入口使用了内联汇编读取soinfo结构体,所以兼容性很差。 14 | 15 | ## 工程介绍 16 | - Extract: 加壳工具 17 | 1. 初始化一些随机幻数,这些幻数应用于解密。 18 | 2. 解析待加密的ELF,提取有用的信息。例如:段数量;段大小;导入表和字符串表。 19 | 3. 使用zlib压缩每一个段,并使用TEA加密压缩后的数据。 20 | 4. 生成settings.h,用于下一阶段的壳编译工作。其中记录了很多有用的信息。 21 | 5. 生成ldscript,用于下一阶段的壳编译工作。GCC编译器识别该脚本,可以编译出特定的ELF文件。 22 | 6. 执行run_make.bat去编译壳。 23 | - shell: 壳的主要代码 24 | 1. 通过Extract.exe生成的settings.h和ldscript两个配置文件去编译壳。 25 | 2. 壳代码基于 "腾讯LeGu"。 26 | 27 | ## 编译 28 | - 编辑run_make.bat,配置NDK的目录 29 | - Visual Studio 2017 将Extrace工程编译为 x86 Release 30 | - 将编译好的Extract.exe放入shell目录中 31 | - 命令行进入shell目录,并运行 Extract libxxx.so 32 | - 生成shell_bak.so即已经被加壳的so 33 | 34 | ## 值得改进的地方 35 | - 先压缩,再加密;那么解密时顺序是相反的,即先解密再解压;那么Cracker只需要Hook解压函数就可以DUMP我们的so;以后有时间的话,需要将加密和压缩顺序调换一下;防止Hook解压函数的DUMP; 36 | - 加入OLLVM,将会使壳强度再提升一个等级; 37 | - 花指令啥的;使IDA不能快捷键"P - Make proc" 38 | - 加入反调试;反调试的加入点很重要; 39 | 40 | ## 效果图 41 | ![avatar](./test.png) 42 | -------------------------------------------------------------------------------- /shell/Extract.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CCint3/LLeGu/c3b4c31709e5759c943d3fa07345555c2c650bdd/shell/Extract.exe -------------------------------------------------------------------------------- /shell/finally.h: -------------------------------------------------------------------------------- 1 | #ifndef TXLEGU_FINALLY_H 2 | #define TXLEGU_FINALLY_H 3 | 4 | #include 5 | 6 | #include "public.h" 7 | #include "include/linker.h" 8 | 9 | #define SwapBytes( Value1, Value2 ) \ 10 | { \ 11 | uint8_t temp = Value1; \ 12 | Value1 = Value2; \ 13 | Value2 = temp; \ 14 | } 15 | 16 | struct Rc4Context { 17 | uint32_t i; 18 | uint32_t j; 19 | uint8_t S[256]; 20 | }; 21 | 22 | struct Key { 23 | uint32_t k1; 24 | uint32_t k2; 25 | }; 26 | 27 | struct Exchange { 28 | uint32_t m0 : 4; 29 | uint32_t m1 : 4; 30 | uint32_t m2 : 4; 31 | uint32_t m3 : 4; 32 | 33 | uint32_t m4 : 4; 34 | uint32_t m5 : 4; 35 | uint32_t m6 : 4; 36 | uint32_t m7 : 4; 37 | }; 38 | 39 | #pragma pack(push) 40 | #pragma pack(1) 41 | 42 | // sizeof = 0x58 43 | struct Header { 44 | ElfW(Addr) min_vaddr; // +00: 最小虚拟地址 希望内存被分布的地址 45 | size_t self_size_; 46 | size_t load_size_; // +04: 所有可加载段 47 | size_t load_seg_num_; // +0A: 可加载段的数量 48 | ElfW(Addr) ARM_exidx; // +50: -A8 v56 49 | size_t ARM_exidx_count; // +54: -A4 v57 50 | ElfW(Addr) bucket_; // +3C: Hash 表的偏移,每一项4字节, load_size_=Header.nbucket_ * 4 51 | ElfW(Addr) strtab_; // +10: .dynstr, load_size_=Header.bucket_ - Header.strtab_ - 8; 因为字符串表下面就是bucket 52 | ElfW(Addr) symtab_; // +14: .dynsym, load_size_=Header.nchain_ * 0x10; nchain_ 表示符号表的个数 53 | ElfW(Addr) plt_rel_; // +40: DT_JMPREL .rel.plt的偏移 54 | ElfW(Addr) rel_; // +4C: DT_REL .rel.dyn的偏移 55 | 56 | size_t plt_rel_count_; // +44: DT_PLTRELSZ .rel.plt的数量,每一项8字节 57 | size_t rel_count_; // +48: DT_RELSZ .rel.dyn的数量,每一项8字节 58 | size_t init_array_count_; // +2A: 因为没有使用,这是一个猜测 59 | size_t fini_array_count_; // +28: 因为没有使用,这是一个猜测 60 | 61 | ElfW(Addr) init_func_; // +18: 初始化函数的偏移 62 | ElfW(Addr) fini_func_; // +20: 因为没有使用,这是一个猜测 63 | 64 | ElfW(Addr) init_array_; // +1C: 初始化函数数组的偏移 65 | ElfW(Addr) fini_array_; // +24: 因为没有使用,这是一个猜测 66 | 67 | size_t needed_count_; // +2C: 在执行解压代码前,需要加载多少个依赖的lib 68 | ElfW(Addr) needed_strtab_; // +30: 指定了需要被加载的library字符串表的偏移 69 | }; 70 | 71 | // sizeof = 0x18 72 | struct LoadSegment { 73 | ElfW(Addr) p_vaddr; // +00: 74 | ElfW(Addr) p_memsz; // +04: 75 | ElfW(Off) p_offset; // +08: 数据距离 Header 的偏移 76 | ElfW(Addr) p_filesz; // +0C: 数据在文件中占用的实际大小 77 | ElfW(Word) p_flags; // +10: 标识了读,写,执行 78 | }; 79 | #pragma pack(pop) 80 | 81 | typedef int (*PFUNC_JNI_OnLoad)(void *vm, void *reserved); 82 | 83 | #ifdef __cplusplus 84 | extern "C" { 85 | #endif 86 | 87 | __attribute__ ((visibility ("hidden"))) extern soinfo *g_self_si; 88 | __attribute__ ((visibility ("hidden"))) extern soinfo *g_parasitic; 89 | __attribute__ ((visibility ("hidden"))) extern p_munmap g_munmap; 90 | #ifdef MYLOG 91 | __attribute__ ((visibility ("hidden"))) extern p___android_log_print g_LogFun; 92 | #endif 93 | 94 | __inline int CACHEFLUSH(ElfW(Addr) start, ElfW(Addr) end) { 95 | const int syscall = 0xF0002; 96 | __asm __volatile ( 97 | "MOV R0, %0 \n" 98 | "MOV R1, %1 \n" 99 | "MOV R7, %2\n" 100 | "MOV R2, #0x0 \n" 101 | "SVC 0x00000000 \n" 102 | : 103 | : "r" (start), "r" (end), "r" (syscall) 104 | : "r0", "r1", "r7"); 105 | } 106 | 107 | 108 | SECTION(".text.00") 109 | __attribute__ ((visibility ("hidden"))) 110 | __inline 111 | void Rc4Initialise(Rc4Context* Context, void const* Key, uint32_t KeySize, uint32_t DropN); 112 | 113 | SECTION(".text.00") 114 | __attribute__ ((visibility ("hidden"))) 115 | __inline 116 | void Rc4Xor(Rc4Context* Context, void const* InBuffer, void* OutBuffer, uint32_t Size); 117 | 118 | SECTION(".text.00") 119 | __attribute__ ((visibility ("hidden"))) 120 | __inline 121 | uint16_t func_global_0001(uint16_t iSeed, uint32_t iMagic1, uint32_t iMagic2, int iCount); 122 | 123 | SECTION(".text.00") 124 | __attribute__ ((visibility ("hidden"))) 125 | __inline 126 | uint32_t func_global_0005(uint32_t iSeed, uint32_t iMagic1, uint32_t iMagic2, uint32_t iMagic3); 127 | 128 | // DT_INIT 129 | SECTION(".text.01") 130 | __attribute__ ((visibility ("hidden"))) 131 | __unused 132 | void _init(); 133 | 134 | // DT_FINI 135 | __attribute__ ((visibility ("hidden"))) 136 | __unused 137 | void _fini(); 138 | 139 | //SECTION(".text.startup.after") 140 | __attribute__ ((visibility ("hidden"))) 141 | void null_func(...); 142 | 143 | SECTION(".text.startup.after") 144 | DLL_LOCAL 145 | INLINE_FUNC 146 | int is_symbol_global_and_defined(const ElfW(Sym) *s); 147 | 148 | SECTION(".text.startup.after") 149 | DLL_LOCAL 150 | INLINE_FUNC 151 | uint32_t symbol_checksum(const char *name); 152 | 153 | SECTION(".text.startup.after") 154 | DLL_LOCAL 155 | INLINE_FUNC 156 | uint32_t elf_hash(const char *name); 157 | 158 | SECTION(".text.startup.after") 159 | DLL_LOCAL 160 | INLINE_FUNC 161 | ElfW(Addr) elf_lookup(uint32_t hash, uint32_t checksum); 162 | 163 | SECTION(".text.startup.after") 164 | DLL_LOCAL 165 | INLINE_FUNC 166 | int get_path(char *buf, soinfo *si); 167 | 168 | SECTION(".text.startup.after") 169 | DLL_LOCAL 170 | INLINE_FUNC 171 | void TEA_Decrypt(uint32_t *key, uint32_t *buf, int size, int round); 172 | 173 | SECTION(".text.startup.after") 174 | DLL_LOCAL 175 | INLINE_FUNC 176 | void fix_symtab(size_t nchain, ElfW(Sym) *symtab, ElfW(Addr) load_bias, ElfW(Addr) self_load_bias); 177 | 178 | SECTION(".text.startup.after") 179 | DLL_LOCAL 180 | INLINE_FUNC 181 | void relocate(soinfo *si, ElfW(Rel) *rels, int rel_cnt, void **lib_buf, int lib_buf_cnt); 182 | 183 | SECTION(".text.startup.after") 184 | DLL_LOCAL 185 | INLINE_FUNC 186 | bool elf_reader_Load(int fd, off64_t file_offset, off64_t file_size, soinfo &si, Header &header); 187 | 188 | SECTION(".text.startup.after") 189 | DLL_LOCAL 190 | INLINE_FUNC 191 | bool link_image(soinfo &si, Header &header); 192 | 193 | SECTION(".text.startup.after") 194 | DLL_LOCAL 195 | INLINE_FUNC 196 | void load_library(const char* name); 197 | 198 | // .text.startup DT_INIT_ARRAY 199 | // 必须隐藏符号 200 | __attribute__ ((visibility ("hidden"))) 201 | CONSTRUCTOR(1) 202 | __unused void load(); 203 | 204 | #ifdef __cplusplus 205 | } 206 | #endif 207 | 208 | #endif //TXLEGU_FINALLY_H 209 | -------------------------------------------------------------------------------- /shell/include/linker.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in 12 | * the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef _LINKER_H_ 30 | #define _LINKER_H_ 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #define MAYBE_MAP_FLAG(x, from, to) (((x) & (from)) ? (to) : 0) 40 | #define PFLAGS_TO_PROT(x) ( \ 41 | MAYBE_MAP_FLAG((x), PF_X, PROT_EXEC) | \ 42 | MAYBE_MAP_FLAG((x), PF_R, PROT_READ) | \ 43 | MAYBE_MAP_FLAG((x), PF_W, PROT_WRITE)) 44 | 45 | #define DL_ERR(fmt, x...) \ 46 | do { \ 47 | __libc_format_buffer(linker_get_error_buffer(), linker_get_error_buffer_size(), fmt, ##x); \ 48 | /* If LD_DEBUG is set high enough, log every dlerror(3) message. */ \ 49 | DEBUG("%s\n", linker_get_error_buffer()); \ 50 | } while (false) 51 | 52 | #define DL_WARN(fmt, x...) \ 53 | do { \ 54 | __libc_format_log(ANDROID_LOG_WARN, "linker", fmt, ##x); \ 55 | __libc_format_fd(2, "WARNING: linker: "); \ 56 | __libc_format_fd(2, fmt, ##x); \ 57 | __libc_format_fd(2, "\n"); \ 58 | } while (false) 59 | 60 | #if defined(__LP64__) 61 | #define ELFW(what) ELF64_ ## what 62 | #else 63 | #define ELFW(what) ELF32_ ## what 64 | #endif 65 | 66 | // mips64 interprets Elf64_Rel structures' r_info field differently. 67 | // bionic (like other C libraries) has macros that assume regular ELF files, 68 | // but the dynamic linker needs to be able to load mips64 ELF files. 69 | #if defined(__mips__) && defined(__LP64__) 70 | #undef ELF64_R_SYM 71 | #undef ELF64_R_TYPE 72 | #undef ELF64_R_INFO 73 | #define ELF64_R_SYM(info) (((info) >> 0) & 0xffffffff) 74 | #define ELF64_R_SSYM(info) (((info) >> 32) & 0xff) 75 | #define ELF64_R_TYPE3(info) (((info) >> 40) & 0xff) 76 | #define ELF64_R_TYPE2(info) (((info) >> 48) & 0xff) 77 | #define ELF64_R_TYPE(info) (((info) >> 56) & 0xff) 78 | #endif 79 | 80 | // Returns the address of the page containing address 'x'. 81 | #define PAGE_START(x) ((x) & PAGE_MASK) 82 | 83 | // Returns the offset of address 'x' in its page. 84 | #define PAGE_OFFSET(x) ((x) & ~PAGE_MASK) 85 | 86 | // Returns the address of the next page after address 'x', unless 'x' is 87 | // itself at the start of a page. 88 | #define PAGE_END(x) PAGE_START((x) + (PAGE_SIZE-1)) 89 | 90 | #define FLAG_LINKED 0x00000001 91 | #define FLAG_EXE 0x00000004 // The main executable 92 | #define FLAG_LINKER 0x00000010 // The linker itself 93 | #define FLAG_GNU_HASH 0x00000040 // uses gnu hash 94 | #define FLAG_NEW_SOINFO 0x40000000 // new soinfo format 95 | 96 | #define SUPPORTED_DT_FLAGS_1 (DF_1_NOW | DF_1_GLOBAL | DF_1_NODELETE) 97 | 98 | #define SOINFO_VERSION 2 99 | 100 | #if defined(__work_around_b_19059885__) 101 | #define SOINFO_NAME_LEN 128 102 | #endif 103 | 104 | typedef void (*linker_function_t)(); 105 | 106 | // Android uses RELA for aarch64 and x86_64. mips64 still uses REL. 107 | #if defined(__aarch64__) || defined(__x86_64__) 108 | #define USE_RELA 1 109 | #endif 110 | 111 | struct soinfo; 112 | 113 | struct soinfo_list_entry_t { 114 | soinfo_list_entry_t* next; 115 | soinfo* element; 116 | }; 117 | 118 | struct soinfo_list_t { 119 | soinfo_list_entry_t *head_; 120 | soinfo_list_entry_t *tail_; 121 | }; 122 | 123 | struct soinfo { 124 | #if defined(__work_around_b_19059885__) 125 | char old_name_[SOINFO_NAME_LEN]; 126 | #endif 127 | 128 | const ElfW(Phdr)* phdr; 129 | size_t phnum; 130 | ElfW(Addr) entry; 131 | ElfW(Addr) base; 132 | size_t size; 133 | 134 | #if defined(__work_around_b_19059885__) 135 | uint32_t unused1; // DO NOT USE, maintained for compatibility. 136 | #endif 137 | 138 | ElfW(Dyn)* dynamic; 139 | 140 | #if defined(__work_around_b_19059885__) 141 | uint32_t unused2; // DO NOT USE, maintained for compatibility 142 | uint32_t unused3; // DO NOT USE, maintained for compatibility 143 | #endif 144 | 145 | soinfo* next; 146 | 147 | uint32_t flags_; 148 | 149 | char* strtab_; 150 | ElfW(Sym)* symtab_; 151 | 152 | size_t nbucket_; 153 | size_t nchain_; 154 | uint32_t* bucket_; 155 | uint32_t* chain_; 156 | 157 | #if defined(__mips__) || !defined(__LP64__) 158 | // This is only used by mips and mips64, but needs to be here for 159 | // all 32-bit architectures to preserve binary compatibility. 160 | ElfW(Addr)** plt_got_; 161 | #endif 162 | 163 | #if defined(USE_RELA) 164 | ElfW(Rela)* plt_rela_; 165 | size_t plt_rela_count_; 166 | 167 | ElfW(Rela)* rela_; 168 | size_t rela_count_; 169 | #else 170 | ElfW(Rel)* plt_rel_; 171 | size_t plt_rel_count_; 172 | 173 | ElfW(Rel)* rel_; 174 | size_t rel_count_; 175 | #endif 176 | 177 | linker_function_t* preinit_array_; 178 | size_t preinit_array_count_; 179 | 180 | linker_function_t* init_array_; 181 | size_t init_array_count_; 182 | linker_function_t* fini_array_; 183 | size_t fini_array_count_; 184 | 185 | linker_function_t init_func_; 186 | linker_function_t fini_func_; 187 | 188 | #if defined(__arm__) 189 | // ARM EABI section used for stack unwinding. 190 | uint32_t* ARM_exidx; 191 | size_t ARM_exidx_count; 192 | #elif defined(__mips__) 193 | uint32_t mips_symtabno_; 194 | uint32_t mips_local_gotno_; 195 | uint32_t mips_gotsym_; 196 | #endif 197 | 198 | size_t ref_count_; 199 | link_map link_map_head; 200 | 201 | bool constructors_called; 202 | 203 | // When you read a virtual address from the ELF file, add this 204 | // value to get the corresponding address in the process' address space. 205 | ElfW(Addr) load_bias; 206 | 207 | #if !defined(__LP64__) 208 | bool has_text_relocations; 209 | #endif 210 | bool has_DT_SYMBOLIC; 211 | 212 | // This part of the structure is only available 213 | // when FLAG_NEW_SOINFO is set in this->p_flags. 214 | uint32_t version_; 215 | 216 | // version >= 0 217 | dev_t st_dev_; 218 | ino_t st_ino_; 219 | 220 | // dependency graph 221 | soinfo_list_t children_; 222 | soinfo_list_t parents_; 223 | 224 | // version >= 1 225 | off64_t file_offset_; 226 | uint32_t rtld_flags_; 227 | uint32_t dt_flags_1_; 228 | size_t strtab_size_; 229 | 230 | // version >= 2 231 | 232 | size_t gnu_nbucket_; 233 | uint32_t* gnu_bucket_; 234 | uint32_t* gnu_chain_; 235 | uint32_t gnu_maskwords_; 236 | uint32_t gnu_shift2_; 237 | ElfW(Addr)* gnu_bloom_filter_; 238 | 239 | soinfo* local_group_root_; 240 | 241 | uint8_t* android_relocs_; 242 | size_t android_relocs_size_; 243 | 244 | const char* soname_; 245 | uint32_t realpath_[3]; 246 | 247 | void* versym_; 248 | 249 | ElfW(Addr) verdef_ptr_; 250 | size_t verdef_cnt_; 251 | 252 | ElfW(Addr) verneed_ptr_; 253 | size_t verneed_cnt_; 254 | 255 | uint32_t target_sdk_version_; 256 | 257 | public: 258 | }; 259 | 260 | 261 | #endif 262 | -------------------------------------------------------------------------------- /shell/include/linker_relocs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __LINKER_RELOCS_H 18 | #define __LINKER_RELOCS_H 19 | 20 | #include 21 | 22 | #define R_GENERIC_NONE 0 // R_*_NONE is always 0 23 | 24 | #if defined (__aarch64__) 25 | 26 | #define R_GENERIC_JUMP_SLOT R_AARCH64_JUMP_SLOT 27 | #define R_GENERIC_GLOB_DAT R_AARCH64_GLOB_DAT 28 | #define R_GENERIC_RELATIVE R_AARCH64_RELATIVE 29 | #define R_GENERIC_IRELATIVE R_AARCH64_IRELATIVE 30 | 31 | #elif defined (__arm__) 32 | 33 | #define R_GENERIC_JUMP_SLOT R_ARM_JUMP_SLOT 34 | #define R_GENERIC_GLOB_DAT R_ARM_GLOB_DAT 35 | #define R_GENERIC_RELATIVE R_ARM_RELATIVE 36 | #define R_GENERIC_IRELATIVE R_ARM_IRELATIVE 37 | 38 | #elif defined (__i386__) 39 | 40 | #define R_GENERIC_JUMP_SLOT R_386_JMP_SLOT 41 | #define R_GENERIC_GLOB_DAT R_386_GLOB_DAT 42 | #define R_GENERIC_RELATIVE R_386_RELATIVE 43 | #define R_GENERIC_IRELATIVE R_386_IRELATIVE 44 | 45 | #elif defined (__x86_64__) 46 | 47 | #define R_GENERIC_JUMP_SLOT R_X86_64_JUMP_SLOT 48 | #define R_GENERIC_GLOB_DAT R_X86_64_GLOB_DAT 49 | #define R_GENERIC_RELATIVE R_X86_64_RELATIVE 50 | #define R_GENERIC_IRELATIVE R_X86_64_IRELATIVE 51 | 52 | #endif 53 | 54 | #endif // __LINKER_RELOCS_H 55 | -------------------------------------------------------------------------------- /shell/include/visibility.h: -------------------------------------------------------------------------------- 1 | #if defined _WIN32 || defined __CYGWIN__ 2 | #ifdef BUILDING_DLL 3 | #ifdef __GNUC__ 4 | #define DLL_PUBLIC __attribute__ ((dllexport)) 5 | #else 6 | #define DLL_PUBLIC __declspec(dllexport) // Note: actually gcc seems to also supports this syntax. 7 | #endif 8 | #else 9 | #ifdef __GNUC__ 10 | #define DLL_PUBLIC __attribute__ ((dllimport)) 11 | #else 12 | #define DLL_PUBLIC __declspec(dllimport) // Note: actually gcc seems to also supports this syntax. 13 | #endif 14 | #endif 15 | #define DLL_LOCAL 16 | #else 17 | #if __GNUC__ >= 4 18 | #define DLL_PUBLIC __attribute__ ((visibility ("default"))) 19 | #define DLL_LOCAL __attribute__ ((visibility ("hidden"))) 20 | #else 21 | #define DLL_PUBLIC 22 | #define DLL_LOCAL 23 | #endif 24 | #endif -------------------------------------------------------------------------------- /shell/ldscript: -------------------------------------------------------------------------------- 1 | PHDRS { 2 | headers PT_PHDR PHDRS FLAGS(4); 3 | text PT_LOAD FILEHDR PHDRS FLAGS(5); 4 | data PT_LOAD FLAGS(6); 5 | dynamic PT_DYNAMIC FLAGS(6); 6 | } 7 | 8 | SECTIONS { 9 | 10 | .rel.dyn SIZEOF_HEADERS : { 11 | *(.rel.dyn) 12 | } :text 13 | 14 | .rel.plt : { 15 | *(.rel.plt) 16 | } :text 17 | 18 | .text : { 19 | *(.text.00) 20 | *(.text.01) 21 | *(.text.startup) 22 | *(.text.startup.*) 23 | *(.text*) 24 | } :text 25 | 26 | .plt : { 27 | *(.plt) 28 | } :text 29 | 30 | .rodata : { 31 | *(.rodata*) 32 | } :text 33 | 34 | .dynamic (.+0xFFF)&0xFFFFF000 : { 35 | *(.dynamic) 36 | } :data :dynamic 37 | 38 | .bss : { 39 | *(.bss) 40 | } :data 41 | 42 | .got : { 43 | *(.got) 44 | } :data 45 | 46 | .data : { 47 | *(.data*) 48 | } :data 49 | 50 | .dynsym ADDR(.data) + SIZEOF(.data) : { 51 | *(.dynsym) 52 | } :data 53 | 54 | .dynstr ADDR(.dynsym) + 0x00000450 : { 55 | *(.dynstr) 56 | } :data 57 | 58 | .hash ADDR(.dynstr) + ((0x0000057B+4)&(-4)) : { 59 | *(.hash) 60 | } :data 61 | 62 | .init_array ADDR(.hash) + 0x00000228 : { 63 | *(.init_array*) 64 | } :data 65 | 66 | .gnu.version : { *(.gnu.version) } :data 67 | .gnu.version_d : { *(.gnu.version_d) } :data 68 | .gnu.version_r : { *(.gnu.version_r) } :data 69 | } 70 | -------------------------------------------------------------------------------- /shell/libGoodBoy.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CCint3/LLeGu/c3b4c31709e5759c943d3fa07345555c2c650bdd/shell/libGoodBoy.so -------------------------------------------------------------------------------- /shell/makefile: -------------------------------------------------------------------------------- 1 | 2 | ifdef app_platform 3 | _APP_PLATFORM := $(app_platform) 4 | else 5 | _APP_PLATFORM := android-21 6 | endif 7 | 8 | ifdef toolchains 9 | _TOOLCHAINS := $(toolchains) 10 | else 11 | _TOOLCHAINS := arm-linux-androideabi 12 | endif 13 | 14 | ifdef toolchains_ver 15 | _TOOLCHAINS_VER := $(toolchains_ver) 16 | else 17 | _TOOLCHAINS_VER := 4.9 18 | endif 19 | 20 | ifdef arch 21 | _ARCH := $(arch) 22 | else 23 | _ARCH := arm 24 | endif 25 | 26 | ifndef ndk_root 27 | $(error "not defined ndk_root") 28 | endif 29 | 30 | _NDK_ROOT := $(ndk_root) 31 | _WORK := $(shell cd)/$(lastword) 32 | 33 | ifeq ("", "$(wildcard $(_NDK_ROOT)/sysroot)") 34 | SYS_INCLUDE := $(_NDK_ROOT)/platforms/$(_APP_PLATFORM)/arch-$(_ARCH)/usr/include 35 | else 36 | SYS_INCLUDE := $(_NDK_ROOT)/sysroot 37 | endif 38 | 39 | CLIBS := $(_NDK_ROOT)/platforms/$(_APP_PLATFORM)/arch-$(_ARCH)/usr/lib 40 | 41 | SRC := ./finally.cpp 42 | 43 | MODULE := shell 44 | 45 | CC := $(_NDK_ROOT)/toolchains/$(_TOOLCHAINS)-$(_TOOLCHAINS_VER)/prebuilt/windows-x86_64/bin/$(_TOOLCHAINS)-gcc 46 | LD := $(_NDK_ROOT)/toolchains/$(_TOOLCHAINS)-$(_TOOLCHAINS_VER)/prebuilt/windows-x86_64/bin/$(_TOOLCHAINS)-ld 47 | 48 | CFLAGS := \ 49 | -s \ 50 | -O2 \ 51 | -std=c11 \ 52 | -nostdlib \ 53 | -march=armv7-a \ 54 | -fno-exceptions \ 55 | -fno-unwind-tables \ 56 | -fno-stack-protector 57 | 58 | INCLUDES := \ 59 | -I$(SYS_INCLUDE) \ 60 | -I$(SYS_INCLUDE)/$(_TOOLCHAINS) 61 | 62 | PRE_DEFINE := -DDYNAMIC_CALL 63 | 64 | 65 | compile: 66 | $(CC) -c -w $(CFLAGS) $(INCLUDES) $(PRE_DEFINE) $(SRC) -o $(MODULE).o 67 | 68 | 69 | link: 70 | $(LD) -shared -T ldscript -l$(CLIBS)/libc.so -l$(CLIBS)/libz.so -l$(CLIBS)/libdl.so -l$(CLIBS)/liblog.so -l$(CLIBS)/libm.so $(MODULE).o -o $(MODULE).so 71 | 72 | -------------------------------------------------------------------------------- /shell/public.h: -------------------------------------------------------------------------------- 1 | #ifndef FINALLY_PUBLIC_H 2 | #define FINALLY_PUBLIC_H 3 | 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #define LOG_TAG "ZWP_SHELL" 11 | 12 | #define MY_TEMP_FAILURE_RETRY(exp) ({ \ 13 | __typeof__(exp) _rc; \ 14 | do { \ 15 | _rc = (exp); \ 16 | } while (_rc == -1); \ 17 | _rc; }) 18 | 19 | #define ELF_HASH_fmodf 0x006D45A6 20 | #define ELF_HASH_strlen 0x07AB92BE 21 | #define ELF_HASH_fopen 0x006D66BE 22 | #define ELF_HASH_fgets 0x006CDCB3 23 | #define ELF_HASH_close 0x006A3695 24 | #define ELF_HASH___system_property_get 0x04CEF454 25 | #define ELF_HASH_memset 0x073C49C4 26 | #define ELF_HASH_malloc 0x07383353 27 | #define ELF_HASH_access 0x06799CA3 28 | #define ELF_HASH_feof 0x0006CC56 29 | #define ELF_HASH_mmap 0x00074380 30 | #define ELF_HASH_open 0x000766BE 31 | #define ELF_HASH_pread 0x00778B74 32 | #define ELF_HASH_sscanf 0x07A99846 33 | #define ELF_HASH_memcpy 0x073C3A79 34 | #define ELF_HASH_free 0x0006D8B5 35 | #define ELF_HASH_fclose 0x06CA3695 36 | #define ELF_HASH_atoi 0x00068B59 37 | #define ELF_HASH_inflateInit2_ 0x09CA2FAF 38 | #define ELF_HASH_inflate 0x004D28D5 39 | #define ELF_HASH_inflateEnd 0x028DA094 40 | #define ELF_HASH___android_log_print 0x0DC5A6F4 41 | #define ELF_HASH_dlsym 0x006B3AFD 42 | #define ELF_HASH_dlopen 0x06B366BE 43 | #define ELF_HASH_pread64 0x078B77E4 44 | #define ELF_HASH_fstat 0x006DAA84 45 | #define ELF_HASH_munmap 0x074C5380 46 | #define ELF_HASH_mprotect 0x0796ACE4 47 | #define ELF_HASH_cacheflush 0x0EBBAB08 48 | 49 | #define CHECKSUM_munmap 0x028E0006 50 | #define CHECKSUM_mprotect 0x036E0008 51 | #define CHECKSUM_cacheflush 0x0416000A 52 | #define CHECKSUM_fmodf 0x020C0005 53 | #define CHECKSUM_strlen 0x02980006 54 | #define CHECKSUM_fopen 0x02180005 55 | #define CHECKSUM_fgets 0x02190005 56 | #define CHECKSUM_close 0x02160005 57 | #define CHECKSUM___system_property_get 0x08E60015 58 | #define CHECKSUM_memset 0x028B0006 59 | #define CHECKSUM_malloc 0x02780006 60 | #define CHECKSUM_access 0x02720006 61 | #define CHECKSUM_feof 0x01A00004 62 | #define CHECKSUM_mmap 0x01AB0004 63 | #define CHECKSUM_open 0x01B20004 64 | #define CHECKSUM_pread 0x020C0005 65 | #define CHECKSUM_sscanf 0x027E0006 66 | #define CHECKSUM_memcpy 0x028B0006 67 | #define CHECKSUM_free 0x01A20004 68 | #define CHECKSUM_fclose 0x027C0006 69 | #define CHECKSUM_atoi 0x01AD0004 70 | #define CHECKSUM_inflateInit2_ 0x0508000D 71 | #define CHECKSUM_inflate 0x02E30007 72 | #define CHECKSUM_inflateEnd 0x03FA000A 73 | #define CHECKSUM___android_log_print 0x07CC0013 74 | #define CHECKSUM_dlsym 0x02290005 75 | #define CHECKSUM_dlopen 0x02820006 76 | #define CHECKSUM_pread64 0x02760007 77 | #define CHECKSUM_fstat 0x02220005 78 | 79 | typedef int (* p_munmap)(void* __addr, size_t __size); 80 | typedef int (* p_mprotect)(void* __addr, size_t __size, int __prot); 81 | typedef int (* p_cacheflush)(long start, long end, long /*flags*/); 82 | typedef float (* p_fmodf)(float x, float y); 83 | typedef size_t (* p_strlen)(const char *s); 84 | typedef int (* p_sscanf)(const char *str, const char *format, ...); 85 | typedef ssize_t (* p_pread)(int fd, void *buf, size_t count, off_t offset); 86 | typedef int (* p_open)(const char* __path, int __flags, ...); 87 | typedef void *(* p_mmap)(void *addr, size_t length, int prot, int flags, int fd, off_t offset); 88 | typedef void *(* p_memset)(void *s, int c, size_t n); 89 | typedef void *(* p_memcpy)(void *dest, const void *src, size_t n); 90 | typedef void *(* p_malloc)(size_t size); 91 | typedef int (* p_inflateInit2_)(z_streamp strm, int windowBits, const char *version, int stream_size); 92 | typedef int (* p_inflateEnd)(z_streamp stream); 93 | typedef int (*p_inflate)(z_streamp strm, int flush); 94 | typedef void (*p_free)(void *ptr); 95 | typedef FILE* (* p_fopen)(const char* __path, const char* __mode); 96 | typedef char *(* p_fgets)(char *s, int n, FILE *stream); 97 | typedef int (* p_feof)(FILE *stream); 98 | typedef void *(* p_dlsym)(void *handle, const char *symbol); 99 | typedef void *(* p_dlopen)(const char *filename, int flags); 100 | typedef int (* p_close)(int fd); 101 | typedef int (* p_atoi)(const char *nptr); 102 | typedef int (* p___system_property_get)(const char *name, char *value); 103 | typedef int (* p___android_log_print)(int prio, const char* tag, const char* fmt, ...); 104 | typedef ssize_t (* p_pread64)(int __fd, void* __buf, size_t __count, off64_t __offset); 105 | typedef int (* p_fstat)(int __fd, struct stat* __buf); 106 | 107 | 108 | #ifdef DYNAMIC_CALL 109 | #define CALL(func_name, ...) (((p_##func_name)elf_lookup(ELF_HASH_##func_name, CHECKSUM_##func_name))(__VA_ARGS__)) 110 | #else 111 | #define CALL(func_name, ...) (func_name(__VA_ARGS__)) 112 | #endif 113 | 114 | #ifdef MYLOG 115 | #define ALOGE(tag, ...) CALL(__android_log_print, 6, tag, __VA_ARGS__) 116 | #else 117 | #define ALOGE(tag, ...) 118 | #endif 119 | 120 | #define DLL_PUBLIC __attribute__ ((visibility ("default"))) 121 | 122 | #define DLL_LOCAL __attribute__ ((visibility ("hidden"))) 123 | //#define DLL_LOCAL 124 | 125 | #define SECTION(name) __attribute__((section(name))) 126 | 127 | //#define INLINE_FUNC 128 | #define INLINE_FUNC __inline 129 | 130 | #define CONSTRUCTOR(n) __attribute__ ((constructor(100+n))) 131 | 132 | #define ICACHE (1 << 0) 133 | #define DCACHE (1 << 1) 134 | #define BCACHE (ICACHE | DCACHE) 135 | #define CACHEABLE 0 136 | #define UNCACHEABLE 1 137 | 138 | #endif //FINALLY_PUBLIC_H 139 | -------------------------------------------------------------------------------- /shell/run_make.bat: -------------------------------------------------------------------------------- 1 | 2 | SET NDKROOT=D:\Tools\Dev\android-ndk-r10e 3 | 4 | SET PATH=%NDKROOT%\prebuilt\windows-x86_64\bin;%NDKROOT%\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\arm-linux-androideabi\bin;%PATH% 5 | 6 | make ndk_root=%NDKROOT% compile 7 | 8 | make ndk_root=%NDKROOT% link 9 | 10 | strip -s -R .gnu* -R .comment -R .note* -R .ARM* shell.so 11 | 12 | del shell.o 13 | pause -------------------------------------------------------------------------------- /shell/settings.h: -------------------------------------------------------------------------------- 1 | #ifndef SETTINGS_H_ 2 | #define SETTINGS_H_ 3 | #define TEA_KEYS_0 0x231EFCB9 4 | #define TEA_KEYS_1 0x154C0345 5 | #define TEA_KEYS_2 0x4D7CE43F 6 | #define TEA_KEYS_3 0x06F5A281 7 | #define MAGIC_01 0xCF264F41 8 | #define TEA_ROUND 0x00000027 9 | #define STRTAB_SIZE 0x0000057B 10 | #define SYMTAB_SIZE 0x00000450 11 | #define HASH_SIZE 0x00000228 12 | #define RANDOM_00 0x2D691897 13 | #define RANDOM_01 0xE5B31228 14 | #define RANDOM_02 0xF972D07F 15 | #define RANDOM_03 0x3EBB118C 16 | #define RANDOM_04 0x7EFA759E 17 | #define RANDOM_05 0xCAD93429 18 | #define RANDOM_06 0x116410C8 19 | #define RANDOM_07 0xF26A887E 20 | #endif 21 | -------------------------------------------------------------------------------- /shell/shell.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CCint3/LLeGu/c3b4c31709e5759c943d3fa07345555c2c650bdd/shell/shell.so -------------------------------------------------------------------------------- /shell/shell_bak.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CCint3/LLeGu/c3b4c31709e5759c943d3fa07345555c2c650bdd/shell/shell_bak.so -------------------------------------------------------------------------------- /test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CCint3/LLeGu/c3b4c31709e5759c943d3fa07345555c2c650bdd/test.png --------------------------------------------------------------------------------