-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
-r switch isn't handled properly on linux #12959
Labels
bugzilla
Issues migrated from bugzilla
Comments
*** Bug llvm/llvm-bugzilla-archive#23688 has been marked as a duplicate of this bug. *** |
mark the -r flag as linker input |
*** Bug llvm/llvm-bugzilla-archive#21357 has been marked as a duplicate of this bug. *** |
mentioned in issue llvm/llvm-bugzilla-archive#21357 |
mentioned in issue llvm/llvm-bugzilla-archive#23688 |
mentioned in issue llvm/llvm-bugzilla-archive#24345 |
This issue was closed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
The text was updated successfully, but these errors were encountered: