Hello,
I have an issue using LTO with the cmdline options -flto
-fuse-linker-plugin. What happens is that section attributes for data get
discarded. I havent had time to narrow down the code, but this is just
about how I use it:
CODE ------------------------------------------------
class XY {
static __attribute__ ((section ("mynocachesection"))) sometype somename;
};
...
accessing the static member somewhere
------------------------------------------------
of course, in the linker description file I have correctly included the
section, together with some linker variables to find the region I have to
map as uncached.
What happens is that everything works fine, untill I compile with LTO
enabled, then the mynocachesection is existing but empty and the static
instances exist (arent garbage collected) but are somewhere within the
regular data section (Really fun time debugging till I found out). This
doesnt seem right to me.
I know LTO basically tries to make all global variables and funtions
"local", but it shouldnt drop the section attribute.
funnily I used another attribute to make it work again, one which isnt
even listed under variable attributes. This fixes it:
CODE ------------------------------------------------
class XY {
static __attribute__ ((externally_visible, section ("mynocachesection")))
sometype somename;
};
------------------------------------------------
Im glad it works, but it just seems even stranger to me now. Is the
original issue how its supposed to be, or a bug? Is the fix even supposed
to be working?
Best Regards, Norbert
Here are the gcc specs:
Using built-in specs.
COLLECT_GCC=arm-none-eabi-g++
COLLECT_LTO_WRAPPER=/opt/hipase-imx28-v0/libexec/gcc/arm-none-eabi/4.7.2/lto-wrapper
Target: arm-none-eabi
Configured with: /opt/hipase-imx28-v0/src/gcc-4.7.2/configure
--prefix=/opt/hipase-imx28-v0 --target=arm-none-eabi
--enable-languages=c,c++ --disable-libstdcxx-verbose --disable-libmudflap
--disable-libssp --disable-libstdcxx-pch --enable-multilib
--disable-shared --disable-nls --with-system-zlib --enable-tls
--enable-gold --with-gnu-as --with-gnu-ld --enable-lto --with-newlib
--with-gmp=/home/tcbuild/gccmake/build/ggcnativebuild/gmp-5.0.5
--with-mpfr=/home/tcbuild/gccmake/build/ggcnativebuild/mpfr-3.1.1
--with-mpc=/home/tcbuild/gccmake/build/ggcnativebuild/mpc-1.0.1
--with-cloog=/home/tcbuild/gccmake/build/ggcnativebuild/cloog-ppl-0.15.11
--with-ppl=/home/tcbuild/gccmake/build/ggcnativebuild/ppl-0.11
--with-host-libstdcxx='-Wl,-Bstatic,/usr/lib/gcc/i486-linux-gnu/4.4.5/libstdc++.a,/usr/lib/gcc/i486-linux-gnu/4.4.5/libsupc++.a,-Bdynamic
-lm'
Thread model: single
gcc version 4.7.2 (GCC)