[LLVMdev] Request for help: why does the program link correctly? (original) (raw)

Soumitra Chatterjee soumitra at hp.com
Wed Jul 1 22:09:35 PDT 2015


Hi, I am a bit stumped on the following case, and hopefully missing something very basic. Can someone please help me understand why the following is allowed to link correctly?

$ cat -n main.c 1 extern void foo(); 2 3 int main() { foo(); }

$ cat -n def.c 1 int foo = 99;

$ clang main.c def.c ; echo $? 0

I guess the answer depends on why is 'main.c::foo' not marked as func?

$ clang -c main.c def.c $ readelf -s main.o def.o | grep foo 9: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND foo 7: 0000000000000000 4 OBJECT GLOBAL DEFAULT 2 foo

Thanks, Soumitra



More information about the llvm-dev mailing list