-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Description
Bugzilla Link | 12587 |
Resolution | FIXED |
Resolved on | Jul 07, 2019 01:30 |
Version | unspecified |
OS | Linux |
Blocks | llvm/llvm-bugzilla-archive#24345 |
Attachments | Proposed patch attached |
Reporter | LLVM Bugzilla Contributor |
CC | @frobtech |
Extended Description
Looks like '-r' option isn't handled on Linux:
$ cat a.c
int bar();
int foo()
{
return bar();
}
$ cat b.c
int bar()
{
return 7;
}
$ clang -v
clang version 3.1 (trunk 155001)
Target: x86_64-unknown-linux-gnu
Thread model: posix
$ clang -c a.c
$ clang -c b.c
$ clang -nostdlib -r -o all.o a.o b.o
clang: warning: argument unused during compilation: '-r'
/usr/bin/ld: warning: cannot find entry symbol _start; defaulting to 00000000004000b0
$ clang -v -nostdlib -r -o all.o a.o b.o
clang version 3.1 (trunk 155001)
Target: x86_64-unknown-linux-gnu
Thread model: posix
clang: warning: argument unused during compilation: '-r'
"/usr/bin/ld" --hash-style=gnu --no-add-needed --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o all.o -L/usr/lib/gcc/x86_64-redhat-linux6E/4.4.4 -L/usr/lib/gcc/x86_64-redhat-linux6E/4.4.4/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux6E/4.4.4/../../.. -L/lib -L/usr/lib a.o b.o
/usr/bin/ld: warning: cannot find entry symbol _start; defaulting to 00000000004000b0
$ file all.o
all.o: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), statically linked, not stripped
So instead of creating relocatable object it creates (broken) static executable.
GCC does the right thing:
$ gcc -nostdlib -r -o all.o a.o b.o
$ file all.o
all.o: ELF 64-bit LSB relocatable, AMD x86-64, version 1 (SYSV), not stripped