[PATCH][M68K] Fix shared libraries on uClinux
Maxim Kuvyrkov
maxim@codesourcery.com
Wed Nov 19 13:46:00 GMT 2008
Hello,
At the moment binaries built for M68K uClinux -mid-shared-library fail
with 'Illegal instruction' error. The problem is in assembler piece of
libgcc that provides FP routines for FPU-less cores.
The attached patch fixes this problem. OK for trunk?
Analysis:
1. Libstdc++ library is compiled with -mid-shared-library.
2. A program that has floating point operation (e.g., compare) is
compiled for an fpu-less CPU. This FP operation is implemented with
couple of functions: implementation (__cmpsf_internal) and wrapper
(__eqsf2). To handle FP operation an object file is being included from
libgcc.a (_eqsf2.o). As we compile against shared libstdc++, which
already has linked in __cmpsf_internal, we only link in the wrapper
(__eqsf2) to executable.
3. The wrapper (_eqsf2) contains PC-relative relocation to call the
implementation (__cmpsf_internal). When the wrapper is being linked
into the executable, this relocation resolves to symbol in the shared
library (libstdc++) and PC-relative offset is written to the binary. The
linker assumes that the binary will be loaded at address 0x0. At
runtime the binary is not being loaded at 0x0 and the wrong offset
triggers jump to nowhere.
The attached patch fixes this problem by using GOT instead of
PC-relative addressing and by hiding implementation functions so that
only wrappers are visible to outside world.
--
MaximK
CodeSourcery
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cf-uclinux-pic.ChangeLog
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20081119/3e493cf7/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cf-uclinux-pic.patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20081119/3e493cf7/attachment-0001.ksh>
More information about the Gcc-patches
mailing list