From: NIIBE Y. <gn...@m1...> - 2001-09-25 04:24:48
|
More explanation of .hidden. 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. To prevent this, a solution would be using .hidden for libgcc functions. Case 2: Shared library Normal pc-relative call has no problem. 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,r0 mov.l @(r0,r12),r1 jsr @r1 nop ... .L1: __udivsi3@GOT GOT: ... __udivsi3@GOT: The address of PLT entry of __udivsi3 PLT: ... opecode of PLT ... Offset of __udivsi3 ---------------------- When we use .hidden attribute for the libgcc function (in this case, __udivsi3), PLT will not be generated and it will become like that (at link time): ---------------------- <<CALL of __udivsi3>> mov.l .L1,r0 mov.l @(r0,r12),r1 jsr @r1 nop ... .L1: __udivsi3@GOTOFF ---------------------- -- |