From 688157295f55edbfddb2277e7bdf5635f6be591a Mon Sep 17 00:00:00 2001 From: Raghu Gandham Date: Thu, 18 Dec 2014 19:12:19 -0800 Subject: [PATCH] Add support for DT_MIPS_RLD_MAP2 tag. Position Independent Executables cannot communicate with GDB using DT_MIPS_RLD_TAG. Hence a new tag DT_MIPS_RLD_MAP2 got introduced to fix the issue. Change-Id: I77ce3faf1ef2e121003b804ecd291abb25cfbb56 Signed-off-by: Nikola Veljkovic --- libc/arch-mips/include/machine/elf_machdep.h | 1 + linker/linker.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/libc/arch-mips/include/machine/elf_machdep.h b/libc/arch-mips/include/machine/elf_machdep.h index d27d43183..0aacedfe8 100644 --- a/libc/arch-mips/include/machine/elf_machdep.h +++ b/libc/arch-mips/include/machine/elf_machdep.h @@ -121,6 +121,7 @@ #define DT_MIPS_GOTSYM 0x70000013 /* first dynamic sym in got */ #define DT_MIPS_HIPAGENO 0x70000014 #define DT_MIPS_RLD_MAP 0x70000016 /* address of loader map */ +#define DT_MIPS_RLD_MAP2 0x70000035 /* offset of loader map, used for PIE */ /* * ELF Flags diff --git a/linker/linker.cpp b/linker/linker.cpp index 34099316f..babefeb3c 100644 --- a/linker/linker.cpp +++ b/linker/linker.cpp @@ -2402,6 +2402,13 @@ bool soinfo::prelink_image() { *dp = &_r_debug; } break; + case DT_MIPS_RLD_MAP2: + // Set the DT_MIPS_RLD_MAP2 entry to the address of _r_debug for GDB. + { + r_debug** dp = reinterpret_cast(reinterpret_cast(d) + d->d_un.d_val); + *dp = &_r_debug; + } + break; case DT_MIPS_RLD_VERSION: case DT_MIPS_FLAGS: