Mixing libraries for different architectures into a shared lib

Erik Leunissen e.leunissen@hccnet.nl
Sat Jan 21 00:22:00 GMT 2012


L.S.

I'd like to understand what happens when I (inadvertently) link object 
files for different architectures like this (all build commands being 
done on linux for linux target):

# two source files:
lib1.c
lib2.c

# compiling one for i386 and the other for i686
gcc -march=i386 -o lib1.o -c lib1.c
gcc -march=i686 -o lib2.o -c lib2.c

# linking the both into a shared lib
gcc -shared -o myshlib.so lib1.o lib2.o

I can imagine that things go wrong at load time or run time when 
launching a program (on a i686 machine) that uses myshlib.so:
- does it run?
- will it even load myshlib.so at runtime?

Does it make a difference if the binaries are produced for windows 
(using a cross-toolchain and adjusting file names properly, of course)?


Thanks in advance for any insight,

Erik Leunissen.



More information about the Binutils mailing list