Fix upxfd_create for stubs on PowerPC64
https://github.com/upx/upx/issues/925 modified: misc/testsuite/upx_testsuite_1-expected_sha256sums.sh modified: src/stub/src/powerpc64-linux.elf-fold.S plus generated .h
This commit is contained in:
Generated
+1060
-1059
File diff suppressed because it is too large
Load Diff
Generated
+1053
-1052
File diff suppressed because it is too large
Load Diff
@@ -418,21 +418,30 @@ close: .globl close
|
||||
li r0,SYS_close; 5: b sysgo
|
||||
|
||||
upxfd_create: .globl upxfd_create // (char *tag, unsigned flags)
|
||||
stdu a0,-AL_STK(sp) // push tag onto aligned stack
|
||||
0: // try memfd_create
|
||||
ld a0,0(sp) // get tag
|
||||
li r0,SYS_memfd_create; sc; bns+ ok_memfd
|
||||
cmpwi a2,0; beq no_memfd // memfd_create failed twice
|
||||
li a2,0; b 0b // try again without MFD_EXEC
|
||||
// failed syscall returns errno in a0
|
||||
cmpwi a0,EINVAL; bne 8f // unexpected error number
|
||||
cmpwi a1,0; beq no_memfd // memfd_create failed twice
|
||||
li a1,0; b 0b // try again without MFD_EXEC
|
||||
no_memfd: // so try /dev/shm
|
||||
O_RDWR= 2
|
||||
O_DIRECTORY= 040000 // 0x4000
|
||||
O_TMPFILE= 020000000 // 0x400000
|
||||
mflr r6; bl 0f; .asciz "/dev/shm"; .balign 4;
|
||||
0: mflr a1; mtlr r6
|
||||
li a2,0700
|
||||
lis a3,O_TMPFILE>>16
|
||||
ori a3,a3,O_RDWR | O_DIRECTORY
|
||||
li r0,SYS_open; sc; bns+ ok_memfd; teq r0,r0
|
||||
mflr r6
|
||||
bl 0f; .asciz "/dev/shm"; .balign 4
|
||||
0: mflr a0
|
||||
mtlr r6
|
||||
li a2,0700 // mode
|
||||
lis a1,O_TMPFILE>>16
|
||||
ori a1,a1,O_RDWR | O_DIRECTORY
|
||||
li r0,SYS_open; sc; bns+ ok_memfd // name, flags, mode
|
||||
8:
|
||||
teq r0,r0 // unexpected errno
|
||||
ok_memfd:
|
||||
addi sp,sp,AL_STK // toss tag
|
||||
ret
|
||||
|
||||
__NR_memfd_create= 360
|
||||
|
||||
+5
-5
@@ -27,8 +27,8 @@ OUTPUT(tmp/powerpc64-linux.elf-fold.bin elf64-powerpc)
|
||||
.bss 0x0000000000000000 0x0
|
||||
.bss 0x0000000000000000 0x0 tmp/powerpc64-linux.elf-fold.o
|
||||
|
||||
SYSCALLS 0x0000000000000000 0x148
|
||||
SYSCALLS 0x0000000000000000 0x148 tmp/powerpc64-linux.elf-fold.o
|
||||
SYSCALLS 0x0000000000000000 0x15c
|
||||
SYSCALLS 0x0000000000000000 0x15c tmp/powerpc64-linux.elf-fold.o
|
||||
0x0000000000000008 mmap
|
||||
0x0000000000000020 munmap
|
||||
0x0000000000000028 mprotect
|
||||
@@ -44,9 +44,9 @@ SYSCALLS 0x0000000000000000 0x148
|
||||
0x0000000000000070 openat
|
||||
0x0000000000000078 close
|
||||
0x0000000000000080 upxfd_create
|
||||
0x00000000000000d8 memfd_create
|
||||
0x000000000000011c memcpy
|
||||
0x0000000000000140 my_bkpt
|
||||
0x00000000000000ec memfd_create
|
||||
0x0000000000000130 memcpy
|
||||
0x0000000000000154 my_bkpt
|
||||
|
||||
.comment 0x0000000000000000 0x33
|
||||
.comment 0x0000000000000000 0x33 tmp/powerpc64-linux.elf-fold.o
|
||||
|
||||
+5
-5
@@ -27,8 +27,8 @@ OUTPUT(tmp/powerpc64le-linux.elf-fold.bin elf64-powerpcle)
|
||||
.bss 0x0000000000000000 0x0
|
||||
.bss 0x0000000000000000 0x0 tmp/powerpc64le-linux.elf-fold.o
|
||||
|
||||
SYSCALLS 0x0000000000000000 0x148
|
||||
SYSCALLS 0x0000000000000000 0x148 tmp/powerpc64le-linux.elf-fold.o
|
||||
SYSCALLS 0x0000000000000000 0x15c
|
||||
SYSCALLS 0x0000000000000000 0x15c tmp/powerpc64le-linux.elf-fold.o
|
||||
0x0000000000000008 mmap
|
||||
0x0000000000000020 munmap
|
||||
0x0000000000000028 mprotect
|
||||
@@ -44,9 +44,9 @@ SYSCALLS 0x0000000000000000 0x148
|
||||
0x0000000000000070 openat
|
||||
0x0000000000000078 close
|
||||
0x0000000000000080 upxfd_create
|
||||
0x00000000000000d8 memfd_create
|
||||
0x000000000000011c memcpy
|
||||
0x0000000000000140 my_bkpt
|
||||
0x00000000000000ec memfd_create
|
||||
0x0000000000000130 memcpy
|
||||
0x0000000000000154 my_bkpt
|
||||
|
||||
.comment 0x0000000000000000 0x33
|
||||
.comment 0x0000000000000000 0x33 tmp/powerpc64le-linux.elf-fold.o
|
||||
|
||||
Reference in New Issue
Block a user