[lld] r207141 - [PECOFF] Define implicit symbols for exported ones.

Reid Kleckner rnk at google.com
Thu Apr 24 14:08:59 PDT 2014


Can I use it do this?

__declspec(dllimport) void hello(void);
extern void (*__imp__hello)(void);
void my_hello(void) { ... }
int main() {
  __imp__hello = my_hello;
}

I think the __imp_ pointers are writable.


On Thu, Apr 24, 2014 at 1:57 PM, Rui Ueyama <ruiu at google.com> wrote:

> On Thu, Apr 24, 2014 at 1:29 PM, Chandler Carruth <chandlerc at google.com>wrote:
>
>>
>> On Thu, Apr 24, 2014 at 1:12 PM, Rui Ueyama <ruiu at google.com> wrote:
>>
>>> Using __imp_ symbols locally is I think not a good coding style. One
>>> should just take an address using "&" operator rather than appending
>>> __imp_ prefix. However, there are programs in the wild that depends
>>> on this link.exe's behavior, so we need this feature.
>>>
>>
>> I wonder if we should have a warning about this?
>>
>
> Ideally, yes, but there's no good way to print a warning message when some
> symbol is actually linked. In this patch I create __imp_ symbols
> unconditionally for all dllexported symbols. Creating them is not visible
> to user -- using them should be warned.
>
> I also wonder whether the cause in the wild is source code being shared
>> between the DLL and the users of the DLL and being written "generically".
>>
>
> The program I spotted in the wild is ffmpeg. That has /include:__imp_*sym* where
> *sym* is a defined function in ffmpeg (/include is equivalent to
> --undefined). Not sure why it has such option as it is basically no-op to
> link.exe.
>
> I don't think writing code generically cannot really justify to use __imp_
> symbols, as you can just use "&", so I'm still wondering what this feature
> is really for...
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140424/1c50ec2a/attachment.html>


More information about the llvm-commits mailing list