From e1b42616a2079827de7bfd58670cb8ec0d771888 Mon Sep 17 00:00:00 2001 From: John Reiser Date: Tue, 26 May 2020 14:49:25 -0700 Subject: [PATCH] workaround: MIPS.r3000 early uClibc forgot memset(,0,) of local array ldso/ldso/ldso.c: _dl_get_ready_to_run() _dl_memset(app_tpnt, 0, sizeof(*app_tpnt)); modified: stub/src/mipsel.r3000-linux.elf-fold.S modified: stub/mips.r3000-linux.elf-fold.h modified: stub/mipsel.r3000-linux.elf-fold.h --- src/stub/mips.r3000-linux.elf-fold.h | 6 +++--- src/stub/mipsel.r3000-linux.elf-fold.h | 6 +++--- src/stub/src/mipsel.r3000-linux.elf-fold.S | 9 ++++++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/stub/mips.r3000-linux.elf-fold.h b/src/stub/mips.r3000-linux.elf-fold.h index 3d7a92be..7875ed51 100644 --- a/src/stub/mips.r3000-linux.elf-fold.h +++ b/src/stub/mips.r3000-linux.elf-fold.h @@ -32,8 +32,8 @@ #define STUB_MIPS_R3000_LINUX_ELF_FOLD_SIZE 2892 -#define STUB_MIPS_R3000_LINUX_ELF_FOLD_ADLER32 0xa2e27f2f -#define STUB_MIPS_R3000_LINUX_ELF_FOLD_CRC32 0x719a099a +#define STUB_MIPS_R3000_LINUX_ELF_FOLD_ADLER32 0x40e97fad +#define STUB_MIPS_R3000_LINUX_ELF_FOLD_CRC32 0x749d56f7 unsigned char stub_mips_r3000_linux_elf_fold[2892] = { /* 0x0000 */ 127, 69, 76, 70, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -66,7 +66,7 @@ unsigned char stub_mips_r3000_linux_elf_fold[2892] = { /* 0x01b0 */ 175,169, 0, 20, 36, 7, 0, 2, 36, 6, 0, 1, 0, 28, 40, 34, /* 0x01c0 */ 0, 0, 32, 33, 36, 2, 15,250, 0, 0, 0, 12,143,164, 0, 16, /* 0x01d0 */ 36, 2, 15,166, 0, 0, 0, 12,143,165, 0, 28,143,164, 0, 24, -/* 0x01e0 */ 39,189, 0, 32, 3,160, 8, 33, 39,189,254, 0, 39,189, 0, 4, +/* 0x01e0 */ 39,189, 0, 32, 3,160, 8, 33, 39,189,252,128, 39,189, 0, 4, /* 0x01f0 */ 23,161,255,254,175,160,255,252,142,129,255,252, 0, 0, 0, 0, /* 0x0200 */ 16, 32, 0, 3, 0, 0, 0, 0, 0, 32, 0, 8, 36, 2, 15,251, /* 0x0210 */ 3,192, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/src/stub/mipsel.r3000-linux.elf-fold.h b/src/stub/mipsel.r3000-linux.elf-fold.h index d4613655..761c9172 100644 --- a/src/stub/mipsel.r3000-linux.elf-fold.h +++ b/src/stub/mipsel.r3000-linux.elf-fold.h @@ -32,8 +32,8 @@ #define STUB_MIPSEL_R3000_LINUX_ELF_FOLD_SIZE 2892 -#define STUB_MIPSEL_R3000_LINUX_ELF_FOLD_ADLER32 0xe89d7f2e -#define STUB_MIPSEL_R3000_LINUX_ELF_FOLD_CRC32 0x7f43d7f9 +#define STUB_MIPSEL_R3000_LINUX_ELF_FOLD_ADLER32 0x88227fac +#define STUB_MIPSEL_R3000_LINUX_ELF_FOLD_CRC32 0x708b39a1 unsigned char stub_mipsel_r3000_linux_elf_fold[2892] = { /* 0x0000 */ 127, 69, 76, 70, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -66,7 +66,7 @@ unsigned char stub_mipsel_r3000_linux_elf_fold[2892] = { /* 0x01b0 */ 20, 0,169,175, 2, 0, 7, 36, 1, 0, 6, 36, 34, 40, 28, 0, /* 0x01c0 */ 33, 32, 0, 0,250, 15, 2, 36, 12, 0, 0, 0, 16, 0,164,143, /* 0x01d0 */ 166, 15, 2, 36, 12, 0, 0, 0, 28, 0,165,143, 24, 0,164,143, -/* 0x01e0 */ 32, 0,189, 39, 33, 8,160, 3, 0,254,189, 39, 4, 0,189, 39, +/* 0x01e0 */ 32, 0,189, 39, 33, 8,160, 3,128,252,189, 39, 4, 0,189, 39, /* 0x01f0 */ 254,255,161, 23,252,255,160,175,252,255,129,142, 0, 0, 0, 0, /* 0x0200 */ 3, 0, 32, 16, 0, 0, 0, 0, 8, 0, 32, 0,251, 15, 2, 36, /* 0x0210 */ 8, 0,192, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/src/stub/src/mipsel.r3000-linux.elf-fold.S b/src/stub/src/mipsel.r3000-linux.elf-fold.S index 2c5d3034..ecbbf3e1 100644 --- a/src/stub/src/mipsel.r3000-linux.elf-fold.S +++ b/src/stub/src/mipsel.r3000-linux.elf-fold.S @@ -220,9 +220,16 @@ p_vaddr= 4+4 /* Workaround suspected glibc bug: elf/rtld.c assumes uninit local is zero. 2007-11-24 openembedded.org mipsel-linux 2.6.12.6/glibc 2.3.2 + + Also early uClibc/ldso/ldso/ldso.c function _dl_get_ready_to_run() forgot + _dl_memset(app_tpnt, 0, sizeof(*app_tpnt)); + leaving garbage in + if (app_tpnt->dynamic_info[DT_TEXTREL]) { + leading to SIGSEGV. Fixed in [git blame:] +27d501fdbf (Denis Vlasenko 2009-01-10 21:02:48 +0000 */ move tmp,sp - addiu sp, -512 # estimated stack bound of upx_main and below + addiu sp, -0x380 # estimated stack bound of upx_main and below 0: addiu sp,NBPW bne sp,tmp,0b