[MIPS] Check info->executable to create DT_MIPS_RLD_MAP
Chao-Ying Fu
Chao-Ying.Fu@imgtec.com
Mon Jun 24 21:04:00 GMT 2013
Maciej W. Rozycki wrote:
> Please make sure ld.so handles it correctly first though as
> I suspect it
> may segfault. The thing is in a PIE the segment containing the word
> pointed to by DT_MIPS_RLD_MAP may get mapped to an arbitrary
> memory area
> and it does not immediately appear to me that ld.so relocates
> the value of
> the DT_MIPS_RLD_MAP tag by the base address, which it has to
> if it wants
> to use it (it may be enough to add l->l_addr to the value
> retrieved in
> ELF_MACHINE_DEBUG_SETUP). But perhaps I'm missing something here.
>
> Maciej
>
As your suggestion, here is a patch that can fix seg fault inside ld.so
for a simple "hello" test.
Ex:
fu@debian6:~/dev/test$ ./ld.so.old ./hello-pie-new
Segmentation fault
fu@debian6:~/dev/test$ ./ld.so.new ./hello-pie-new
Hello
Ex:
Index: mips/dl-machine.h
===================================================================
--- mips.orig/dl-machine.h 2012-12-14 03:50:06.000000000 -0800
+++ mips/dl-machine.h 2013-06-24 13:49:59.622179000 -0700
@@ -69,7 +69,8 @@
with the run-time address of the r_debug structure */
#define ELF_MACHINE_DEBUG_SETUP(l,r) \
do { if ((l)->l_info[DT_MIPS (RLD_MAP)]) \
- *(ElfW(Addr) *)((l)->l_info[DT_MIPS (RLD_MAP)]->d_un.d_ptr) = \
+ *(ElfW(Addr) *)((l)->l_info[DT_MIPS (RLD_MAP)]->d_un.d_ptr \
+ + (l)->l_addr) = \
(ElfW(Addr)) (r); \
} while (0)
The question is how to deploy the changes in ld.so and GNU LD, without
breaking existing systems. Thanks!
Regards,
Chao-ying
More information about the Binutils
mailing list