This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PowerPC 32 : GOT access not optimized for DSO-scope static variable ?
- From: "yon ar c'hall" <yon dot ar dot chall at gmail dot com>
- To: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Fri, 14 Jun 2013 16:37:27 +0200
- Subject: PowerPC 32 : GOT access not optimized for DSO-scope static variable ?
Hi,
In the paper "How to write shared libraries" of U.Drepper, it is
explained that declaring a global variable as static (scope supposed
to be limited to the DSO) is better for run-time performance : one
assembly instruction less is used for accessing the variable. However,
it's worth noting this is for x86, as shown below :
global variable :
movl globalvar@GOT(%ebx), %edx
movl (%edx), %eax
static DSO scope variable :
movl staticvar@GOTOFF(%ebx), %eax
When compiling for PowerPC e500mc/e500v2 with gcc 4.6 (options -fPIC,
no optimization specified) and binutils 2.2, the assembly code is the
same whether the variable is static or not :
lwz 0,.LC0-.LCTOC1(30)
mr 9,0
lwz 0,0(9)
with LCTOC1, LC0 and GOT stuff like this :
.section ".got2","aw"
.LCTOC1 = .+32768
.section ".text"
.comm staticvar,4,4
.section ".got2","aw"
.LC0:
.long staticvar
So is there any possible optimization regarding static DSO scope
variables access (and variables with visibility=hidden as well) for
PowerPC ?
Thanks,
- Yon