unify DEBUG STR_* into i386-linux.elf-main.c from *.elf-fold.S
This commit is contained in:
parent
80c5ee2479
commit
279ffeeefa
@ -226,61 +226,5 @@ bswap9:
|
||||
bge bswap0
|
||||
ret
|
||||
|
||||
#if 0 /*{ "gcc-3.4 -fPIC" botches string constants when code moves! */
|
||||
.globl STR_0x
|
||||
STR_0x:
|
||||
mov r0,pc; mov pc,lr
|
||||
.asciz "0x"
|
||||
.balign 4
|
||||
|
||||
.globl STR_hex
|
||||
STR_hex:
|
||||
mov r0,pc; mov pc,lr
|
||||
.asciz "0123456789abcdef"
|
||||
.balign 4
|
||||
|
||||
.globl STR_xread
|
||||
STR_xread:
|
||||
mov r0,pc; mov pc,lr
|
||||
.asciz "xread %p(%x %p) %p %x\n"
|
||||
.balign 4
|
||||
|
||||
.globl STR_unpackExtent
|
||||
STR_unpackExtent:
|
||||
mov r0,pc; mov pc,lr
|
||||
.asciz "unpackExtent in=%p(%x %p) out=%p(%x %p) %p %p\n"
|
||||
.balign 4
|
||||
|
||||
.globl STR_make_hatch_arm
|
||||
STR_make_hatch_arm:
|
||||
mov r0,pc; mov pc,lr
|
||||
.asciz "make_hatch_arm %p %x\n"
|
||||
.balign 4
|
||||
|
||||
.globl STR_auxv_up
|
||||
STR_auxv_up:
|
||||
mov r0,pc; mov pc,lr
|
||||
.asciz "auxv_up %p %x %x\n"
|
||||
.balign 4
|
||||
|
||||
.globl STR_xfind_pages
|
||||
STR_xfind_pages:
|
||||
mov r0,pc; mov pc,lr
|
||||
.asciz "xfind_pages %x %p %d %p\n"
|
||||
.balign 4
|
||||
|
||||
.globl STR_do_xmap
|
||||
STR_do_xmap:
|
||||
mov r0,pc; mov pc,lr
|
||||
.asciz "do_xmap fdi=%x ehdr=%p xi=%p(%x %p) av=%p p_reloc=%p f_unf=%p\n"
|
||||
.balign 4
|
||||
|
||||
.globl STR_upx_main
|
||||
STR_upx_main:
|
||||
mov r0,pc; mov pc,lr
|
||||
.asciz "upx_main av=%p szc=%x f_dec=%p f_unf=%p xo=%p(%x %p) xi=%p(%x %p) dynbase=%x\n",
|
||||
.balign 4
|
||||
#endif /*}*/
|
||||
|
||||
// vi:ts=8:et:nowrap
|
||||
|
||||
|
||||
@ -200,7 +200,7 @@ mmap:
|
||||
#define DEBUG 0
|
||||
#endif /*}*/
|
||||
|
||||
#if DEBUG /*{ "gcc-3.4 -fPIC" botches string constants when code moves! */
|
||||
#if DEBUG /*{*/
|
||||
|
||||
div10: .globl div10
|
||||
mov ip,r0 @ extra copy used at end
|
||||
@ -233,59 +233,6 @@ div10: .globl div10
|
||||
adc r0,r1,#0 @ * 0x0.1999999a
|
||||
ret
|
||||
|
||||
.globl STR_0x
|
||||
STR_0x:
|
||||
mov r0,pc; ret
|
||||
.asciz "0x"
|
||||
.balign 4
|
||||
|
||||
.globl STR_hex
|
||||
STR_hex:
|
||||
mov r0,pc; ret
|
||||
.asciz "0123456789abcdef"
|
||||
.balign 4
|
||||
|
||||
.globl STR_xread
|
||||
STR_xread:
|
||||
mov r0,pc; ret
|
||||
.asciz "xread %p(%x %p) %p %x\n"
|
||||
.balign 4
|
||||
|
||||
.globl STR_unpackExtent
|
||||
STR_unpackExtent:
|
||||
mov r0,pc; ret
|
||||
.asciz "unpackExtent in=%p(%x %p) out=%p(%x %p) %p %p\n"
|
||||
.balign 4
|
||||
|
||||
.globl STR_make_hatch_arm
|
||||
STR_make_hatch_arm:
|
||||
mov r0,pc; ret
|
||||
.asciz "make_hatch_arm %p %x\n"
|
||||
.balign 4
|
||||
|
||||
.globl STR_auxv_up
|
||||
STR_auxv_up:
|
||||
mov r0,pc; ret
|
||||
.asciz "auxv_up %p %x %x\n"
|
||||
.balign 4
|
||||
|
||||
.globl STR_xfind_pages
|
||||
STR_xfind_pages:
|
||||
mov r0,pc; ret
|
||||
.asciz "xfind_pages %x %p %d %p\n"
|
||||
.balign 4
|
||||
|
||||
.globl STR_do_xmap
|
||||
STR_do_xmap:
|
||||
mov r0,pc; ret
|
||||
.asciz "do_xmap fdi=%x ehdr=%p xi=%p(%x %p) av=%p p_reloc=%p f_unf=%p\n"
|
||||
.balign 4
|
||||
|
||||
.globl STR_upx_main
|
||||
STR_upx_main:
|
||||
mov r0,pc; ret
|
||||
.asciz "upx_main av=%p szc=%x f_dec=%p f_unf=%p xo=%p(%x %p) xi=%p(%x %p) dynbase=%x\n",
|
||||
.balign 4
|
||||
#endif /*}*/
|
||||
|
||||
@ vi:ts=8:et:nowrap
|
||||
|
||||
@ -202,55 +202,5 @@ L32:
|
||||
pop edi // &auxtab
|
||||
ret
|
||||
|
||||
#ifndef DEBUG /*{*/
|
||||
#define DEBUG 0
|
||||
#endif /*}*/
|
||||
|
||||
#if DEBUG /*{ truly-PIC string constants for debugging */
|
||||
.globl STR_0x
|
||||
STR_0x:
|
||||
call 0f; .asciz "0x"; 0:
|
||||
pop eax; ret
|
||||
|
||||
.globl STR_hex
|
||||
STR_hex:
|
||||
call 0f; .asciz "0123456789abcdef"; 0:
|
||||
pop eax; ret
|
||||
|
||||
.globl STR_xread
|
||||
STR_xread:
|
||||
call 0f; .asciz "xread %p(%x %p) %p %x\n"; 0:
|
||||
pop eax; ret
|
||||
|
||||
.globl STR_unpackExtent
|
||||
STR_unpackExtent:
|
||||
call 0f; .asciz "unpackExtent in=%p(%x %p) out=%p(%x %p) %p %p\n"; 0:
|
||||
pop eax; ret
|
||||
|
||||
.globl STR_make_hatch_arm
|
||||
STR_make_hatch_arm:
|
||||
call 0f; .asciz "make_hatch_arm %p %x\n"; 0:
|
||||
pop eax; ret
|
||||
|
||||
.globl STR_auxv_up
|
||||
STR_auxv_up:
|
||||
call 0f; .asciz "auxv_up %p %x %x\n"; 0:
|
||||
pop eax; ret
|
||||
|
||||
.globl STR_xfind_pages
|
||||
STR_xfind_pages:
|
||||
call 0f; .asciz "xfind_pages %x %p %d %p\n"; 0:
|
||||
pop eax; ret
|
||||
|
||||
.globl STR_do_xmap
|
||||
STR_do_xmap:
|
||||
call 0f; .asciz "do_xmap fdi=%x ehdr=%p xi=%p(%x %p) av=%p p_reloc=%p f_unf=%p\n"; 0:
|
||||
pop eax; ret
|
||||
|
||||
.globl STR_upx_main
|
||||
STR_upx_main:
|
||||
call 0f; .asciz "upx_main av=%p szc=%x f_dec=%p f_unf=%p xo=%p(%x %p) xi=%p(%x %p) dynbase=%x\n"; 0:
|
||||
pop eax; ret
|
||||
#endif /*}*/
|
||||
// vi:ts=8:et:nowrap
|
||||
|
||||
|
||||
@ -238,56 +238,5 @@ mmap: .globl mmap
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
#ifndef DEBUG /*{*/
|
||||
#define DEBUG 0
|
||||
#endif /*}*/
|
||||
|
||||
#if DEBUG /*{ truly-PIC string constants for debugging */
|
||||
.globl STR_0x
|
||||
STR_0x:
|
||||
call 0f; .asciz "0x"; 0:
|
||||
pop eax; ret
|
||||
|
||||
.globl STR_hex
|
||||
STR_hex:
|
||||
call 0f; .asciz "0123456789abcdef"; 0:
|
||||
pop eax; ret
|
||||
|
||||
.globl STR_xread
|
||||
STR_xread:
|
||||
call 0f; .asciz "xread %p(%x %p) %p %x\n"; 0:
|
||||
pop eax; ret
|
||||
|
||||
.globl STR_unpackExtent
|
||||
STR_unpackExtent:
|
||||
call 0f; .asciz "unpackExtent in=%p(%x %p) out=%p(%x %p) %p %p\n"; 0:
|
||||
pop eax; ret
|
||||
|
||||
.globl STR_make_hatch_arm
|
||||
STR_make_hatch_arm:
|
||||
call 0f; .asciz "make_hatch_arm %p %x\n"; 0:
|
||||
pop eax; ret
|
||||
|
||||
.globl STR_auxv_up
|
||||
STR_auxv_up:
|
||||
call 0f; .asciz "auxv_up %p %x %x\n"; 0:
|
||||
pop eax; ret
|
||||
|
||||
.globl STR_xfind_pages
|
||||
STR_xfind_pages:
|
||||
call 0f; .asciz "xfind_pages %x %p %d %p\n"; 0:
|
||||
pop eax; ret
|
||||
|
||||
.globl STR_do_xmap
|
||||
STR_do_xmap:
|
||||
call 0f; .asciz "do_xmap fdi=%x ehdr=%p xi=%p(%x %p) av=%p p_reloc=%p f_unf=%p\n"; 0:
|
||||
pop eax; ret
|
||||
|
||||
.globl STR_upx_main
|
||||
STR_upx_main:
|
||||
call 0f; .asciz "upx_main av=%p szc=%x f_dec=%p f_unf=%p xo=%p(%x %p) xi=%p(%x %p) dynbase=%x\n"; 0:
|
||||
pop eax; ret
|
||||
#endif /*}*/
|
||||
|
||||
// vi:ts=8:et:nowrap
|
||||
|
||||
|
||||
@ -59,6 +59,46 @@ ssize_t write(int, void const *, size_t);
|
||||
#define va_start __builtin_va_start
|
||||
#endif
|
||||
|
||||
#if defined(__i386__) /*{*/
|
||||
#define PIC_STRING(value, var) \
|
||||
__asm__ __volatile__ ( \
|
||||
"call 0f; .asciz \"" value "\"; \
|
||||
0: pop %0;" : "=a"(var) : \
|
||||
)
|
||||
#elif defined(__arm__) /*}{*/
|
||||
__asm__ __volatile__ ( \
|
||||
"mov r0,pc; ret; \
|
||||
.asciz \"" value "\"; .balign 4" : "=a"(var) : \
|
||||
)
|
||||
#elif defined(__mips__) /*}{*/
|
||||
__asm__ __volatile__ ( \
|
||||
"mov at,ra; bal 0f; move v0,ra; \
|
||||
.asciz \"" value "\"; .balign 4; \
|
||||
0: jr at; nop" : "=a"(var) : \
|
||||
)
|
||||
#endif /*}*/
|
||||
|
||||
|
||||
#define DEBUG_STRCON(name, value) \
|
||||
static char const *name(void) \
|
||||
{ \
|
||||
char *rv; PIC_STRING(value, rv); \
|
||||
return rv; \
|
||||
}
|
||||
|
||||
DEBUG_STRCON(STR_hex, "0123456789abcdef");
|
||||
DEBUG_STRCON(STR_xread, "xread %%p(%%x %%p) %%p %%x\\n")
|
||||
DEBUG_STRCON(STR_unpackExtent,
|
||||
"unpackExtent in=%%p(%%x %%p) out=%%p(%%x %%p) %%p %%p\\n");
|
||||
DEBUG_STRCON(STR_make_hatch, "make_hatch %%p %%x\\n");
|
||||
DEBUG_STRCON(STR_auxv_up, "auxv_up %%p %%x %%x\\n");
|
||||
DEBUG_STRCON(STR_xfind_pages, "xfind_pages %%x %%p %%d %%p\\n");
|
||||
DEBUG_STRCON(STR_do_xmap,
|
||||
"do_xmap fdi=%%x ehdr=%%p xi=%%p(%%x %%p) av=%%p p_reloc=%%p f_unf=%%p\\n")
|
||||
DEBUG_STRCON(STR_upx_main,
|
||||
"upx_main av=%%p szc=%%x f_dec=%%p f_unf=%%p "
|
||||
" xo=%%p(%%x %%p) xi=%%p(%%x %%p) dynbase=%%x\\n")
|
||||
|
||||
#ifdef __arm__ /*{*/
|
||||
extern unsigned div10(unsigned);
|
||||
#else /*}{*/
|
||||
@ -106,15 +146,6 @@ heximal(unsigned x, char *ptr, int n)
|
||||
|
||||
|
||||
#define DPRINTF(a) dprintf a
|
||||
extern char const *STR_0x(void);
|
||||
extern char const *STR_xread(void);
|
||||
extern char const *STR_unpackExtent(void);
|
||||
extern char const *STR_make_hatch_arm(void);
|
||||
extern char const *STR_auxv_up(void);
|
||||
extern char const *STR_xfind_pages(void);
|
||||
extern char const *STR_do_xmap(void);
|
||||
extern char const *STR_upx_main(void);
|
||||
|
||||
|
||||
static int
|
||||
dprintf(char const *fmt, ...)
|
||||
@ -290,6 +321,7 @@ static void *
|
||||
make_hatch_x86(Elf32_Phdr const *const phdr, unsigned const reloc)
|
||||
{
|
||||
unsigned *hatch = 0;
|
||||
DPRINTF((STR_make_hatch(),phdr,reloc));
|
||||
if (phdr->p_type==PT_LOAD && phdr->p_flags & PF_X) {
|
||||
// The format of the 'if' is
|
||||
// if ( ( (hatch = loc1), test_loc1 )
|
||||
@ -328,7 +360,7 @@ make_hatch_arm(
|
||||
)
|
||||
{
|
||||
unsigned *hatch = 0;
|
||||
DPRINTF((STR_make_hatch_arm(),phdr,reloc));
|
||||
DPRINTF((STR_make_hatch(),phdr,reloc));
|
||||
if (phdr->p_type==PT_LOAD && phdr->p_flags & PF_X) {
|
||||
// The format of the 'if' is
|
||||
// if ( ( (hatch = loc1), test_loc1 )
|
||||
|
||||
@ -207,65 +207,4 @@ mmap: .globl mmap
|
||||
addiu sp,sp, sp_frame
|
||||
#endif /*}*/
|
||||
|
||||
#if 0 /*{ truly-PIC string constants for debugging */
|
||||
/* UNFORTUNATELY THIS DOES NOT WORK because gcc uses 'jal' instead of 'bal' */
|
||||
|
||||
.globl STR_0x
|
||||
ret_at:
|
||||
jr at
|
||||
nop
|
||||
STR_0x:
|
||||
move at,ra; bal ret_at; move v0,ra
|
||||
.asciz "0x"
|
||||
.balign 4
|
||||
|
||||
.globl STR_hex
|
||||
STR_hex:
|
||||
move at,ra; bal ret_at; move v0,ra
|
||||
.asciz "0123456789abcdef"
|
||||
.balign 4
|
||||
|
||||
.globl STR_xread
|
||||
STR_xread:
|
||||
move at,ra; bal ret_at; move v0,ra
|
||||
.asciz "xread %p(%x %p) %p %x\n"
|
||||
.balign 4
|
||||
|
||||
.globl STR_unpackExtent
|
||||
STR_unpackExtent:
|
||||
move at,ra; bal ret_at; move v0,ra
|
||||
.asciz "unpackExtent in=%p(%x %p) out=%p(%x %p) %p %p\n"
|
||||
.balign 4
|
||||
|
||||
.globl STR_make_hatch_arm
|
||||
STR_make_hatch_arm:
|
||||
move at,ra; bal ret_at; move v0,ra
|
||||
.asciz "make_hatch_arm %p %x\n"
|
||||
.balign 4
|
||||
|
||||
.globl STR_auxv_up
|
||||
STR_auxv_up:
|
||||
move at,ra; bal ret_at; move v0,ra
|
||||
.asciz "auxv_up %p %x %x\n"
|
||||
.balign 4
|
||||
|
||||
.globl STR_xfind_pages
|
||||
STR_xfind_pages:
|
||||
move at,ra; bal ret_at; move v0,ra
|
||||
.asciz "xfind_pages %x %p %d %p\n"
|
||||
.balign 4
|
||||
|
||||
.globl STR_do_xmap
|
||||
STR_do_xmap:
|
||||
move at,ra; bal ret_at; move v0,ra
|
||||
.asciz "do_xmap fdi=%x ehdr=%p xi=%p(%x %p) av=%p p_reloc=%p f_unf=%p\n"
|
||||
.balign 4
|
||||
|
||||
.globl STR_upx_main
|
||||
STR_upx_main:
|
||||
move at,ra; bal ret_at; move v0,ra
|
||||
.asciz "upx_main av=%p szc=%x f_dec=%p f_unf=%p xo=%p(%x %p) xi=%p(%x %p) dynbase=%x\n",
|
||||
.balign 4
|
||||
#endif /*}*/
|
||||
|
||||
# vi:ts=8:et:nowrap
|
||||
|
||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user