Date: Tue, 5 Jan 2016 15:52:17 +0000 (UTC) From: Ed Maste <emaste@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r293201 - head/libexec/rtld-elf Message-ID: <201601051552.u05FqHhe078074@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: emaste Date: Tue Jan 5 15:52:16 2016 New Revision: 293201 URL: https://svnweb.freebsd.org/changeset/base/293201 Log: rtld: populate DT_DEBUG iff DYNAMIC segment is writable MIPS has/had a read-only DYNAMIC segment, and uses an extra level of indirection (through MIPS_RLD_MAP) to locate the debugger rendezvous data. Some linkers (e.g. LLVM's lld) may produce MIPS binaries with a writable DYNAMIC segment, which would allow us to eventually drop a special case. Therefore, instead of hardcoding knowledge that DYNAMIC is not writable on MIPS just check the permissions on the segment. Reviewed by: kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D4791 Modified: head/libexec/rtld-elf/rtld.c Modified: head/libexec/rtld-elf/rtld.c ============================================================================== --- head/libexec/rtld-elf/rtld.c Tue Jan 5 15:50:50 2016 (r293200) +++ head/libexec/rtld-elf/rtld.c Tue Jan 5 15:52:16 2016 (r293201) @@ -1144,13 +1144,13 @@ digest_dynamic1(Obj_Entry *obj, int earl * is mapped read-only. DT_MIPS_RLD_MAP is used instead. */ -#ifndef __mips__ case DT_DEBUG: + if (!obj->writable_dynamic) + break; if (!early) dbg("Filling in DT_DEBUG entry"); ((Elf_Dyn*)dynp)->d_un.d_ptr = (Elf_Addr) &r_debug; break; -#endif case DT_FLAGS: if (dynp->d_un.d_val & DF_ORIGIN) @@ -1331,6 +1331,8 @@ digest_phdr(const Elf_Phdr *phdr, int ph break; case PT_DYNAMIC: + if (ph->p_flags & PROT_WRITE) + obj->writable_dynamic = true; obj->dynamic = (const Elf_Dyn *)(ph->p_vaddr + obj->relocbase); break;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601051552.u05FqHhe078074>