[PATCH] sh: Add PIC implementation for crt1.S

Carmelo AMOROSO carmelo.amoroso at st.com
Thu Apr 30 14:41:28 UTC 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Peter Griffin wrote:
>> Hi Peter,
>> where is it supposed to be required to be PIC... for PIE programs?
>> Indeed I'm seeing a problem with dbus due to TEXTREL that are not
>> allowed by ld.so for sh4... and I've seen that the relocations are
>> from crt1.S related to uCLibc_main and abort... so I'm thinking that
>> your patch will solve my issue too ;-)
>>
>> cheers,
>> carmelo
>>
>> Hi Carmelo,
>>
>> Yes for PIE programs, I wrote the patch to get PIE running on SH2A
>> NOMMU, with the ultimate aim of one day having XIP and shared libs in
>> uClinux for SH2A.
>>
>> I can't get XIP running yet because of a SH toolchain issue. I believe
>> SH needs an equivalent of single-pic-base like in ARM, so the PIC
>> register is not setup in the prologue of every function.
>>
>> Hopefully it will fix your issue to :-)
>>
>> regards, 
>>
>> Pete.
> 
> 

Hi Pete,
I tried you patch but I cannot link a pie application (simple hello)
due to linker error as below:

/opt/STM/STLinux-2.3/devkit/sh4_uclibc/lib/gcc/sh4-linux-uclibc/4.2.4/../../../../sh4-linux-uclibc/bin/ld:
/opt/STM/STLinux-2.3/devkit/sh4_uclibc/target/usr/lib/Scrt1.o(.text+0x40):
unresolvable R_SH_GOTOFF relocation against symbol `__uClibc_main'
/opt/STM/STLinux-2.3/devkit/sh4_uclibc/lib/gcc/sh4-linux-uclibc/4.2.4/../../../../sh4-linux-uclibc/bin/ld:
final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status

I've fixed your patch... GOTOFF relocation should be used for static
data access, not for function call. I've fixed it by using a GOT
entry. I've linked a pie hello application and I do not have any
TEXTREL.
Please may you try my version (attached) on your system.

Thanks,
Carmelo
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkn5uJgACgkQoRq/3BrK1s9jrwCghPI8T44YckBUfL3Ke6p8SEiZ
HqQAoL4nbp3dPrZFEg4CB5Njjrt7s10x
=fXiH
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: crt1_sh.patch
Type: application/mbox
Size: 1526 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/uclibc/attachments/20090430/ae8d5a04/attachment.bin>


More information about the uClibc mailing list