Skip to content
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

MinGW cross-compilation fails due to .size/.type directives #9

Closed
dwmw2 opened this issue Jun 17, 2021 · 4 comments
Closed

MinGW cross-compilation fails due to .size/.type directives #9

dwmw2 opened this issue Jun 17, 2021 · 4 comments

Comments

@dwmw2
Copy link

dwmw2 commented Jun 17, 2021

Building for Win64, I get:

$ CC="x86_64-w64-mingw32-gcc" /usr/bin/perl ../aesni/aesni-x86_64.pl | sed s/OPENSSL_ia32/OPENCONNECT_ia32/g > aesni-x86_64.s
$ x86_64-w64-mingw32-gcc  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 -c -o aesni-x86_64.o aesni-x86_64.s
aesni-x86_64.s: Assembler messages:
aesni-x86_64.s:4: Warning: .type pseudo-op used outside of .def/.endef: ignored.
aesni-x86_64.s:4: Error: junk at end of line, first unrecognized character is `a'
aesni-x86_64.s:27: Warning: .size pseudo-op used outside of .def/.endef: ignored.
aesni-x86_64.s:27: Error: junk at end of line, first unrecognized character is `a'
…
@dot-asm
Copy link
Owner

dot-asm commented Jun 18, 2021

You've got to "flavour" it, perl <script> mingw64. As for sed-ing, another possibility is to change suffix to .S, capital S, and use -D at compiler line.

@dwmw2
Copy link
Author

dwmw2 commented Jun 18, 2021

Thanks, that works. I'm dusting off the OpenConnect AES-NI support, at https://gitlab.com/openconnect/openconnect/-/commits/hacks2/

I have bigger problems with OPEN{SSL,CONNECT}_ia32cap_P anyway... now the Android build is failing because it wants PIC support:

/opt/android-sdk-linux_x86/toolchains/x86_64-linux-android-23/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: .libs/aesni-sha1-x86_64.o: requires dynamic R_X86_64_PC32 reloc against 'OPENCONNECT_ia32cap_P' which may overflow at runtime; recompile with -fPIC
/opt/android-sdk-linux_x86/toolchains/x86_64-linux-android-23/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: .libs/aesni-x86_64.o: requires dynamic R_X86_64_PC32 reloc against 'OPENCONNECT_ia32cap_P' which may overflow at runtime; recompile with -fPIC
/opt/android-sdk-linux_x86/toolchains/x86_64-linux-android-23/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: .libs/sha1-x86_64.o: requires dynamic R_X86_64_PC32 reloc against 'OPENCONNECT_ia32cap_P' which may overflow at runtime; recompile with -fPIC
/opt/android-sdk-linux_x86/toolchains/x86_64-linux-android-23/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: warning: shared library text segment is not shareable

@dwmw2 dwmw2 closed this as completed Jun 18, 2021
@dot-asm
Copy link
Owner

dot-asm commented Jun 18, 2021

recompile with -fPIC

I for one argue that it should be a warning, not error. But anyway. Declare the affected symbol hidden, for example with __attribute__((visibility("hidden"))), or use -Wl,-Bsymbolic flag when linking shared object. -Wl,-Bsymbolic is generally better for security, because other shared libraries won't override internal symbols in your shared library, unintentionally or not.

@dwmw2
Copy link
Author

dwmw2 commented Jun 18, 2021

Got it, thanks. In fact OpenSSL's x86_64cpuid.pl was doing precisely that, but I'd ripped it out along with a lot of other things from that file, and kept only the OPENSSL_ia32_cpuid() function. I put it back , and my Android CI builds are now passing again; thanks.

This is giving me a 40% update on ESP performance; I'd love to have the licence issue resolved (#7) so that I can merge it for real into my LGPLv2.1-licensed project :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants