I have a small library, and I build it with gcc without -fPIC option, I think this would mean that the generated object file will not be relocatable, but when I issued file command, it shows relocatable, why?
build command:
gcc -DNDEBUG -g -o module.o -c module.c
file module.o
module.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), with debug_info, not stripped
Because you are looking at the object file, before it is linked into a binary. ELF files are generally one of four types:
CORE core files
DYN Shared object file, for libraries
EXEC Executable file, for binaries
REL Relocatable file, before linked into an executable file
See this link for more info