https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67469
Bug ID: 67469 Summary: "-pie -fpie" result in BSS instead of undefined symbols Product: gcc Version: 5.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: nyh at math dot technion.ac.il Target Milestone: --- I've noticed a really strange phenomenon in Gcc 5.1.1 compared to Gcc 4.9.2. I don't know if it's a bug or a feature. Consider the following simple C program: #include <stdio.h> int main(){ printf("%p\n", stdout); } I would expect, the compiled dynamic executable should have the symbol "stdout" as an undefined ("U" in nm) symbol, because it is an external symbol which must be defined by the shared library. But, if I compile it on gcc 5.1.1 with the command: cc -pie -fpie file.c and do "nm -D a.out", I see that stdout is in the BSS ("B") instead of being undefined ("U")! Strangely, if I use -fpic instead of -fpie, i.e. "cc -pie -fpic" - this issue does not appear and I get "U" as I expected. I also get "U" when compiling with "-shared -fpic". In gcc 4.9.2 I got "U" in all these cases. However, one reason I'm not sure this is actually a bug is that when I compile without any pic/pie parameters (i.e., a normal non-relocatable executable), I get the "B" symbol as well - and this also used to be the case in 4.9.2. So maybe this was always the intended behavior, but I just don't understand why?