microsocks icon indicating copy to clipboard operation
microsocks copied to clipboard

Cross-compilation on arm and mips devices

Open cyadron opened this issue 6 years ago • 11 comments

Hello,

I have successfully cross-compiled microsocks on mips and also on arm devices. On mips devices it works good so far. But I have a strange issue when I tested on arm devices. Some sites fail to load (like google.com, yahoo.com) with an error message (reported by proxifier) - Address type not supported. But some sites load fine (except for elements from google.com domain) - like github.com What could be the issue because this does not happen on mips devices?

cyadron avatar Aug 14 '18 04:08 cyadron

does it work when you add -fsigned-char to your CFLAGS ?

rofl0r avatar Aug 14 '18 12:08 rofl0r

Unfortunately no. Still no go. I am getting other error also (with the original and the fsigned-char version). Proxy server cannot establish a connection with the target - Network unreachable. But some sites load fine.

cyadron avatar Aug 19 '18 04:08 cyadron

well from a C language PoV the only difference between x86 and ARM is that ARM defaults to char == unsigned char. so i'd suspect that your issues are related to the specific ARM box you use - maybe some firewall rules, or a bad connection ?

rofl0r avatar Aug 19 '18 14:08 rofl0r

I have tested another socks server on the same device and it loads the sites ok. Any other idea?

cyadron avatar Aug 21 '18 11:08 cyadron

you could try this: https://github.com/rofl0r/microsocks/issues/6 - increasing the stacksize

maybe for some reason the ARM implementation of GLIBC or whatever LIBC you use (which one is it?) wastes more RAM, and since google has a ton of DNS elements in its response it's sufficient to overwrite things and cause weird hickups.

rofl0r avatar Aug 22 '18 13:08 rofl0r

Until now I was using release 0.1.0. Now I am using the latest commit but I still have the problem. I have tried to set size_t stacksz = 512 * 1024; but nothing changed. The C library is uclibc. And I do get the warning that this library sucks when I cross-compile it but no other warning/errors. The error specified by proxifier is:

  • Proxy server cannot establish a connection with the target - Address type not supported.

and I get no other output/error on the arm machine where microsocks is running. Could the uclibc library create this problem?

cyadron avatar Aug 28 '18 05:08 cyadron

After more testing I find out that resolving hostnames through the socks server option causes problems. If I use an external dns server the sites load fine. I see that this is one difference between uclibc and glibc. According to this paper: https://mirrors.edge.kernel.org/pub/linux/libs/uclibc/Glibc_vs_uClibc_Differences.txt uclibc does not support DNS resolution. But since some sites load, I guess it is partially supported?

cyadron avatar Aug 28 '18 06:08 cyadron

yes, uclibc could be the culprit. i'd strongly suggest to use musl instead to build tiny static-linked binaries (build your own toolchain from the scripts in https://github.com/richfelker/musl-cross-make)

rofl0r avatar Aug 29 '18 15:08 rofl0r

Hi,

I finally built microsocks using musl. I have used the option for static-linked binaries and I was able to compile microsocks. I ended up with a binary 3 times bigger (64 KB). But the good news is that it works. Resolving hostnames finally works. So this workaround is good but I guess there is no way to make it work with the default compiler?

cyadron avatar Mar 02 '19 05:03 cyadron

hi, if you want a smaller binary you can try use the following flags in config.mak:

CFLAGS = -Os -flto
LDFLAGS = -s -flto

as for making it work with your uclibc toolchain: did you try latest git ? some bugs have been fixed since you opened your issue.

rofl0r avatar Mar 02 '19 13:03 rofl0r

Hi @cyadron could you explain to me the steps to cross-compile the project to mipsle32?

hdbreaker avatar Mar 27 '20 07:03 hdbreaker