[PATCH] dinput: Mark internal symbols as hidden

Marcus Meissner meissner at suse.de
Fri Apr 29 09:18:47 CDT 2011

On Fri, Apr 29, 2011 at 07:38:30AM -0600, Vitaliy Margolen wrote:
> On 04/29/2011 01:31 AM, Marcus Meissner wrote:
> >---
> >  dlls/dinput/device_private.h |  148 +++++++++++++++++++++---------------------
> >  1 files changed, 74 insertions(+), 74 deletions(-)
> What exactly is this supposed to to? This is inside header file,
> everything declared in it is internal to dinput. Why do we need some
> extra declarations on it?

If they are not declared hidden, the -fPIC compile generates PLT relocations
for those symbols, even if they are internal to the dll (the compiler does not
know what to export during our build).

With the hidden attribute these get turned into just relative calls or
simpler relocations.

On x86 this will also save use of the %ebx register.

So e.g. this piece of code:

extern int g(void) __attribute__((__visibility__("hidden")));
int f() {
	return g();

will generate without the visibility line a PLT relocation resolving call:

0000045c <f>:
 45c:	55                   	push   %ebp
 45d:	89 e5                	mov    %esp,%ebp
 45f:	53                   	push   %ebx
 460:	83 ec 04             	sub    $0x4,%esp
 463:	e8 ef ff ff ff       	call   457 <__i686.get_pc_thunk.bx>
 468:	81 c3 8c 1b 00 00    	add    $0x1b8c,%ebx
 46e:	e8 15 ff ff ff       	call   388 <g at plt>
 473:	83 c4 04             	add    $0x4,%esp
 476:	5b                   	pop    %ebx
 477:	5d                   	pop    %ebp
 478:	c3                   	ret    

but with the visibility hidden just a relative call, no relocations:

0000042c <f>:
 42c:	55                   	push   %ebp
 42d:	89 e5                	mov    %esp,%ebp
 42f:	83 ec 08             	sub    $0x8,%esp
 432:	e8 05 00 00 00       	call   43c <g>
 437:	c9                   	leave  
 438:	c3                   	ret    

0000043c <g>:

Ciao, Marcus

More information about the wine-devel mailing list