Bug #2559
closedgcc -pie and __builtin_popcount causes
0%
Description
I found that __builtin_popcount is not usable with -pie option for gcc.
$ uname -a
DragonFly dragonfly34 3.4-RELEASE DragonFly v3.4.1-RELEASE #7: Wed Apr 24 20:01:27 PDT 2013 root@pkgbox64.dragonflybsd.org:/usr/obj/build/home/justin/src/sys/X86_64_GENERIC x86_64
$ cat tst.c
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("%d\n", __builtin_popcount(argc));
return 0;
}
$ gcc -pie tst.c
/usr/libexec/binutils222/elf/ld.bfd: /tmp//cc2Tj2Mb.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/tmp//cc2Tj2Mb.o: could not read symbols: Bad value
Updated by marino over 11 years ago
- system gcc 4.4
- dports gcc-aux version 4.7
The latter is particularly telling because it's built with vendor makefiles.
Which means it's not a compiler problem but more likely a crt* stuff problem.
Updated by alexh over 11 years ago
This is not a bug. The compiler is telling you what do to: use -fPIC.
Updated by akr over 11 years ago
- Status changed from New to Closed
Oops. You are right.
-fPIC solves the problem.
Thank you.
Updated by marino over 11 years ago
Heh, I was working under the assumption that this test worked elsewhere and I was going to test it on the latest FreeBSD.
I also assumed that -fpic wasn't wanted because the error message was so obvious about the problem.
Closing.
Updated by exercitation about 6 years ago
- Description updated (diff)
Bug report was represent on this platform that was amazing to have all these on the formation of this programme. I need to get report on this that I got from https://www.essayontime.co.uk/ this was good to have all the verification to remove the bug report on it.