1
votes

I wanted to create macOS binary for that Makefile project I had had for Linux.

Original Linux project links against elf32 static lib so I thought I could utilize objconv to do this conversion.

I do conversion by calling:

objconv -fmacho32 -nu lib_elf.a lib_macho.a

and get the following output:

Warning 1053: Common constant converted to public: triple_des_software_global_tdes_standard Warning 1053: Common constant converted to public: triple_des_software_global_mode Warning 1053: Common constant converted to public: triple_des_software_global_key Warning 1053: Common constant converted to public: maskk Warning 1053: Common constant converted to public: sbox Warning 1053: Common constant converted to public: _SM Warning 1053: Common constant converted to public: bit_size Warning 1053: Common constant converted to public: _local_ucl_a_sm2vp256 Warning 1053: Common constant converted to public: _local_ucl_inv2_sm2vp256 Warning 1053: Common constant converted to public: _local_ucl_p_sm2vp256 Warning 1053: Common constant converted to public: signature_computation Warning 1053: Common constant converted to public: _ucl_n_stored Warning 1053: Common constant converted to public: _ucl_rsqr_stored Warning 1053: Common constant converted to public: _ucl_r_stored Warning 1053: Common constant converted to public: sm2fp192 Warning 1053: Common constant converted to public: m0 Warning 1053: Common constant converted to public: shadec_ctx Warning 1053: Common constant converted to public: shasign_ctx Warning 1053: Common constant converted to public: aesctx Warning 1053: Common constant converted to public: W32 Warning 1053: Common constant converted to public: H32 Warning 1053: Common constant converted to public: a32 Warning 1053: Common constant converted to public: b32 Warning 1053: Common constant converted to public: c32 Warning 1053: Common constant converted to public: d32 Warning 1053: Common constant converted to public: e32 Warning 1053: Common constant converted to public: f32 Warning 1053: Common constant converted to public: g32 Warning 1053: Common constant converted to public: h32 Warning 1053: Common constant converted to public: workbuffer Warning 1053: Common constant converted to public: _stack Warning 1053: Common constant converted to public: _stack_index Warning 1053: Common constant converted to public: hash_size Warning 1053: Common constant converted to public: using_sha_hardwareInput library: lib_elf.a, Format: ELF, Output: lib_macho.a, Format: Mach-O Little Endian

392 Debug sections removed 147 Exception sections removed 1922 Changes in leading underscores on symbol names

I guess that it should be all right till now?

When I try to link against lib_macho.a I get following output:

make
gcc-4.0 -O3 -g0 -v -W -Wall -DWORD32 -m32  -I../include -I../include/ucl  -L.  -o ../bin/darwin/ca_sign_build test.o -m32 -v -l_macho
couldn't understand kern.osversion `16.7.0'
Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc_40/gcc_40-5494~315/src/configure --disable-checking -enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib --build=i686-apple-darwin10 --with-arch=apple --with-tune=generic --host=i686-apple-darwin10 --target=i686-apple-darwin10
Thread model: posix
gcc version 4.0.1 (Apple Inc. build 5494)
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../libexec/gcc/i686-apple-darwin10/4.0.1/collect2

-dynamic -arch i386 -macosx_version_min 10.4 -weak_reference_mismatches non-weak -o ../bin/darwin/ca_sign_build -lcrt1.o -L. -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/gcc/i686-apple-darwin10/4.0.1 -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/gcc -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/gcc/i686-apple-darwin10/4.0.1/../../.. test.o -l_macho -lgcc -lSystem ld: in ./lib_macho.a(ucl_sys.c.o), in section __TEXT,__text reloc 2: R_ABS reloc but no absolute symbol at target address for architecture i386 collect2: ld returned 1 exit status make: *** [ca_sign_build] Error 1

I couldn't google any useful text on:

ld: in ./lib_macho.a(ucl_sys.c.o), in section __TEXT,__text reloc 2: R_ABS reloc but no absolute symbol at target address for architecture i386

so I'm wondering if there is anyone who can tell me something about that linker error?

I tried using latest gcc that's clang/llvm based, gcc-4.2 and gcc-4.0 which I obtained by using xcodelegacy.sh by extracting those from xcode .dmg's but I always get the same error.

Is the error I get matter of version of gcc used or there's some additional instruction needed to be provided to objconv so I can workaround this issue?

Thanks!

1

1 Answers

2
votes

Conversion of an object or library file from one OS to another is only possible in very simple cases. Since you have the original source files, you should recompile them under Mac OS.