From 34d65ba29238b9aed9daead7ab0d9ac6220557fa Mon Sep 17 00:00:00 2001 From: John Reiser Date: Mon, 12 Nov 2007 09:11:16 -0800 Subject: [PATCH] ET_DYN -fPIE position-independent executables --- src/stub/amd64-linux.elf-fold.h | 201 ++++++++++++++-------------- src/stub/src/amd64-linux.elf-fold.S | 7 +- src/stub/src/amd64-linux.elf-main.c | 16 ++- 3 files changed, 120 insertions(+), 104 deletions(-) diff --git a/src/stub/amd64-linux.elf-fold.h b/src/stub/amd64-linux.elf-fold.h index 24e8ab1b..b99d9a5d 100644 --- a/src/stub/amd64-linux.elf-fold.h +++ b/src/stub/amd64-linux.elf-fold.h @@ -1,5 +1,5 @@ /* amd64-linux.elf-fold.h - created from amd64-linux.elf-fold.bin, 1775 (0x6ef) bytes + created from amd64-linux.elf-fold.bin, 1853 (0x73d) bytes This file is part of the UPX executable compressor. @@ -28,20 +28,20 @@ */ -#define STUB_AMD64_LINUX_ELF_FOLD_SIZE 1775 -#define STUB_AMD64_LINUX_ELF_FOLD_ADLER32 0x8871a9cc -#define STUB_AMD64_LINUX_ELF_FOLD_CRC32 0x5856b332 +#define STUB_AMD64_LINUX_ELF_FOLD_SIZE 1853 +#define STUB_AMD64_LINUX_ELF_FOLD_ADLER32 0xdbabc410 +#define STUB_AMD64_LINUX_ELF_FOLD_CRC32 0x7bbf98c2 -unsigned char stub_amd64_linux_elf_fold[1775] = { +unsigned char stub_amd64_linux_elf_fold[1853] = { 127, 69, 76, 70, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 0 */ 2, 0, 62, 0, 1, 0, 0, 0,188, 0, 16, 0, 0, 0, 0, 0, /* 0x 10 */ 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 20 */ 0, 0, 0, 0, 64, 0, 56, 0, 2, 0, 0, 0, 0, 0, 0, 0, /* 0x 30 */ 1, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 40 */ 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, /* 0x 50 */ -239, 6, 0, 0, 0, 0, 0, 0,240, 6, 0, 0, 0, 0, 0, 0, /* 0x 60 */ + 61, 7, 0, 0, 0, 0, 0, 0, 64, 7, 0, 0, 0, 0, 0, 0, /* 0x 60 */ 0, 0, 16, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, /* 0x 70 */ -239, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 80 */ + 61, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 80 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 90 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, /* 0x a0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,232, 95, 0, 0, /* 0x b0 */ @@ -53,95 +53,100 @@ unsigned char stub_amd64_linux_elf_fold[1775] = { 131,199, 1, 72,255,201,117,217,235, 5, 72,255,201,117,190,195, /* 0x 110 */ 65, 89, 72,137,230, 72,141,190,240,239,255,255, 72,137,252, 72, /* 0x 120 */ 131, 62, 0, 72,165,117,248, 72,137,250, 72,171, 72,131, 62, 0, /* 0x 130 */ - 72,165,117,248, 87, 72,131, 62, 0, 72,165, 72,165,117,246, 72, /* 0x 140 */ -137, 58,184, 32, 32, 32, 61,171,186, 0, 16, 0, 0, 72,137,254, /* 0x 150 */ - 76,137,207,106, 89, 88, 15, 5,133,192,120, 4,198, 4, 6, 0, /* 0x 160 */ - 73,131,193, 15, 89, 94, 95, 72,129,236, 0, 8, 0, 0, 72,137, /* 0x 170 */ -226, 73,137,232,232, 68, 4, 0, 0, 72,129,196, 0, 8, 0, 0, /* 0x 180 */ - 94, 95, 89, 80,106, 11, 88,255,225,176, 11,235, 13,176, 10,235, /* 0x 190 */ - 9,176, 12,235, 5,176, 9, 73,137,202, 15,182,192, 15, 5, 72, /* 0x 1a0 */ - 61, 0,240,255,255,114, 4, 72,131,200,255,195,176, 0,235,234, /* 0x 1b0 */ -176, 2,235,230,176, 3,235,226,176, 60,235,222, 81, 72, 57, 23, /* 0x 1c0 */ - 76,139, 71, 8, 72,141, 74,255,115, 10,191,127, 0, 0, 0,232, /* 0x 1d0 */ -228,255,255,255, 72,131,249,255,116, 17, 65, 15,182, 0, 72,255, /* 0x 1e0 */ -201, 73,255,192,136, 6, 72,255,198,235,233, 72, 1, 87, 8, 72, /* 0x 1f0 */ - 41, 23, 88,195, 65, 85, 73,137,213, 65, 84, 73,137,204, 85, 72, /* 0x 200 */ -137,253, 83, 72,137,243, 72,131,236, 40, 72,131, 62, 0, 15,132, /* 0x 210 */ -226, 0, 0, 0, 72,141,116, 36, 16,186, 12, 0, 0, 0, 72,137, /* 0x 220 */ -239,232,150,255,255,255,139, 84, 36, 16,139,116, 36, 20,133,210, /* 0x 230 */ -117, 21,129,254, 85, 80, 88, 33,117, 17, 72,131,125, 0, 0, 15, /* 0x 240 */ -132,177, 0, 0, 0,235, 4,133,246,117, 10,191,127, 0, 0, 0, /* 0x 250 */ -232, 99,255,255,255, 57,214,119,242,137,208, 72, 59, 3,119,235, /* 0x 260 */ - 57,214, 72,139, 67, 8,115,104,137, 84, 36, 12, 72,139,125, 8, /* 0x 270 */ - 72,141, 76, 36, 12, 68,139, 68, 36, 24, 72,137,194, 65,255,213, /* 0x 280 */ -133,192,117,199,139,116, 36, 12, 59,116, 36, 16,117,189, 15,182, /* 0x 290 */ - 76, 36, 25,132,201, 15,149,194, 49,192, 77,133,228, 15,149,192, /* 0x 2a0 */ -133,194,116, 30,129,254, 0, 2, 0, 0,119, 7,137,240, 72, 57, /* 0x 2b0 */ - 3,117, 15, 15,182, 84, 36, 26, 15,182,201, 72,139,123, 8, 65, /* 0x 2c0 */ -255,212,139, 68, 36, 20, 72, 1, 69, 8, 72, 41, 69, 0,235, 13, /* 0x 2d0 */ -137,242, 72,137,239, 72,137,198,232,223,254,255,255,139, 84, 36, /* 0x 2e0 */ - 16, 72,139, 3, 72, 1, 83, 8, 72, 41,208, 72,133,192, 72,137, /* 0x 2f0 */ - 3,233, 24,255,255,255, 72,131,196, 40, 91, 93, 65, 92, 65, 93, /* 0x 300 */ -195, 72,133,255, 73,137,208,116, 41, 72,139, 7,137,241, 72, 57, /* 0x 310 */ -200,116, 17, 72,255,200, 15,148,194, 49,192,133,246, 15,149,192, /* 0x 320 */ -133,194,116, 8, 72,137, 15, 76,137, 71, 8,195, 72,131,199, 16, /* 0x 330 */ -235,215,195, 65, 87,184, 0, 0, 0, 0, 73,137,255, 65, 86, 65, /* 0x 340 */ - 85, 65, 84, 73,137,252, 85, 83, 72,131,236,104, 76, 3,103, 32, /* 0x 350 */ -102,131,127, 16, 3,137, 84, 36, 60, 15,183, 87, 56, 72,137, 76, /* 0x 360 */ - 36, 48,185, 16, 0, 0, 0, 72,137,116, 36, 64, 76,137, 68, 36, /* 0x 370 */ - 40, 76,137, 76, 36, 32, 15, 68,200, 76,137,230, 72,131,205,255, /* 0x 380 */ - 49,219,131,193, 34,255,202,120, 33,131, 62, 1,117, 22, 72,139, /* 0x 390 */ - 70, 16, 72, 57,232, 72, 15, 66,232, 72, 3, 70, 40, 72, 57,195, /* 0x 3a0 */ - 72, 15, 66,216, 72,131,198, 56,235,219, 72,129,229, 0,240,255, /* 0x 3b0 */ -255, 49,210, 69, 49,201, 72, 41,235, 65,131,200,255, 72,137,239, /* 0x 3c0 */ - 72,129,195,255, 15, 0, 0, 72,129,227, 0,240,255,255, 72,137, /* 0x 3d0 */ -222,232,191,253,255,255, 72,141, 20, 24, 72, 41,232,102, 65,131, /* 0x 3e0 */ -127, 56, 0, 72,137, 68, 36, 24,199, 68, 36, 20, 0, 0, 0, 0, /* 0x 3f0 */ - 72,137, 84, 36, 72, 15,132,139, 1, 0, 0, 72,131,124, 36, 64, /* 0x 400 */ - 0,116, 37, 65,131, 60, 36, 6,117, 30, 72,139, 84, 36, 24, 73, /* 0x 410 */ - 3, 84, 36, 16,190, 3, 0, 0, 0, 72,139,124, 36, 48,232,222, /* 0x 420 */ -254,255,255,233, 71, 1, 0, 0, 65,131, 60, 36, 1, 15,133, 60, /* 0x 430 */ - 1, 0, 0, 72,139, 68, 36, 24, 73, 3, 68, 36, 16, 65,190, 64, /* 0x 440 */ - 98, 81,115, 65,139, 76, 36, 4, 65,131,200,255, 73,139, 84, 36, /* 0x 450 */ - 32, 72,137,197, 72,137, 68, 36, 88, 73,139, 68, 36, 40,131,225, /* 0x 460 */ - 7, 72,137,235, 72,137, 84, 36, 80,193,225, 2,129,227,255, 15, /* 0x 470 */ - 0, 0, 72, 1,232, 65,211,238, 72, 41,221, 72,137, 68, 36, 8, /* 0x 480 */ - 73,139, 68, 36, 8, 65,131,230, 7, 76,141, 44, 26,185, 50, 0, /* 0x 490 */ - 0, 0, 72, 41,216, 72,131,124, 36, 64, 0,117, 7, 68,139, 68, /* 0x 4a0 */ - 36, 60,177, 18, 68,137,242, 73,137,193, 76,137,238,131,202, 2, /* 0x 4b0 */ - 72,131,124, 36, 64, 0, 72,137,239, 65, 15, 68,214,232,211,252, /* 0x 4c0 */ -255,255, 72, 57,197,117,105, 72,131,124, 36, 64, 0,116, 25, 72, /* 0x 4d0 */ -139, 76, 36, 32, 72,139, 84, 36, 40, 72,141,116, 36, 80, 72,139, /* 0x 4e0 */ -124, 36, 64,232, 12,253,255,255, 76,137,235, 72,247,219,129,227, /* 0x 4f0 */ -255, 15, 0, 0, 65,246,198, 2,116, 13, 74,141,124, 45, 0, 49, /* 0x 500 */ -192, 72,137,217,252,243,170, 72,131,124, 36, 64, 0,116, 43, 73, /* 0x 510 */ -131,124, 36, 8, 0,117, 7,199, 69, 12, 15, 5,195,144, 68,137, /* 0x 520 */ -242, 76,137,238, 72,137,239,232, 97,252,255,255,133,192,116, 10, /* 0x 530 */ -191,127, 0, 0, 0,232,126,252,255,255, 73,141, 68, 29, 0, 72, /* 0x 540 */ - 1,197, 72, 59,108, 36, 8,115, 38, 72, 41,108, 36, 8, 69, 49, /* 0x 550 */ -201, 65,131,200,255, 72,139,116, 36, 8,185, 50, 0, 0, 0, 68, /* 0x 560 */ -137,242, 72,137,239,232, 43,252,255,255, 72, 57,197,117,193,255, /* 0x 570 */ - 68, 36, 20, 65, 15,183, 71, 56, 73,131,196, 56, 57, 68, 36, 20, /* 0x 580 */ - 15,140,117,254,255,255, 72,131,124, 36, 64, 0,116, 18,102, 65, /* 0x 590 */ -131,127, 16, 3,116, 10, 72,139,124, 36, 72,232,241,251,255,255, /* 0x 5a0 */ - 73,139, 71, 24, 72, 1, 68, 36, 24, 72,139, 68, 36, 24, 72,131, /* 0x 5b0 */ -196,104, 91, 93, 65, 92, 65, 93, 65, 94, 65, 95,195, 65, 86, 76, /* 0x 5c0 */ -141,114, 64, 65, 85, 77,137,205, 65, 84, 77,137,196, 85, 72,137, /* 0x 5d0 */ -213, 83, 72,137,203, 49,201, 72,131,236, 48,139, 7, 72,137, 52, /* 0x 5e0 */ - 36, 72,137,116, 36, 16, 72,141,116, 36, 32, 72,137, 84, 36, 40, /* 0x 5f0 */ - 72,137,124, 36, 8, 76,137,194, 72,137,124, 36, 24, 72,137,231, /* 0x 600 */ - 72,137, 68, 36, 32,232,234,251,255,255, 73,139, 86, 16,190, 3, /* 0x 610 */ - 0, 0, 0, 72,137,223, 72,131,194, 64,232,226,252,255,255, 72, /* 0x 620 */ - 15,183, 85, 56,190, 5, 0, 0, 0, 72,137,223,232,208,252,255, /* 0x 630 */ -255, 72,139, 85, 24,190, 9, 0, 0, 0, 72,137,223,232,191,252, /* 0x 640 */ -255,255, 72,141,116, 36, 16, 77,137,233, 77,137,224, 49,210, 72, /* 0x 650 */ -137,217, 72,137,239,232,217,252,255,255, 69, 49,237,102,131,125, /* 0x 660 */ - 56, 0, 73,137,196,116,104, 65,131, 62, 3,117, 82, 73,139,126, /* 0x 670 */ - 16, 49,210, 49,246,232, 54,251,255,255,133,192,137,195,120, 23, /* 0x 680 */ -186, 0, 4, 0, 0, 72,137,238,137,199,232, 29,251,255,255, 72, /* 0x 690 */ - 61, 0, 4, 0, 0,116, 10,191,127, 0, 0, 0,232, 23,251,255, /* 0x 6a0 */ -255, 72,137,239, 69, 49,201, 69, 49,192, 49,201,137,218, 49,246, /* 0x 6b0 */ -232,126,252,255,255,137,223, 73,137,196,232,245,250,255,255, 15, /* 0x 6c0 */ -183, 69, 56, 65,255,197, 73,131,198, 56, 65, 57,197,124,152, 72, /* 0x 6d0 */ -131,196, 48, 76,137,224, 91, 93, 65, 92, 65, 93, 65, 94,195 /* 0x 6e0 */ + 72,165,117,248, 87, 72,131, 62, 0, 72,165, 72,165,117,246, 76, /* 0x 140 */ +141,127,248, 72,137, 58,184, 32, 32, 32, 61,171,186, 0, 16, 0, /* 0x 150 */ + 0, 72,137,254, 76,137,207,106, 89, 88, 15, 5,133,192,120, 4, /* 0x 160 */ +198, 4, 6, 0, 73,131,193, 15, 89, 94, 95, 72,129,236, 0, 8, /* 0x 170 */ + 0, 0, 72,137,226, 73,137,232,106, 0,232,117, 4, 0, 0, 90, /* 0x 180 */ + 72,129,196, 0, 8, 0, 0, 94, 95, 89, 80,106, 11, 88, 65,255, /* 0x 190 */ + 39,255,225,176, 11,235, 13,176, 10,235, 9,176, 12,235, 5,176, /* 0x 1a0 */ + 9, 73,137,202, 15,182,192, 15, 5, 72, 61, 0,240,255,255,114, /* 0x 1b0 */ + 4, 72,131,200,255,195,176, 0,235,234,176, 2,235,230,176, 3, /* 0x 1c0 */ +235,226,176, 60,235,222, 0, 0, 81, 72, 57, 23, 76,139, 71, 8, /* 0x 1d0 */ + 72,141, 74,255,115, 10,191,127, 0, 0, 0,232,226,255,255,255, /* 0x 1e0 */ + 72,131,249,255,116, 17, 65, 15,182, 0, 72,255,201, 73,255,192, /* 0x 1f0 */ +136, 6, 72,255,198,235,233, 72, 1, 87, 8, 72, 41, 23, 88,195, /* 0x 200 */ + 65, 85, 73,137,213, 65, 84, 73,137,204, 85, 72,137,253, 83, 72, /* 0x 210 */ +137,243, 72,131,236, 40, 72,131, 62, 0, 15,132,226, 0, 0, 0, /* 0x 220 */ + 72,141,116, 36, 16,186, 12, 0, 0, 0, 72,137,239,232,150,255, /* 0x 230 */ +255,255,139, 84, 36, 16,139,116, 36, 20,133,210,117, 21,129,254, /* 0x 240 */ + 85, 80, 88, 33,117, 17, 72,131,125, 0, 0, 15,132,177, 0, 0, /* 0x 250 */ + 0,235, 4,133,246,117, 10,191,127, 0, 0, 0,232, 97,255,255, /* 0x 260 */ +255, 57,214,119,242,137,208, 72, 59, 3,119,235, 57,214, 72,139, /* 0x 270 */ + 67, 8,115,104,137, 84, 36, 12, 72,139,125, 8, 72,141, 76, 36, /* 0x 280 */ + 12, 68,139, 68, 36, 24, 72,137,194, 65,255,213,133,192,117,199, /* 0x 290 */ +139,116, 36, 12, 59,116, 36, 16,117,189, 15,182, 76, 36, 25,132, /* 0x 2a0 */ +201, 15,149,194, 49,192, 77,133,228, 15,149,192,133,194,116, 30, /* 0x 2b0 */ +129,254, 0, 2, 0, 0,119, 7,137,240, 72, 57, 3,117, 15, 15, /* 0x 2c0 */ +182, 84, 36, 26, 15,182,201, 72,139,123, 8, 65,255,212,139, 68, /* 0x 2d0 */ + 36, 20, 72, 1, 69, 8, 72, 41, 69, 0,235, 13,137,242, 72,137, /* 0x 2e0 */ +239, 72,137,198,232,223,254,255,255,139, 84, 36, 16, 72,139, 3, /* 0x 2f0 */ + 72, 1, 83, 8, 72, 41,208, 72,133,192, 72,137, 3,233, 24,255, /* 0x 300 */ +255,255, 72,131,196, 40, 91, 93, 65, 92, 65, 93,195, 72,133,255, /* 0x 310 */ + 73,137,208,116, 41, 72,139, 7,137,241, 72, 57,200,116, 17, 72, /* 0x 320 */ +255,200, 15,148,194, 49,192,133,246, 15,149,192,133,194,116, 8, /* 0x 330 */ + 72,137, 15, 76,137, 71, 8,195, 72,131,199, 16,235,215,195, 65, /* 0x 340 */ + 87,184, 0, 0, 0, 0, 73,137,255, 65, 86, 65, 85, 65, 84, 73, /* 0x 350 */ +137,252, 85, 83, 72,131,236,104, 76, 3,103, 32,102,131,127, 16, /* 0x 360 */ + 3,137, 84, 36, 60, 15,183, 87, 56, 72,137, 76, 36, 48,185, 16, /* 0x 370 */ + 0, 0, 0, 72,137,116, 36, 64, 76,137, 68, 36, 40, 76,137, 76, /* 0x 380 */ + 36, 32, 15, 68,200, 76,137,230, 72,131,205,255, 49,219,131,193, /* 0x 390 */ + 34,255,202,120, 33,131, 62, 1,117, 22, 72,139, 70, 16, 72, 57, /* 0x 3a0 */ +232, 72, 15, 66,232, 72, 3, 70, 40, 72, 57,195, 72, 15, 66,216, /* 0x 3b0 */ + 72,131,198, 56,235,219, 72,129,229, 0,240,255,255, 49,210, 69, /* 0x 3c0 */ + 49,201, 72, 41,235, 65,131,200,255, 72,137,239, 72,129,195,255, /* 0x 3d0 */ + 15, 0, 0, 72,129,227, 0,240,255,255, 72,137,222,232,189,253, /* 0x 3e0 */ +255,255, 72,141, 20, 24, 72, 41,232,102, 65,131,127, 56, 0, 72, /* 0x 3f0 */ +137, 68, 36, 24,199, 68, 36, 20, 0, 0, 0, 0, 72,137, 84, 36, /* 0x 400 */ + 72, 15,132,155, 1, 0, 0, 72,131,124, 36, 64, 0,116, 37, 65, /* 0x 410 */ +131, 60, 36, 6,117, 30, 72,139, 84, 36, 24, 73, 3, 84, 36, 16, /* 0x 420 */ +190, 3, 0, 0, 0, 72,139,124, 36, 48,232,222,254,255,255,233, /* 0x 430 */ + 87, 1, 0, 0, 65,131, 60, 36, 1, 15,133, 76, 1, 0, 0, 72, /* 0x 440 */ +139, 68, 36, 24, 73, 3, 68, 36, 16, 65,190, 64, 98, 81,115, 65, /* 0x 450 */ +139, 76, 36, 4, 65,131,200,255, 73,139, 84, 36, 32, 72,137,197, /* 0x 460 */ + 72,137, 68, 36, 88, 73,139, 68, 36, 40,131,225, 7, 72,137,235, /* 0x 470 */ + 72,137, 84, 36, 80,193,225, 2,129,227,255, 15, 0, 0, 72, 1, /* 0x 480 */ +232, 65,211,238, 72, 41,221, 72,137, 68, 36, 8, 73,139, 68, 36, /* 0x 490 */ + 8, 65,131,230, 7, 76,141, 44, 26,185, 50, 0, 0, 0, 72, 41, /* 0x 4a0 */ +216, 72,131,124, 36, 64, 0,117, 7, 68,139, 68, 36, 60,177, 18, /* 0x 4b0 */ + 68,137,242, 73,137,193, 76,137,238,131,202, 2, 72,131,124, 36, /* 0x 4c0 */ + 64, 0, 72,137,239, 65, 15, 68,214,232,209,252,255,255, 72, 57, /* 0x 4d0 */ +197,117,121, 72,131,124, 36, 64, 0,116, 25, 72,139, 76, 36, 32, /* 0x 4e0 */ + 72,139, 84, 36, 40, 72,141,116, 36, 80, 72,139,124, 36, 64,232, /* 0x 4f0 */ + 12,253,255,255, 76,137,235, 72,247,219,129,227,255, 15, 0, 0, /* 0x 500 */ + 65,246,198, 2,116, 13, 74,141,124, 45, 0, 49,192, 72,137,217, /* 0x 510 */ +252,243,170, 72,131,124, 36, 64, 0,116, 59, 73,131,124, 36, 8, /* 0x 520 */ + 0,117, 23, 72,139,124, 36, 48, 72,141, 85, 12,199, 69, 12, 15, /* 0x 530 */ + 5,195,144, 49,246,232,211,253,255,255, 68,137,242, 76,137,238, /* 0x 540 */ + 72,137,239,232, 79,252,255,255,133,192,116, 10,191,127, 0, 0, /* 0x 550 */ + 0,232,108,252,255,255, 73,141, 68, 29, 0, 72, 1,197, 72, 59, /* 0x 560 */ +108, 36, 8,115, 38, 72, 41,108, 36, 8, 69, 49,201, 65,131,200, /* 0x 570 */ +255, 72,139,116, 36, 8,185, 50, 0, 0, 0, 68,137,242, 72,137, /* 0x 580 */ +239,232, 25,252,255,255, 72, 57,197,117,193,255, 68, 36, 20, 65, /* 0x 590 */ + 15,183, 71, 56, 73,131,196, 56, 57, 68, 36, 20, 15,140,101,254, /* 0x 5a0 */ +255,255, 72,131,124, 36, 64, 0,116, 18,102, 65,131,127, 16, 3, /* 0x 5b0 */ +116, 10, 72,139,124, 36, 72,232,223,251,255,255, 72,131,188, 36, /* 0x 5c0 */ +160, 0, 0, 0, 0,116, 16, 72,139, 68, 36, 24, 72,139,148, 36, /* 0x 5d0 */ +160, 0, 0, 0, 72,137, 2, 73,139, 87, 24, 72, 1, 84, 36, 24, /* 0x 5e0 */ + 72,139, 68, 36, 24, 72,131,196,104, 91, 93, 65, 92, 65, 93, 65, /* 0x 5f0 */ + 94, 65, 95,195, 65, 86, 76,141,114, 64, 65, 85, 77,137,205, 65, /* 0x 600 */ + 84, 77,137,196, 85, 72,137,213, 83, 72,137,203, 49,201, 72,131, /* 0x 610 */ +236, 48,139, 7, 72,137, 52, 36, 72,137,116, 36, 16, 72,141,116, /* 0x 620 */ + 36, 32, 72,137, 84, 36, 40, 72,137,124, 36, 8, 76,137,194, 72, /* 0x 630 */ +137,124, 36, 24, 72,137,231, 72,137, 68, 36, 32,232,191,251,255, /* 0x 640 */ +255, 73,139, 86, 16,190, 3, 0, 0, 0, 72,137,223, 72,131,194, /* 0x 650 */ + 64,232,183,252,255,255, 72, 15,183, 85, 56,190, 5, 0, 0, 0, /* 0x 660 */ + 72,137,223,232,165,252,255,255, 72,139, 85, 24,190, 9, 0, 0, /* 0x 670 */ + 0, 72,137,223,232,148,252,255,255, 65, 83, 77,137,233, 77,137, /* 0x 680 */ +224, 49,210, 72,137,217, 72,137,239, 72,141, 68, 36,104, 72,141, /* 0x 690 */ +116, 36, 24, 69, 49,237, 80,232,163,252,255,255,102,131,125, 56, /* 0x 6a0 */ + 0, 73,137,196, 65, 89, 65, 90,116,115, 65,131, 62, 3,117, 93, /* 0x 6b0 */ + 72,139,124, 36, 96, 73, 3,126, 16, 49,210, 49,246,232,248,250, /* 0x 6c0 */ +255,255,133,192,137,195,120, 23,186, 0, 4, 0, 0, 72,137,238, /* 0x 6d0 */ +137,199,232,223,250,255,255, 72, 61, 0, 4, 0, 0,116, 10,191, /* 0x 6e0 */ +127, 0, 0, 0,232,217,250,255,255, 65, 80, 49,246, 69, 49,201, /* 0x 6f0 */ + 69, 49,192, 49,201,106, 0,137,218, 72,137,239,232, 62,252,255, /* 0x 700 */ +255,137,223, 73,137,196,232,179,250,255,255, 94, 95, 15,183, 69, /* 0x 710 */ + 56, 65,255,197, 73,131,198, 56, 65, 57,197,124,141, 72,131,196, /* 0x 720 */ + 48, 76,137,224, 91, 93, 65, 92, 65, 93, 65, 94,195 /* 0x 730 */ }; diff --git a/src/stub/src/amd64-linux.elf-fold.S b/src/stub/src/amd64-linux.elf-fold.S index 059242c1..3e5589de 100644 --- a/src/stub/src/amd64-linux.elf-fold.S +++ b/src/stub/src/amd64-linux.elf-fold.S @@ -81,6 +81,7 @@ L90: pushq %rdi # &Elf64_auxv 0: cmpq $0,(%rsi); movsq; movsq; jne 0b # move past auxv + lea -8(%rdi),%r15 # &auxv[N-1].a_un movq %rdi,(%arg3) # new_env[0] movl $('='<<24)|(' '<<16)|(' '<<8)|(' '<<0),%eax # " =" @@ -99,16 +100,20 @@ L90: subq $ OVERHEAD,%rsp movq %rsp,%arg3 # &ELf64_Ehdr temporary space movq %rbp,%arg5 # &decompress: f_expand + pushq $0 # reloc call upx_main # Out: %rax= entry /* entry= upx_main(b_info *arg1, total_size arg2, Elf64_Ehdr *arg3, - Elf32_Auxv_t *arg4, f_decompr arg5, f_unfilter arg6 ) + Elf32_Auxv_t *arg4, f_decompr arg5, f_unfilter arg6, + Elf64_Addr reloc ) */ + popq %rdx # reloc addq $OVERHEAD,%rsp pop %arg2 # LENU pop %arg1 # ADRU pop %rcx # JMPU push %rax # &entry push $ __NR_munmap; pop %rax + jmp *(%r15) jmp *%rcx # goto: syscall; ret munmap: .globl munmap diff --git a/src/stub/src/amd64-linux.elf-main.c b/src/stub/src/amd64-linux.elf-main.c index 553b4eb2..d40bc7f6 100644 --- a/src/stub/src/amd64-linux.elf-main.c +++ b/src/stub/src/amd64-linux.elf-main.c @@ -236,7 +236,8 @@ do_xmap( int const fdi, Elf64_auxv_t *const av, f_expand *const f_decompress, - f_unfilter *const f_unf + f_unfilter *const f_unf, + Elf64_Addr *p_reloc ) { Elf64_Phdr const *phdr = (Elf64_Phdr const *) (ehdr->e_phoff + @@ -279,6 +280,7 @@ do_xmap( if (0==phdr->p_offset) { Elf64_Ehdr *const ehdr = (Elf64_Ehdr *)addr; *(int *)&ehdr->e_ident[12] = 0x90c3050f; // syscall; ret; nop + auxv_up(av, AT_NULL, (uint64_t)&ehdr->e_ident[12]); } if (0!=mprotect(addr, mlen, prot)) { err_exit(10); @@ -299,6 +301,9 @@ ERR_LAB brk(v_brk); } } + if (0!=p_reloc) { + *p_reloc = reloc; + } return ehdr->e_entry + reloc; } @@ -316,7 +321,8 @@ upx_main( // returns entry address Elf64_Ehdr *const ehdr, // temp char[sz_ehdr] for decompressing Elf64_auxv_t *const av, f_expand *const f_decompress, - f_unfilter *const f_unf + f_unfilter *const f_unf, + Elf64_Addr reloc // IN OUT; value result for ET_DYN ) { Elf64_Phdr const *phdr = (Elf64_Phdr const *)(1+ ehdr); @@ -338,12 +344,12 @@ upx_main( // returns entry address //auxv_up(av, AT_PHENT , ehdr->e_phentsize); /* this can never change */ //auxv_up(av, AT_PAGESZ, PAGE_SIZE); /* ld-linux.so.2 does not need this */ - entry = do_xmap(ehdr, &xi1, 0, av, f_decompress, f_unf); // "rewind" + entry = do_xmap(ehdr, &xi1, 0, av, f_decompress, f_unf, &reloc); // "rewind" { // Map PT_INTERP program interpreter int j; for (j=0; j < ehdr->e_phnum; ++phdr, ++j) if (PT_INTERP==phdr->p_type) { - char const *const iname = (char const *)phdr->p_vaddr; + char const *const iname = reloc + (char const *)phdr->p_vaddr; int const fdi = open(iname, O_RDONLY, 0); if (0 > fdi) { err_exit(18); @@ -352,7 +358,7 @@ upx_main( // returns entry address ERR_LAB err_exit(19); } - entry = do_xmap(ehdr, 0, fdi, 0, 0, 0); + entry = do_xmap(ehdr, 0, fdi, 0, 0, 0, 0); close(fdi); } }