800-mips_pie_debug.patch 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. Fix DT_DEBUG handling on MIPS in musl libc.
  2. With this change gdb will load the symbol files for shared libraries on MIPS too.
  3. This patch was taken from this thread: https://www.openwall.com/lists/musl/2022/01/09/4
  4. --- a/arch/mips/reloc.h
  5. +++ b/arch/mips/reloc.h
  6. @@ -29,6 +29,7 @@
  7. #define NEED_MIPS_GOT_RELOCS 1
  8. #define DT_DEBUG_INDIRECT DT_MIPS_RLD_MAP
  9. +#define DT_DEBUG_INDIRECT_REL DT_MIPS_RLD_MAP_REL
  10. #define ARCH_SYM_REJECT_UND(s) (!((s)->st_other & STO_MIPS_PLT))
  11. #define CRTJMP(pc,sp) __asm__ __volatile__( \
  12. --- a/arch/mips64/reloc.h
  13. +++ b/arch/mips64/reloc.h
  14. @@ -38,6 +38,7 @@
  15. #define NEED_MIPS_GOT_RELOCS 1
  16. #define DT_DEBUG_INDIRECT DT_MIPS_RLD_MAP
  17. +#define DT_DEBUG_INDIRECT_REL DT_MIPS_RLD_MAP_REL
  18. #define ARCH_SYM_REJECT_UND(s) (!((s)->st_other & STO_MIPS_PLT))
  19. #define CRTJMP(pc,sp) __asm__ __volatile__( \
  20. --- a/arch/mipsn32/reloc.h
  21. +++ b/arch/mipsn32/reloc.h
  22. @@ -29,6 +29,7 @@
  23. #define NEED_MIPS_GOT_RELOCS 1
  24. #define DT_DEBUG_INDIRECT DT_MIPS_RLD_MAP
  25. +#define DT_DEBUG_INDIRECT_REL DT_MIPS_RLD_MAP_REL
  26. #define ARCH_SYM_REJECT_UND(s) (!((s)->st_other & STO_MIPS_PLT))
  27. #define CRTJMP(pc,sp) __asm__ __volatile__( \
  28. --- a/ldso/dynlink.c
  29. +++ b/ldso/dynlink.c
  30. @@ -1923,6 +1923,10 @@ void __dls3(size_t *sp, size_t *auxv)
  31. size_t *ptr = (size_t *) app.dynv[i+1];
  32. *ptr = (size_t)&debug;
  33. }
  34. + if (app.dynv[i]==DT_DEBUG_INDIRECT_REL) {
  35. + size_t *ptr = (size_t *)((size_t)&app.dynv[i] + app.dynv[i+1]);
  36. + *ptr = (size_t)&debug;
  37. + }
  38. }
  39. /* This must be done before final relocations, since it calls
  40. --- a/src/internal/dynlink.h
  41. +++ b/src/internal/dynlink.h
  42. @@ -92,6 +92,10 @@ struct fdpic_dummy_loadmap {
  43. #define DT_DEBUG_INDIRECT 0
  44. #endif
  45. +#ifndef DT_DEBUG_INDIRECT_REL
  46. +#define DT_DEBUG_INDIRECT_REL 0
  47. +#endif
  48. +
  49. #define AUX_CNT 32
  50. #define DYN_CNT 32