f897461d4fe72bb71854a6d0662de83008caccb7 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. From f897461d4fe72bb71854a6d0662de83008caccb7 Mon Sep 17 00:00:00 2001
  2. From: Rich Felker <dalias@aerifal.cx>
  3. Date: Wed, 18 Jan 2023 10:32:14 -0500
  4. Subject: fix debugger tracking of shared libraries on mips with PIE main
  5. program
  6. mips has its own mechanisms for DT_DEBUG because it makes _DYNAMIC
  7. read-only, and the original mechanism, DT_MIPS_RLD_MAP, was
  8. PIE-incompatible. DT_MIPS_RLD_MAP_REL was added to remedy this, but we
  9. never implemented support for it. add it now using the same idioms for
  10. mips-specific ldso logic.
  11. ---
  12. arch/mips/reloc.h | 1 +
  13. arch/mips64/reloc.h | 1 +
  14. arch/mipsn32/reloc.h | 1 +
  15. ldso/dynlink.c | 4 ++++
  16. src/internal/dynlink.h | 4 ++++
  17. 5 files changed, 11 insertions(+)
  18. diff --git a/arch/mips/reloc.h b/arch/mips/reloc.h
  19. index 88d23639..f4023b16 100644
  20. --- a/arch/mips/reloc.h
  21. +++ b/arch/mips/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. diff --git a/arch/mips64/reloc.h b/arch/mips64/reloc.h
  29. index fdb5edc9..145d8b0b 100644
  30. --- a/arch/mips64/reloc.h
  31. +++ b/arch/mips64/reloc.h
  32. @@ -38,6 +38,7 @@
  33. #define NEED_MIPS_GOT_RELOCS 1
  34. #define DT_DEBUG_INDIRECT DT_MIPS_RLD_MAP
  35. +#define DT_DEBUG_INDIRECT_REL DT_MIPS_RLD_MAP_REL
  36. #define ARCH_SYM_REJECT_UND(s) (!((s)->st_other & STO_MIPS_PLT))
  37. #define CRTJMP(pc,sp) __asm__ __volatile__( \
  38. diff --git a/arch/mipsn32/reloc.h b/arch/mipsn32/reloc.h
  39. index 47c6e591..bf00bd6a 100644
  40. --- a/arch/mipsn32/reloc.h
  41. +++ b/arch/mipsn32/reloc.h
  42. @@ -29,6 +29,7 @@
  43. #define NEED_MIPS_GOT_RELOCS 1
  44. #define DT_DEBUG_INDIRECT DT_MIPS_RLD_MAP
  45. +#define DT_DEBUG_INDIRECT_REL DT_MIPS_RLD_MAP_REL
  46. #define ARCH_SYM_REJECT_UND(s) (!((s)->st_other & STO_MIPS_PLT))
  47. #define CRTJMP(pc,sp) __asm__ __volatile__( \
  48. diff --git a/ldso/dynlink.c b/ldso/dynlink.c
  49. index 09f3b0a8..fde5f346 100644
  50. --- a/ldso/dynlink.c
  51. +++ b/ldso/dynlink.c
  52. @@ -1992,6 +1992,10 @@ void __dls3(size_t *sp, size_t *auxv)
  53. size_t *ptr = (size_t *) app.dynv[i+1];
  54. *ptr = (size_t)&debug;
  55. }
  56. + if (app.dynv[i]==DT_DEBUG_INDIRECT_REL) {
  57. + size_t *ptr = (size_t *)((size_t)&app.dynv[i] + app.dynv[i+1]);
  58. + *ptr = (size_t)&debug;
  59. + }
  60. }
  61. /* This must be done before final relocations, since it calls
  62. diff --git a/src/internal/dynlink.h b/src/internal/dynlink.h
  63. index 830354eb..06f41d09 100644
  64. --- a/src/internal/dynlink.h
  65. +++ b/src/internal/dynlink.h
  66. @@ -92,6 +92,10 @@ struct fdpic_dummy_loadmap {
  67. #define DT_DEBUG_INDIRECT 0
  68. #endif
  69. +#ifndef DT_DEBUG_INDIRECT_REL
  70. +#define DT_DEBUG_INDIRECT_REL 0
  71. +#endif
  72. +
  73. #define AUX_CNT 32
  74. #define DYN_CNT 37
  75. --
  76. cgit v1.2.1