Advertisement
Guest User

Untitled

a guest
Dec 19th, 2016
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.79 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <string.h>
  5.  
  6. //#define DEF_DEBUG
  7. #define DEF_DEBUG2
  8. #define DEF_CROSSROOT 1
  9.  
  10. #ifndef EMU_ARCH
  11. #define EMU_ARCH "arm"
  12. #endif /*EMU_ARCH*/
  13. #ifndef RUN_ARCH
  14. #define RUN_ARCH "x86_64"
  15. #endif /*RUN_ARCH*/
  16.  
  17. #ifndef RUN_LIBSUFFIX
  18. #define RUN_LIBSUFFIX "64"
  19. #endif /*RUN_LIBSUFFIX*/
  20.  
  21. #ifndef DEF_SYSROOT
  22. #define DEF_SYSROOT "/sr9"
  23. #endif /*DEF_SYSROOT*/
  24. //#define GCC_VERS "4.9.3"
  25. #ifndef GCC_VERS
  26. #define GCC_VERS "5.4.0"
  27. #endif /*GCC_VERS*/
  28. #ifndef PERL_VERS
  29. #define PERL_VERS "5.22.2"
  30. #endif /*PERL_VERS*/
  31.  
  32. #ifndef MACHINE_PKSUFFIX
  33. #define MACHINE_PKSUFFIX "-pc-linux-gnueabihf"
  34. #endif /*MACHINE_PKSUFFIX*/
  35. #define MACHINE_TARGET EMU_ARCH MACHINE_PKSUFFIX
  36.  
  37. //llvm: armv6-pc-linux-gnueabihf
  38. #ifndef MACHINE_LLVM_TARGET
  39. #define MACHINE_LLVM_TARGET "armv7-pc-linux-gnueabihf"
  40. #endif /*MACHINE_LLVM_TARGET*/
  41. #define MACHINE_QEMU_TARGET EMU_ARCH
  42. #define DEF_LD_LIBRARY_PATH_NAME "ZZ_LIBRARY_PATH"
  43. #define DEF_LD_LIBRARY_PATH_PATH \
  44. "\
  45. " DEF_SYSROOT "/lib" RUN_LIBSUFFIX ":\
  46. " DEF_SYSROOT "/usr/lib" RUN_LIBSUFFIX ":\
  47. " DEF_SYSROOT "/usr/local/lib" RUN_LIBSUFFIX ":\
  48. " DEF_SYSROOT "/usr/X11R6/lib" RUN_LIBSUFFIX ":\
  49. " DEF_SYSROOT "/usr/gnome/lib" RUN_LIBSUFFIX ":\
  50. " DEF_SYSROOT "/lib" RUN_LIBSUFFIX "/libc5-compat:\
  51. " DEF_SYSROOT "/usr/share/texmf/lib" RUN_LIBSUFFIX ":\
  52. " DEF_SYSROOT "/usr/local/qt/lib" RUN_LIBSUFFIX ":\
  53. " DEF_SYSROOT "/usr/gnome/lib" RUN_LIBSUFFIX "/mozilla/lib:\
  54. " DEF_SYSROOT "/usr/lib" RUN_LIBSUFFIX "/perl5/" PERL_VERS "/" RUN_ARCH "-linux-thread-multi/CORE:\
  55. "
  56.  
  57. #ifndef MACHINE_QEMU_SYSROOT
  58. #define MACHINE_QEMU_SYSROOT "/sr7"
  59. #endif /*MACHINE_QEMU_SYSROOT*/
  60.  
  61. #ifndef JAVA_VERS
  62. #define JAVA_VERS "jdk8u-jdk8u102-b14"
  63. #endif /*JAVA_VERS*/
  64.  
  65. #define JAVA_TRAP "/dosy/src/java/" JAVA_VERS "-" EMU_ARCH "/bin/"
  66. #define JAVA_OUTP "/dosy/src/java/" JAVA_VERS "-" RUN_ARCH "/bin/"
  67.  
  68. //#define ICED_TRAP "/dosy/src/java/icedtea6-0-" EMU_ARCH "/bin/"
  69. //#define ICED_OUTP "/dosy/src/java/icedtea6-0-" RUN_ARCH "/bin/"
  70.  
  71. #if !defined(GCC_BOLD) && 1
  72. #define GCC_BOLD "4.9.4"
  73. #endif /*GCC_BOLDS*/
  74. #if !defined(GCC_COLD) && 0
  75. #define GCC_COLD "4.8.5"
  76. #endif /*GCC_COLDS*/
  77.  
  78.  
  79. /*
  80. if [ "x86_64" = "`uname -m`" ]; then moddir="/usr/local/x86_64-pc-linux-gnu/lib/modules/`uname -r`";else moddir="/lib/modules/`uname -r`";fi;
  81. if lsmod | grep -q binfmt_misc; then true; else insmod "${moddir}/kernel/fs/binfmt_misc.ko";fi;
  82. if [ ! -f /proc/sys/fs/binfmt_misc/register ]; then mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc;fi;
  83.  
  84. echo ":arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/lib64/bin/execproxy-$(uname -m):" \
  85. >/proc/sys/fs/binfmt_misc/register
  86.  
  87.  
  88. mount ant9:/ /sr7; #mount --bind /dosy/src/tmp/root-arm /sr7; ### /root/config/config-glibc-2.9.0 "" qemu-wrapper-glibc
  89. mount --bind /dosy /sr7/dosy;
  90. mount -t proc . /sr7/proc;mount -t sysfs . /sr7/sys;mount -r --bind / /sr7/sr9;mount --bind /dev/pts/ /sr7/dev/pts/
  91. #mkdir -p /sr7/lib64/;rm -f /sr7/lib64/ld-linux-x86-64.so.2;cp -dpR /dosy/pkg/high-pack/boot/ld-linux-x86-64.so.2.xz /sr7/lib64/; xz -dv /sr7/lib64/ld-linux-x86-64.so.2.xz; ### ZZ_LIBRARY_PATH compatible
  92. #mkdir -p /sr7/usr/local/x86_64-pc-linux-gnu;mount -r --bind /sr7/sr9/usr/local/x86_64-pc-linux-gnu /sr7/usr/local/x86_64-pc-linux-gnu;
  93. #mkdir -p /sr7/usr/local/arm-pc-linux-gnueabihf/lib; (for w in $(cd /sr7/usr/lib/; echo libstdc*); do cd /sr7/usr/local/arm-pc-linux-gnueabihf/lib;ln -snf ../../../lib/$w $w;done );
  94. #mkdir -p /sr7/usr/lib64;ln -snf /sr9/usr/lib64/perl5 /sr7/usr/lib64/perl5;ln -snf /sr9/usr/lib64/locale /sr7/usr/lib64/locale;ln -snf /sr9/usr/lib64/gconv /sr7/usr/lib64/gconv;
  95. mount -r --bind /dosz /sr7/dosz;
  96. #tar xvf /dosy/pkg/high-pack/qemu/qemu-2.5.0-arm_userstatic-x86_64-1.txz -C /sr7/ --transform="s,^./usr/local/bin/,lib64/," ./usr/local/bin/qemu-arm;cp -dpR /home/patrick/dev/system/execproxy /sr7/lib64/;
  97. chroot /sr7;
  98. . /etc/profile ; ldconfig; echo $ARCH
  99.  
  100. #-
  101. cd /tmp;
  102. #rm -Rf /sr7/lib64/{ld-linux-x86-64.so.2,ld-2.22.so,execproxy,qemu-arm}; rmdir /sr7/lib64/bin /sr7/lib64/; rm -Rf /sr7/usr/lib64/; rm -R /sr7/usr/local/arm-pc-linux-gnueabihf/;
  103. umount /sr7/dev/pts/ /sr7/usr/local/x86_64-pc-linux-gnu /sr7/sr9 /sr7/dosy /sr7/proc /sr7/sys /sr7/dosz;
  104. umount /sr7/;
  105. */
  106.  
  107. /*
  108. for f in $(file * | sed -r -n 's/:[ \t]+ELF 64-bit LSB executable, x86-64, version 1 .*$//p'); do cp /sr7/usr/bin/true $f;done
  109. */
  110.  
  111. /* generate ld.so ZZ_ : #/root/config/config-glibc-2.9.0 "" zzglibc
  112. sed -r -i 's/"LD_LIBRARY_PATH"/"ZZ_LIBRARY_PATH"/' /dosy/src/glibc-2.22/elf/dl-load.c /dosy/src/glibc-2.22/elf/dl-support.c:
  113. sed -r -i "s/'L'/'Z'/; s/'D'/'Z'/;" /dosy/src/glibc-2.22/elf/dl-environ.c; #LD prefix -> ZZ prefix
  114. ( cd /dosy/src/glibc;make)
  115. cp -dpR /dosy/src/glibc/elf/ld.so /dosy/pkg/high-pack/boot/ld-linux-x86-64.so.2
  116. xz -9ev /dosy/pkg/high-pack/boot/ld-linux-x86-64.so.2
  117.  
  118. ZZ_LIBRARY_PATH="/usr/X11R6/lib64" /dosy/src/glibc/elf/ld.so --inhibit-cache --list /usr/local/bin/octave
  119. */
  120.  
  121. // rm -f /sr7/tmp/execproxy.log;touch /sr7/tmp/execproxy.log;chown nobody.users /sr7/tmp/execproxy.log;chmod 660 /sr7/tmp/execproxy.log;make execproxy_s; cp -dpR execproxy "/sr7/lib64/bin/"
  122. //
  123. // cat /sr7/tmp/execproxy.log | grep qemu-arm | gawk -F, '{printf("%s\n",$2);}' | sort | uniq
  124.  
  125.  
  126.  
  127.  
  128. static int s_execv(const char *const name, int afn, char *const argfirst[], const int argc, char *argv[]) {
  129. //sizeof(s_proxyprg)/sizeof(*s_proxyprg)
  130. int err, i;
  131. char *s_proxyarg[(argc-1) + afn + 1 ];
  132.  
  133. for (i=0;i<afn;i++) { s_proxyarg[i]=argfirst[i]; }
  134. for (i=0;i<argc-1;i++) { s_proxyarg[i + afn]=argv[i+1]; }
  135. s_proxyarg[(sizeof(s_proxyarg)/sizeof(*s_proxyarg))-1] = NULL;
  136.  
  137. #ifdef DEF_DEBUG
  138. { fprintf(stderr,">"); for (i=0;i<(sizeof(s_proxyarg)/sizeof(*s_proxyarg))-1;i++) { fprintf(stderr,"'%s',",s_proxyarg[i]); } fprintf(stderr,"\n"); }
  139. #endif /*DEF_DEBUG*/
  140. #ifdef DEF_DEBUG2
  141. { FILE *f=fopen("/tmp/execproxy.log","a"); fprintf(f,">'%s'>",name); for (i=0;i<(sizeof(s_proxyarg)/sizeof(*s_proxyarg))-1;i++) { fprintf(f,"'%s',",s_proxyarg[i]); } fprintf(f,"\n"); fclose(f); }
  142. #endif /*DEF_DEBUG2*/
  143.  
  144. err = execv(name, s_proxyarg);
  145. //printf("error");
  146. return err;
  147. }
  148.  
  149. static int s_execsubroot(const char *const name, int afn, char *const argfirst[],const int argc, char *argv[]) {
  150. // echo /sr9/lib64:/sr9/usr/lib64:$(cat /etc/ld.so.conf|grep 64|sed "/^#/ D;"|sed "s,^,/sr9,")|sed "s/ /:/g"
  151. setenv(DEF_LD_LIBRARY_PATH_NAME, DEF_LD_LIBRARY_PATH_PATH, 1);
  152. return s_execv(name, afn, argfirst, argc-1, &argv[1]);
  153. }
  154.  
  155. #if 0
  156. static int s_execsubroot_noldpath(const char *const name, int afn, char *const argfirst[],const int argc, char *argv[]) {
  157. //setenv(DEF_LD_LIBRARY_PATH_NAME, "", 1);
  158. return s_execv(name, afn, argfirst, argc-1, &argv[1]);
  159. }
  160. #endif
  161.  
  162. int main(const int argc, char *argv[], char *envp[]) {
  163. int err = 0;
  164. char *s_cmd=argv[1];
  165.  
  166. #ifdef DEF_DEBUG
  167. { int i; fprintf(stderr,"#"); for (i=0;i<argc;i++) { fprintf(stderr,"'%s',",argv[i]); } fprintf(stderr,"\n"); }
  168. #endif
  169. #ifdef DEF_DEBUG2
  170. { int i; FILE *f=fopen("/tmp/execproxy.log","a"); fprintf(f,"#"); for (i=0;i<argc;i++) { fprintf(f,"'%s',",argv[i]); } fprintf(f,"\n"); fclose(f); }
  171. #endif
  172.  
  173. if (argc<2) exit(-1);
  174.  
  175. #ifdef DEF_CROSSROOT
  176. if (!strcmp(s_cmd, "/bin/ls") || !strcmp(s_cmd, "/usr/bin/ls") ||
  177. !strcmp(s_cmd, "/bin/sed") || !strcmp(s_cmd, "/usr/bin/sed") ||
  178. !strcmp(s_cmd, "/bin/grep") || !strcmp(s_cmd, "/usr/bin/grep") ||
  179. !strcmp(s_cmd, "/bin/gzip") || !strcmp(s_cmd, "/usr/bin/gzip") ||
  180. !strcmp(s_cmd, "/bin/cat") || !strcmp(s_cmd, "/usr/bin/cat") ||
  181. !strcmp(s_cmd, "/bin/cp") || !strcmp(s_cmd, "/usr/bin/cp") ||
  182. !strcmp(s_cmd, "/bin/ln") || !strcmp(s_cmd, "/usr/bin/ln") ||
  183. !strcmp(s_cmd, "/bin/mv") || !strcmp(s_cmd, "/usr/bin/mv") ||
  184. !strcmp(s_cmd, "/bin/ln") || !strcmp(s_cmd, "/usr/bin/ln") ||
  185. !strcmp(s_cmd, "/bin/rm") || !strcmp(s_cmd, "/usr/bin/rm") ||
  186. !strcmp(s_cmd, "/bin/du") || !strcmp(s_cmd, "/usr/bin/du") ||
  187. !strcmp(s_cmd, "/bin/pwd") || !strcmp(s_cmd, "/usr/bin/pwd") ||
  188. !strcmp(s_cmd, "/bin/echo") || !strcmp(s_cmd, "/usr/bin/echo") ||
  189. !strcmp(s_cmd, "/bin/rmdir") || !strcmp(s_cmd, "/usr/bin/rmdir") ||
  190. !strcmp(s_cmd, "/bin/mkdir") || !strcmp(s_cmd, "/usr/bin/mkdir") ||
  191. !strcmp(s_cmd, "/bin/chmod") || !strcmp(s_cmd, "/usr/bin/chmod") ||
  192. !strcmp(s_cmd, "/bin/true") || !strcmp(s_cmd, "/bin/false") || !strcmp(s_cmd, "/usr/bin/true") || !strcmp(s_cmd, "/usr/bin/false") ||
  193. !strcmp(s_cmd, "/usr/bin/grep") || !strcmp(s_cmd, "/usr/bin/egrep") || !strcmp(s_cmd, "/usr/bin/fgrep") || !strcmp(s_cmd, "/usr/bin/id") ||
  194. !strcmp(s_cmd, "/usr/bin/m4") || !strcmp(s_cmd, "/usr/bin/tar") || !strcmp(s_cmd, "/usr/bin/xz") || !strcmp(s_cmd, "/usr/bin/sort") || !strcmp(s_cmd, "/usr/bin/expr") ||
  195. !strcmp(s_cmd, "/usr/bin/tail") || !strcmp(s_cmd, "/usr/bin/lzma") || !strcmp(s_cmd, "/usr/bin/chown") || !strcmp(s_cmd, "/usr/bin/dirname") || !strcmp(s_cmd, "/usr/bin/cmp") ||
  196. !strcmp(s_cmd, "/usr/bin/wc") || !strcmp(s_cmd, "/usr/bin/xargs") || !strcmp(s_cmd, "/usr/bin/touch") || !strcmp(s_cmd, "/usr/bin/gawk") || !strcmp(s_cmd, "/usr/bin/awk") || !strcmp(s_cmd, "/usr/bin/cut") ||
  197. !strcmp(s_cmd, "/usr/bin/md5sum") || !strcmp(s_cmd, "/usr/bin/uniq") || !strcmp(s_cmd, "/usr/bin/od") || !strcmp(s_cmd, "/usr/bin/dd") || !strcmp(s_cmd, "/usr/bin/df") || !strcmp(s_cmd, "/usr/bin/find") ||
  198. !strcmp(s_cmd, "/usr/bin/comm") || !strcmp(s_cmd, "/usr/bin/mktemp") || !strcmp(s_cmd, "/usr/bin/diff") || !strcmp(s_cmd, "/usr/bin/sleep") || !strcmp(s_cmd, "/usr/bin/tr") ||
  199. !strcmp(s_cmd, "/usr/bin/less") || !strcmp(s_cmd, "/usr/bin/file") || !strcmp(s_cmd, "/usr/bin/patch") || !strcmp(s_cmd, "/usr/bin/date") || !strcmp(s_cmd, "/usr/bin/basename") || !strcmp(s_cmd, "/usr/bin/split") ||
  200. !strcmp(s_cmd, "/usr/bin/groff") || !strcmp(s_cmd, "/usr/bin/troff") || !strcmp(s_cmd, "/usr/bin/rev") || !strcmp(s_cmd, "/usr/bin/paste") || !strcmp(s_cmd, "/usr/bin/readlink") || !strcmp(s_cmd, "/usr/bin/numfmt") ||
  201. !strcmp(s_cmd, "/usr/bin/xzcat") || !strcmp(s_cmd, "/usr/bin/tput") || !strcmp(s_cmd, "/usr/bin/head") || !strcmp(s_cmd, "/usr/bin/env") || !strcmp(s_cmd, "/usr/bin/unlzma") || !strcmp(s_cmd, "/usr/bin/bzip2") ||
  202. !strcmp(s_cmd, "/usr/bin/msgfmt") || !strcmp(s_cmd, "/usr/bin/xgettext") || !strcmp(s_cmd, "/usr/bin/msgmerge") ||
  203. !strcmp(s_cmd, "/usr/bin/cpio") || !strcmp(s_cmd, "/usr/bin/join") || !strcmp(s_cmd, "/usr/bin/mkfifo") || !strcmp(s_cmd, "/usr/bin/printf") || !strcmp(s_cmd, "/usr/bin/chroot") ||
  204. !strcmp(s_cmd, "/usr/bin/seq") || !strcmp(s_cmd, "/usr/bin/test") || !strcmp(s_cmd, "/usr/bin/dircolors") || !strcmp(s_cmd, "/usr/bin/etags") ||
  205. !strcmp(s_cmd, "/bin/tee") || !strcmp(s_cmd, "/usr/bin/tee") || !strcmp(s_cmd, "/usr/gnome/bin/pkg-config") || !strcmp(s_cmd, "/usr/bin/time") || !strcmp(s_cmd, "/usr/bin/tbl") ||
  206. !strcmp(s_cmd, "/usr/local/bin/zip") || !strcmp(s_cmd, "/usr/local/bin/unzip") || !strcmp(s_cmd, "/usr/bin/gjar")
  207. ) {
  208. char s[128]=DEF_SYSROOT; strncat(s, s_cmd, sizeof(s));
  209. //char *const s_proxyprg[] = { s_cmd, "--inhibit-cache", "--library-path", DEF_LD_LIBRARY_PATH_PATH, s };
  210. //err = s_execsubroot_noldpath("/lib64/ld-linux-x86-64.so.2", sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  211. char *const s_proxyprg[] = { s_cmd }; err = s_execsubroot(s, sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  212. } else if (!strcmp(s_cmd, "/usr/bin/make") || !strcmp(s_cmd, "/bin/make") || !strcmp(s_cmd, "/bin/bash") || !strcmp(s_cmd, "/bin/sh") || !strcmp(s_cmd, "/usr/bin/bash")) {
  213. char s[128]=DEF_SYSROOT; strncat(s, s_cmd, sizeof(s));
  214. char *const s_proxyprg[] = { s_cmd }; err = s_execsubroot(s, sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  215. #if 1
  216. } else if (!strcmp(s_cmd, "/usr/gnome/bin/xsltproc") || !strcmp(s_cmd, "/usr/gnome/bin/xmllint")) { // required: /usr/lib64/gconv/*.so
  217. char s[128]=DEF_SYSROOT; strncat(s, s_cmd, sizeof(s));
  218. char *const s_proxyprg[] = { s_cmd };
  219. setenv("GCONV_PATH", DEF_SYSROOT "/usr/lib" RUN_LIBSUFFIX "/gconv", 1);
  220. err = s_execsubroot(s, sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  221. #endif
  222. } else if (!strcmp(s_cmd, "/usr/bin/gcc") || !strcmp(s_cmd, "/usr/bin/" MACHINE_TARGET "-gcc") || !strcmp(s_cmd, "/usr/bin/cc")) {
  223. char *const s_proxyprg[] = { DEF_SYSROOT "/usr/local/bin/" MACHINE_TARGET "-gcc", "--sysroot", "/" }; err = s_execsubroot(s_proxyprg[0], sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  224. } else if (!strcmp(s_cmd, "/usr/bin/g++") || !strcmp(s_cmd, "/usr/bin/" MACHINE_TARGET "-g++") || !strcmp(s_cmd, "/usr/bin/c++")) {
  225. char *const s_proxyprg[] = { DEF_SYSROOT "/usr/local/bin/" MACHINE_TARGET "-g++", "--sysroot", "/" }; err = s_execsubroot(s_proxyprg[0], sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  226. } else if (!strcmp(s_cmd, "/usr/bin/gfortran") || !strcmp(s_cmd, "/usr/bin/" MACHINE_TARGET "-gfortran")) { //octave
  227. char *const s_proxyprg[] = { DEF_SYSROOT "/usr/local/bin/" MACHINE_TARGET "-gfortran", "--sysroot", "/" }; err = s_execsubroot(s_proxyprg[0], sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  228. } else if (!strcmp(s_cmd, "/usr/bin/gcj") || !strcmp(s_cmd, "/usr/bin/" MACHINE_TARGET "-gcj")) {
  229. char *const s_proxyprg[] = { DEF_SYSROOT "/usr/local/bin/" MACHINE_TARGET "-gcj", "--sysroot", "/" }; err = s_execsubroot(s_proxyprg[0], sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  230. } else if (!strcmp(s_cmd, "/usr/bin/../libexec/gcc/" MACHINE_TARGET "/" GCC_VERS "/cc1")) {
  231. char *const s_proxyprg[] = { DEF_SYSROOT "/usr/local/libexec/gcc/" MACHINE_TARGET "/" GCC_VERS "/cc1" }; err = s_execsubroot(s_proxyprg[0], sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  232. } else if (!strcmp(s_cmd, "/usr/bin/../libexec/gcc/" MACHINE_TARGET "/" GCC_VERS "/cc1plus")) {
  233. char *const s_proxyprg[] = { DEF_SYSROOT "/usr/local/libexec/gcc/" MACHINE_TARGET "/" GCC_VERS "/cc1plus" }; err = s_execsubroot(s_proxyprg[0], sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  234. } else if (!strcmp(s_cmd, "/usr/bin/strip") ||
  235. !strcmp(s_cmd, "/usr/bin/as") ||
  236. !strcmp(s_cmd, "/usr/bin/nm") ||
  237. !strcmp(s_cmd, "/usr/bin/ar") ||
  238. !strcmp(s_cmd, "/usr/bin/ranlib") ||
  239. !strcmp(s_cmd, "/usr/bin/ld") ||
  240. !strcmp(s_cmd, "/usr/bin/objdump") ||
  241. !strcmp(s_cmd, "/usr/bin/objcopy") ||
  242. !strcmp(s_cmd, "/usr/bin/size") ||
  243. !strcmp(s_cmd, "/usr/bin/cpp") /*|| !strcmp(s_cmd, "/lib/cpp")*/) {
  244. char s[128]=DEF_SYSROOT "/usr/local/bin/" MACHINE_TARGET "-"; strncat(s, &s_cmd[strlen("/usr/bin/")], sizeof(s));
  245. char *const s_proxyprg[] = { s_cmd }; err = s_execsubroot(s, sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  246. } else if (!strcmp(s_cmd, "/usr/bin/" MACHINE_TARGET "-strip") ||
  247. !strcmp(s_cmd, "/usr/bin/" MACHINE_TARGET "-as") ||
  248. !strcmp(s_cmd, "/usr/bin/" MACHINE_TARGET "-nm") ||
  249. !strcmp(s_cmd, "/usr/bin/" MACHINE_TARGET "-ar") ||
  250. !strcmp(s_cmd, "/usr/bin/" MACHINE_TARGET "-ranlib") ||
  251. !strcmp(s_cmd, "/usr/bin/" MACHINE_TARGET "-ld") ||
  252. !strcmp(s_cmd, "/usr/bin/" MACHINE_TARGET "-objdump") ||
  253. !strcmp(s_cmd, "/usr/bin/" MACHINE_TARGET "-objcopy") ||
  254. !strcmp(s_cmd, "/usr/bin/" MACHINE_TARGET "-size") ||
  255. !strcmp(s_cmd, "/usr/bin/" MACHINE_TARGET "-cpp")) {
  256. char s[128]=DEF_SYSROOT "/usr/local/bin/" MACHINE_TARGET "-"; strncat(s, &s_cmd[strlen("/usr/bin/" MACHINE_TARGET "-")], sizeof(s));
  257. char *const s_proxyprg[] = { s_cmd }; err = s_execsubroot(s, sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  258. } else if (!strcmp(s_cmd, "/usr/" MACHINE_TARGET "/bin/strip") ||
  259. !strcmp(s_cmd, "/usr/" MACHINE_TARGET "/bin/as") ||
  260. !strcmp(s_cmd, "/usr/" MACHINE_TARGET "/bin/nm") ||
  261. !strcmp(s_cmd, "/usr/" MACHINE_TARGET "/bin/ar") ||
  262. !strcmp(s_cmd, "/usr/" MACHINE_TARGET "/bin/ranlib") ||
  263. (!strcmp(s_cmd, "/usr/" MACHINE_TARGET "/bin/ld") && !(argc>=4 && !strcmp(argv[2], "-plugin")) ) || //* gcc-5.3.0: -plugin arg requires local ld*/
  264. !strcmp(s_cmd, "/usr/" MACHINE_TARGET "/bin/objdump") ||
  265. !strcmp(s_cmd, "/usr/" MACHINE_TARGET "/bin/objcopy") ||
  266. !strcmp(s_cmd, "/usr/" MACHINE_TARGET "/bin/cpp")) {
  267. char s[128]=DEF_SYSROOT "/usr/local/bin/" MACHINE_TARGET "-"; strncat(s, &s_cmd[strlen("/usr/" MACHINE_TARGET "/bin/")], sizeof(s));
  268. char *const s_proxyprg[] = { s_cmd }; err = s_execsubroot(s, sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  269. } else if ((argc >= 3 && (!strcmp(s_cmd, "/usr/bin/perl") && (!strcmp(argv[2], "/usr/bin/makeinfo") || !strcmp(argv[2], "/usr/bin/autoheader") || !strcmp(argv[2], "/usr/bin/pod2man") ))) ||
  270. (argc >= 4 && (!strcmp(s_cmd, "/usr/bin/perl") && !strcmp(argv[2], "-w") &&
  271. (!strcmp(argv[3], "/usr/bin/aclocal") || !strcmp(argv[3], "/usr/bin/aclocal") || !strcmp(argv[3], "/usr/bin/autom4te") || !strcmp(argv[3], "/usr/bin/autoheader") ||
  272. !strcmp(argv[3], "/usr/bin/automake") || !strcmp(argv[3], "/usr/bin/aclocal") || !strcmp(argv[3], "/usr/bin/aclocal-1.15") || !strcmp(argv[3], "/usr/bin/automake-1.15") ||
  273. !strcmp(argv[3], "/usr/gnome/bin/intltool-merge") || !strcmp(argv[3], "/usr/gnome/bin/intltool-update") ))) // required: /usr/lib64/perl5
  274. ) { //process safe perl process only ////// fgrep "qemu-arm','/usr/bin/perl'" /sr7/tmp/execproxy.log | less
  275. char s[128]=DEF_SYSROOT; strncat(s, s_cmd, sizeof(s));
  276. char *const s_proxyprg[] = { s_cmd };
  277. setenv("PERL5LIB", DEF_SYSROOT "/usr/lib" RUN_LIBSUFFIX "/perl5/site_perl/" PERL_VERS "/x86_" RUN_LIBSUFFIX "-linux-thread-multi:" DEF_SYSROOT "/usr/lib" RUN_LIBSUFFIX "/perl5/site_perl/" PERL_VERS ":" DEF_SYSROOT "/usr/lib" RUN_LIBSUFFIX "/perl5/" PERL_VERS "/" RUN_ARCH "-linux-thread-multi:" DEF_SYSROOT "/usr/lib" RUN_LIBSUFFIX "/perl5/" PERL_VERS, 1);
  278. err = s_execsubroot(s, sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  279. } else if ((argc >= 3 && (!strcmp(s_cmd, "/usr/bin/python") || !strcmp(s_cmd, "/usr/bin/python2.7")) &&
  280. ((!strcmp(argv[2], "/usr/bin/scons")) || !strcmp(argv[2], "/usr/local/bin/asciidoc")
  281. /*|| !strcmp(argv[2], "/usr/gnome/bin/g-ir-scanner")*/ /*|| !strcmp(argv[2], "/usr/gnome/bin/xml2po")*/) ) // 'scons': serf, 'asciidoc': git, 'xml2po': gnome-games-2.32.1
  282. ) { //process safe python process only ////// egrep "qemu-arm','/usr/bin/python.*'" /sr7/tmp/execproxy.log | less
  283. char s[128]=DEF_SYSROOT; strncat(s, s_cmd, sizeof(s)); setenv("PYTHONHOME", DEF_SYSROOT "/usr", 1);
  284. char *const s_proxyprg[] = { s_cmd }; err = s_execsubroot(s, sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  285. #if 0 // ./ruby: failed ruby required some .so libs...
  286. } else if ((argc >= 2 && (!strcmp(s_cmd, "/usr/local/bin/ruby") || !strcmp(s_cmd, "./ruby")))) {
  287. char *const s_proxyprg[] = { s_cmd }; err = s_execsubroot(DEF_SYSROOT "/usr/local/bin/ruby", sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  288. #endif
  289. } else if (!strcmp(s_cmd, "/usr/local/bin/clang") || !strcmp(s_cmd, "/usr/bin/clang")) { //pkg: icu4c-56_1 (patch: +#LDFLAGSICUDT=-nodefaultlibs -nostdlib ### mandatory for arm)
  290. char *const s_proxyprg[] = { DEF_SYSROOT "/usr/local/bin/clang", "-target", MACHINE_LLVM_TARGET,
  291. "--sysroot", "/", "-L/usr/lib/gcc/" MACHINE_TARGET "/" GCC_VERS, "-B/usr/lib/gcc/" MACHINE_TARGET "/" GCC_VERS, "-I/usr/include/c++/" GCC_VERS, "-I/usr/include/c++/" GCC_VERS "/" MACHINE_TARGET "" };
  292. err = s_execsubroot(s_proxyprg[0], sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  293. } else if (!strcmp(s_cmd, "/usr/local/bin/clang++") || !strcmp(s_cmd, "/usr/bin/clang++")) {
  294. char *const s_proxyprg[] = { DEF_SYSROOT "/usr/local/bin/clang++", "-target", MACHINE_LLVM_TARGET,
  295. "--sysroot", "/", "-L/usr/lib/gcc/" MACHINE_TARGET "/" GCC_VERS, "-B/usr/lib/gcc/" MACHINE_TARGET "/" GCC_VERS, "-I/usr/include/c++/" GCC_VERS, "-I/usr/include/c++/" GCC_VERS "/" MACHINE_TARGET "" };
  296. err = s_execsubroot(s_proxyprg[0], sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  297. } else if (!strcmp(s_cmd, "/usr/local/bin/opt")) { // pkg: libclc
  298. char *const s_proxyprg[] = { s_cmd };
  299. err = s_execsubroot(DEF_SYSROOT "/usr/local/bin/opt", sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  300. } else if (!strncmp(s_cmd, JAVA_TRAP, strlen(JAVA_TRAP))) { // openjdk
  301. char s[128]=JAVA_OUTP; strncat(s, &s_cmd[strlen(JAVA_TRAP)], sizeof(s));
  302. char *const s_proxyprg[] = { s_cmd }; err = s_execsubroot(s, sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  303. #ifdef ICED_TRAP
  304. } else if (!strncmp(s_cmd, ICED_TRAP, strlen(ICED_TRAP))) { // icedtea
  305. char s[128]=ICED_OUTP; strncat(s, &s_cmd[strlen(ICED_TRAP)], sizeof(s));
  306. char *const s_proxyprg[] = { s_cmd }; err = s_execsubroot(s, sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  307. #endif /*ICED_TRAP*/
  308. #ifdef GCC_VERS
  309. } else if (!strcmp(s_cmd, "/usr/bin/" MACHINE_TARGET "-gcc-" GCC_VERS)) {
  310. char *const s_proxyprg[] = { DEF_SYSROOT "/usr/local/bin/" MACHINE_TARGET "-gcc-" GCC_VERS, "--sysroot", "/" }; err = s_execsubroot(s_proxyprg[0], sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  311. #endif /*GCC_VERS*/
  312. #ifdef GCC_BOLD
  313. } else if (!strcmp(s_cmd, "/usr/bin/" MACHINE_TARGET "-gcc-" GCC_BOLD)) {
  314. char *const s_proxyprg[] = { DEF_SYSROOT "/usr/local/bin/" MACHINE_TARGET "-gcc-" GCC_BOLD, "--sysroot", "/" }; err = s_execsubroot(s_proxyprg[0], sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  315. #endif /*GCC_BOLD*/
  316. #ifdef GCC_COLD
  317. } else if (!strcmp(s_cmd, "/usr/bin/" MACHINE_TARGET "-gcc-" GCC_COLD)) {
  318. char *const s_proxyprg[] = { DEF_SYSROOT "/usr/local/bin/" MACHINE_TARGET "-gcc-" GCC_COLD, "--sysroot", "/" }; err = s_execsubroot(s_proxyprg[0], sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  319. #endif /*GCC_COLD*/
  320. } else if (!strcmp(s_cmd, "/usr/bin/git")) {
  321. char s[128]=DEF_SYSROOT; strncat(s, s_cmd, sizeof(s)); setenv("GIT_EXEC_PATH", DEF_SYSROOT "/usr/libexec/git-core", 1); // git --exec-path
  322. char *const s_proxyprg[] = { s_cmd }; err = s_execsubroot(s, sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  323. } else {
  324. char *const s_proxyprg[] = { "/lib" RUN_LIBSUFFIX "/bin/qemu-" MACHINE_QEMU_TARGET "-" RUN_ARCH, };
  325. //printf("error");
  326. err = s_execv(s_proxyprg[0], sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  327. }
  328. #else /*DEF_CROSSROOT*/
  329. {
  330. char *const s_proxyprg[] = { "/lib" RUN_LIBSUFFIX "/bin/qemu-" MACHINE_QEMU_TARGET, "-L", MACHINE_QEMU_SYSROOT };
  331. setenv(DEF_LD_LIBRARY_PATH_NAME, "", 1);
  332. err = s_execv(s_proxyprg[0], sizeof(s_proxyprg)/sizeof(*s_proxyprg), s_proxyprg, argc, argv);
  333. }
  334. #endif /*DEF_CROSSROOT*/
  335. return err;
  336. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement