Comments (5)
Hello,
Thanks for trying out mandibule and writing this report.
Can you please tell me what you have in CC (and its version) and CFLAGS?
In the meantime you can try to change
icrt/icrt_syscall.h:169:25: _syscall1(SYS_exit, _exit, void, int);
That might fix the problem.
Im going to compile with -Werror -Wpedantic -Wall ... on my end to fix that kind of issues.
from mandibule.
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?
from mandibule.
rewrote the x86 syscall wrapper to be compatible with older gcc (4.9).
works on my debian jessie chroot with gcc version 4.9.2 (Debian 4.9.2-10)
from mandibule.
Firstly thank you for your answer and code adjustment effort.
In 32bit there are still some errors, I am trimming its bug source now,
but in 64bit just a warning and compilation is successfully done as per snipped below:
$ 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.
from mandibule.
For the x86 people will meet the bug in the assembly coding for C in volatile
mode,
the problem is residing in the icrt/icrt_syscall.h:30:9
, as per snipped below:
#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 ]
I think this is the assembly code writing matter for 32bit (register adjust)
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
But talking is always be easier than doing it, thank you for the x86_64 fix!!!
from mandibule.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mandibule.