This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [MIPS] Check info->executable to create DT_MIPS_RLD_MAP

Maciej W. Rozycki wrote:
>  Please make sure 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 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 
for a simple "hello" test.
fu@debian6:~/dev/test$ ./  ./hello-pie-new
Segmentation fault
fu@debian6:~/dev/test$ ./  ./hello-pie-new

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  */
 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 and GNU LD, without
breaking existing systems.  Thanks!


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]