Given the program
$ cat main.cpp #ifndef WITH_LOCAL_STATIC static int y = 0; #endif class X { public: void foo() { #ifdef WITH_LOCAL_STATIC static int y = 0; #endif ++y; } }; int main() { X().foo(); return 0; }
compiled in two ways:
$ g++ main.cpp -o global $ g++ main.cpp -DWITH_LOCAL_STATIC -o local
I get two different binary formats:
$ file local local: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x8d8e998601e44115b5fa6c0e71f3ed97cb13a0bd, not stripped $ file global global: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x3481ba7c6969ed9d1bd1c8ce0f052d574023d488, not stripped
Can someone explain why I get ELFOSABI_LINUX in one case, but ELFOSABI_NONE in another? Compiler - gcc 4.7.2
The background is that in my environment, the loader rejects executable files that are not ELFOSABI_NONE .
source share