From 02972e7101291409121a085b104d3f7451a2e1d7 Mon Sep 17 00:00:00 2001 From: Junichi Uekawa Date: Wed, 18 Nov 2015 10:18:59 +0900 Subject: Do not depend on host bits to get the right size to write. x86_64 32-bit or 64-bit relocations do not depend on ELF bit size, they are 32-bit or 64-bit respectively. Known compiler that emits such code is nacl-clang which emits R_X86_64_PC32 which should write 32 bits but ended up writing 64 bits. Change-Id: Ibb6b484c0fea6a7e291362148e8ac749d6674529 --- linker/linker.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'linker') diff --git a/linker/linker.cpp b/linker/linker.cpp index bc40cf1..6019c91 100644 --- a/linker/linker.cpp +++ b/linker/linker.cpp @@ -2208,14 +2208,14 @@ bool soinfo::relocate(const VersionTracker& version_tracker, ElfRelIteratorT&& r MARK(rel->r_offset); TRACE_TYPE(RELO, "RELO R_X86_64_32 %08zx <- +%08zx %s", static_cast(reloc), static_cast(sym_addr), sym_name); - *reinterpret_cast(reloc) = sym_addr + addend; + *reinterpret_cast(reloc) = sym_addr + addend; break; case R_X86_64_64: count_relocation(kRelocRelative); MARK(rel->r_offset); TRACE_TYPE(RELO, "RELO R_X86_64_64 %08zx <- +%08zx %s", static_cast(reloc), static_cast(sym_addr), sym_name); - *reinterpret_cast(reloc) = sym_addr + addend; + *reinterpret_cast(reloc) = sym_addr + addend; break; case R_X86_64_PC32: count_relocation(kRelocRelative); @@ -2223,7 +2223,7 @@ bool soinfo::relocate(const VersionTracker& version_tracker, ElfRelIteratorT&& r TRACE_TYPE(RELO, "RELO R_X86_64_PC32 %08zx <- +%08zx (%08zx - %08zx) %s", static_cast(reloc), static_cast(sym_addr - reloc), static_cast(sym_addr), static_cast(reloc), sym_name); - *reinterpret_cast(reloc) = sym_addr + addend - reloc; + *reinterpret_cast(reloc) = sym_addr + addend - reloc; break; #elif defined(__arm__) case R_ARM_ABS32: -- cgit v1.1 From 92595081575c82ace07201a3ea32004eba968c0b Mon Sep 17 00:00:00 2001 From: Marcin Chojnacki Date: Sun, 10 Nov 2013 13:59:47 +0100 Subject: linker: Avoid logcat spam with some blobs Many of pre-kitkat blobs would emit a "text relocations" warning which makes logcat completely unreadable. This commit will hide this warning to prevent it. Change-Id: I8f32b5bbfea33d732320b3ac29da6b0027fbd521 Reworked-by: Caio Oliveira --- linker/linker.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'linker') diff --git a/linker/linker.cpp b/linker/linker.cpp index 6019c91..99c02d8 100644 --- a/linker/linker.cpp +++ b/linker/linker.cpp @@ -3023,7 +3023,11 @@ bool soinfo::link_image(const soinfo_list_t& global_group, const soinfo_list_t& #endif // Make segments writable to allow text relocations to work properly. We will later call // phdr_table_protect_segments() after all of them are applied and all constructors are run. +#if defined(USE_LEGACY_BLOBS) + DEBUG("%s has text relocations. This is wasting memory and prevents " +#else DL_WARN("%s has text relocations. This is wasting memory and prevents " +#endif "security hardening. Please fix.", get_realpath()); if (phdr_table_unprotect_segments(phdr, phnum, load_bias) < 0) { DL_ERR("can't unprotect loadable segments for \"%s\": %s", -- cgit v1.1