This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

sh-unknown-linux-gnu and shared library


NIIBE Yutaka wrote:
 > We needed small changes to GCC, I'll send patches to gcc-patches.
 > They are three things:
 > 	Support of no fdiv for integer division
 > 	Support of specific targets (sh3, sh4, sh3eb, and sh4eb)

I've sent the patches for those two.

 > 	Hide some libgcc functions to avoid unexpected register clobber

I think that Kaz will send the patch for this.  Before that, I'd like
to explain the problem.

Problem:
    With the call through PLT (Procedure Linkage Table), 
    (unexpected) register(s) will be clobbered.

There're two cases, one is (non-PIC) executable, and another is (PIC)
shared library.

Case 1: Executable
Suppose an executable is linked to a shared library which exports a
libgcc function.  At link time, PLT will be generated and the call to
that libgcc function will become the one through PLT.

Case 2: Shared library
Normal pc-relative call has no problem, because GCC knows the
registers clobbered.

There're cases of call of libgcc functions, using the symbol reference
through GOT (Global Offset Table) which goes through PLT.  Like this:
----------------------
    <<CALL of __udivsi3>>
	mov.l	.L1,r5
	mov.l	@(r5,r12),r6
	jsr	@r6
	 nop
	...
.L1:
	__udivsi3@GOT

GOT:
	...
__udivsi3@GOT:
	The address of PLT entry of __udivsi3

PLT:
	...
	opecode of PLT 
	...
	Offset of __udivsi3 
----------------------

Such a call doesn't expect PLT clobbers some registers.
-- 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]