[Bug c/66219] New: The gcc generated section start/stop pointers become undefined when option -flto is used

2015-05-20 Thread dscao999 at hotmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66219

Bug ID: 66219
   Summary: The gcc generated section start/stop pointers become
undefined when option -flto is used
   Product: gcc
   Version: 4.8.4
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: dscao999 at hotmail dot com
  Target Milestone: ---

Created attachment 35577
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35577&action=edit
This tar contains all the information required for a bug

#include 

__attribute__ ((__section__("MAP"))) long flags[] = {1, 2, 3, 4, 5, 6};

extern const long __start_MAP[];
extern const long __stop_MAP[];

int main(int argc, char *argv[])
{
const long *m;

m = __start_MAP;
while (m < __stop_MAP) {
printf("%d ", *m);
m++;
}
printf("\n");

return 0;
}

The magic pointers(__start_MAP, __stop_MAP) of sections will become undefined
if option -flto is used.


[Bug c/66219] The gcc generated section start/stop pointers become undefined when option -flto is used

2015-05-21 Thread dscao999 at hotmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66219

--- Comment #2 from Cao Da Shi  ---
This issue poped up when cross compiling systemd-219. It is confirmed that the
missed section has the __attribute__((used)) declared. But still the link will
only pass without "-flto", with all other options exactly the same. The files
are too large to be sent. The link command is as follows:
arm-elf-linux-gnueabi-gcc -shared -Wl,-Map=/tmp/mymap.txt -fPIC -DPIC
pam_systemd_la-pam_systemd.o -Wl,--whole-archive libsystemd-internal.a
libsystemd-shared.a -Wl,--no-whole-archive -Wl,-rpath -lrt -lcap -lm
libpam_misc.so libpam.so -ldl -flto -O2 -Wl,--as-needed -Wl,--no-undefined
-Wl,--gc-sections -Wl,-z -Wl,relro -Wl,-z -Wl,now
-Wl,--version-script=pam_systemd.sym -pthread -Wl,-soname -Wl,pam_systemd.so -o
/tmp/pam_systemd.so

$ arm-elf-linux-gnueabi-gcc -v
Using built-in specs.
COLLECT_GCC=arm-elf-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/opt/cxpkg/cxarm/libexec/gcc/arm-elf-linux-gnueabi/4.8.4/lto-wrapper
Target: arm-elf-linux-gnueabi
Configured with: /home/dscao/build/native/gcc/gcc-4.8.4/configure
--prefix=/opt/cxpkg/cxarm --target=arm-elf-linux-gnueabi
--host=x86_64-unknown-linux-gnu --build=x86_64-unknown-linux-gnu
--with-tune=cortex-a8 --with-arch=armv7-a -with-mode=arm --with-float=hard
--with-fpu=vfp3 --disable-nls --with-system-zlib
--with-sysroot=/var/opt/cxroots/armroot --enable-languages=c,c++
--enable-checking=release --enable-threads=posix --enable-shared
Thread model: posix
gcc version 4.8.4 (GCC)