[llvm-commits] patch: teach deadargelim to work on externally visible functions!

Török Edwin edwintorok at gmail.com
Mon Jan 11 10:29:06 PST 2010


On 01/11/2010 08:06 PM, Rafael Espindola wrote:
>> Right, we shouldn't change the ELF visibility, however we could avoid
>> emitting the @PLT for in-module calls (Dan says in another mail that it
>> wouldn't
>> affect function pointer compares).
>>     
>
> It is probably a good option to have, but I am not sure it fully
> captures the semantics of protected. Consider
>
> --------------------------------
> typedef void (*h)(void);
>
> void __attribute__((visibility ("protected"))) g(void);
> void f(void) {
>    h p = g;
>    p();
> }
> -----------------------------
>
> If the p=g assignment uses the PLT entry, the p() function call will
> be overwritten at runtime. Not sure how gcc avoids this.
>
>   

for -m64:
-       movq    g at GOTPCREL(%rip), %rax
+       leaq    g(%rip), %rax


for -m32
-       movl    g at GOT(%ebx), %eax
+       leal    g at GOTOFF(%ebx), %eax

Not sure how the GOTOFF table works, but the 64-bit code is clear enough
that g cannot be overridden.

BTW I also found this in gcc manpage:
"Note that due to ISO C++  specification requirements, operator new and
operator delete must
always be of default visibility."

Best regards,
--Edwin



More information about the llvm-commits mailing list