aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHauke Mehrtens <hmehrtens@maxlinear.com>2023-01-10 19:50:12 +0100
committerHauke Mehrtens <hauke@hauke-m.de>2023-01-22 02:00:35 +0100
commitfcdd407e8e16b90e1995789ba217be5591a88d2f (patch)
treeac9fcbfa9a2c68d4f7c9d1c243d8f59f81dcb365
parent6a3816efb736b4ff8b4c7ec725522d275afd7496 (diff)
downloadupstream-fcdd407e8e16b90e1995789ba217be5591a88d2f.tar.gz
upstream-fcdd407e8e16b90e1995789ba217be5591a88d2f.tar.bz2
upstream-fcdd407e8e16b90e1995789ba217be5591a88d2f.zip
toolchain: musl: Fix symbol loading in gdb
Fix DT_DEBUG handling on MIPS in musl libc. With this change gdb will load the symbol files for shared libraries on MIPS too. This patch was taken from this thread: https://www.openwall.com/lists/musl/2022/01/09/4 Signed-off-by: Hauke Mehrtens <hmehrtens@maxlinear.com>
-rw-r--r--toolchain/musl/patches/800-mips_pie_debug.patch61
1 files changed, 61 insertions, 0 deletions
diff --git a/toolchain/musl/patches/800-mips_pie_debug.patch b/toolchain/musl/patches/800-mips_pie_debug.patch
new file mode 100644
index 0000000000..80fe15e841
--- /dev/null
+++ b/toolchain/musl/patches/800-mips_pie_debug.patch
@@ -0,0 +1,61 @@
+Fix DT_DEBUG handling on MIPS in musl libc.
+With this change gdb will load the symbol files for shared libraries on MIPS too.
+
+This patch was taken from this thread: https://www.openwall.com/lists/musl/2022/01/09/4
+
+--- a/arch/mips/reloc.h
++++ b/arch/mips/reloc.h
+@@ -29,6 +29,7 @@
+
+ #define NEED_MIPS_GOT_RELOCS 1
+ #define DT_DEBUG_INDIRECT DT_MIPS_RLD_MAP
++#define DT_DEBUG_INDIRECT_REL DT_MIPS_RLD_MAP_REL
+ #define ARCH_SYM_REJECT_UND(s) (!((s)->st_other & STO_MIPS_PLT))
+
+ #define CRTJMP(pc,sp) __asm__ __volatile__( \
+--- a/arch/mips64/reloc.h
++++ b/arch/mips64/reloc.h
+@@ -38,6 +38,7 @@
+
+ #define NEED_MIPS_GOT_RELOCS 1
+ #define DT_DEBUG_INDIRECT DT_MIPS_RLD_MAP
++#define DT_DEBUG_INDIRECT_REL DT_MIPS_RLD_MAP_REL
+ #define ARCH_SYM_REJECT_UND(s) (!((s)->st_other & STO_MIPS_PLT))
+
+ #define CRTJMP(pc,sp) __asm__ __volatile__( \
+--- a/arch/mipsn32/reloc.h
++++ b/arch/mipsn32/reloc.h
+@@ -29,6 +29,7 @@
+
+ #define NEED_MIPS_GOT_RELOCS 1
+ #define DT_DEBUG_INDIRECT DT_MIPS_RLD_MAP
++#define DT_DEBUG_INDIRECT_REL DT_MIPS_RLD_MAP_REL
+ #define ARCH_SYM_REJECT_UND(s) (!((s)->st_other & STO_MIPS_PLT))
+
+ #define CRTJMP(pc,sp) __asm__ __volatile__( \
+--- a/ldso/dynlink.c
++++ b/ldso/dynlink.c
+@@ -1923,6 +1923,10 @@ void __dls3(size_t *sp, size_t *auxv)
+ size_t *ptr = (size_t *) app.dynv[i+1];
+ *ptr = (size_t)&debug;
+ }
++ if (app.dynv[i]==DT_DEBUG_INDIRECT_REL) {
++ size_t *ptr = (size_t *)((size_t)&app.dynv[i] + app.dynv[i+1]);
++ *ptr = (size_t)&debug;
++ }
+ }
+
+ /* This must be done before final relocations, since it calls
+--- a/src/internal/dynlink.h
++++ b/src/internal/dynlink.h
+@@ -92,6 +92,10 @@ struct fdpic_dummy_loadmap {
+ #define DT_DEBUG_INDIRECT 0
+ #endif
+
++#ifndef DT_DEBUG_INDIRECT_REL
++#define DT_DEBUG_INDIRECT_REL 0
++#endif
++
+ #define AUX_CNT 32
+ #define DYN_CNT 32
+