-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/usr/include/unistd.h:603:13: error: conflicting types for '_exit' #1
Comments
Hello, In the meantime you can try to change Im going to compile with -Werror -Wpedantic -Wall ... on my end to fix that kind of issues. |
I just pushed a commit fixing a few warnings when compiling with -Wall -Wpedantic i also pushed a small edit for _exit which should fix your problem. Can you pull & try the compilation again? |
Firstly thank you for your answer and code adjustment effort. $ make x86_64
rm -rf mandibule target toinject
cc -D_GNU_SOURCE -std=gnu99 -static-libgcc -lgcc -I icrt/ -I code/ -fno-common -fno-stack-protector -fomit-frame-pointer -fno-exceptions -fno-asynchronous-unwind-tables -fno-unwind-tables -pie -fPIE -fno-builtin -nostdlib -o mandibule mandibule.c
In file included from icrt/icrt.h:15:0,
from mandibule.c:25:
/usr/include/unistd.h: In function '_exit':
icrt/icrt_syscall.h:170:1: warning: 'noreturn' function does return
void _exit(int c) { __exit(c); }
^
cc -D_GNU_SOURCE -std=gnu99 -static-libgcc -lgcc -I icrt/ -I code/ -fno-common -fno-stack-protector -fomit-frame-pointer -fno-exceptions -fno-asynchronous-unwind-tables -fno-unwind-tables -pie -fPIE -fno-builtin -o toinject samples/toinject.c
cc -D_GNU_SOURCE -std=gnu99 -static-libgcc -lgcc -I icrt/ -I code/ -fno-common -fno-stack-protector -fomit-frame-pointer -fno-exceptions -fno-asynchronous-unwind-tables -fno-unwind-tables -o target samples/target.c
$ file mandibule target toinject
mandibule: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=26e4d6ad5402b7a2afaa74193174946eb9443fb0, not stripped
target: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=d9e02b9978525438aeb4c4e6b91e328813f7a5b6, not stripped
toinject: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=c148db991287dbb06f381735b4ae284c286ebe5a, not stripped I will get back on the x86 (32bit) report with more details in CC version CFLAGS. |
For the x86 people will meet the bug in the assembly coding for C in #ifdef __i386__
#define _syscall_do(sys_nbr, rettype) \
{ \
rettype ret = 0; \
asm volatile \
( \
"int $0x80;" \
: "=a" (ret) \
: "0"(sys_nbr), "bx"(a1), "cx"(a2), \
"dx"(a3), "S"(a4), "D"(a5), "bp"(a6) \
); \
return ret; \
}
[ EDIT ] Error message for the fail compilation with CC -v4.9.2 x86, or [ EDIT ] the other versions too appears the same error state: icrt/icrt_syscall.h: In function '_getpid':
icrt/icrt_syscall.h:30:9: error: inconsistent operand constraints in an 'asm'
asm volatile \
^ And this is the full log of compilation with the error message intact. $
$ cc --version
cc (Debian 4.9.2-10 deb8u1) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$
$ make x86
rm -rf mandibule target toinject
cc -D_GNU_SOURCE -std=gnu99 -static-libgcc -lgcc -I icrt/ -I code/ -fno-common -fno-stack-protector -fomit-frame-pointer -fno-exceptions -fno-asynchronous-unwind-tables -fno-unwind-tables -pie -fPIE -fno-builtin -nostdlib -m32 -o mandibule mandibule.c
In file included from icrt/icrt.h:15:0,
from mandibule.c:25:
/usr/include/unistd.h: In function '_exit':
icrt/icrt_syscall.h:170:1: warning: 'noreturn' function does return
void _exit(int c) { __exit(c); }
^
icrt/icrt_syscall.h: In function '_getpid':
icrt/icrt_syscall.h:30:9: error: inconsistent operand constraints in an 'asm'
asm volatile \
^
icrt/icrt_syscall.h:159:5: note: in expansion of macro '_syscall_do'
_syscall_do(sys_nbr, rettype) \
^
icrt/icrt_syscall.h:167:1: note: in expansion of macro '_syscall0'
_syscall0(SYS_getpid, _getpid, int)
^
Makefile:26: recipe for target 'x86' failed
make: *** [x86] Error 1
$
$ the best way I can advise for this matter is avoiding volatile mode and just convert the code into basic asm, for example: asm ( "int $0x80;"
"mov %1, %0;"
"add $1, %0;"
: "=a" (ret)
: Please refer to https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.htmlv |
rewrote the x86 syscall wrapper to be compatible with older gcc (4.9). |
Good work on the method for injection with
fPIE
compilation ELF!I am not so sure why I have problem with the build, as per seen in the the title or in the error snip below.
It seems that the
macro
(for arch recognition) is having a problem oricrt_syscall.h
has been conflicted with/usr/include/unistd.h
?If you would be kind to upload the mandiblue you compiled for the both architecture in the repo or onto virus total etc, it would be very helpful. I am onto reproduction the method your described.
I use Debian for the purpose, and doing plenty of build on the other apps without problem.. Thank you.
On x32:
On x64:
end of issue
The text was updated successfully, but these errors were encountered: