Skip to content
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

Closed
llvmbot opened this issue Apr 18, 2012 · 6 comments
Closed

-r switch isn't handled properly on linux #12959

llvmbot opened this issue Apr 18, 2012 · 6 comments
Labels
bugzilla Issues migrated from bugzilla

Comments

@llvmbot
Copy link
Member

llvmbot commented Apr 18, 2012

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

@rnk
Copy link
Collaborator

rnk commented Jul 14, 2015

*** Bug llvm/llvm-bugzilla-archive#23688 has been marked as a duplicate of this bug. ***

@llvmbot
Copy link
Member Author

llvmbot commented Aug 6, 2015

mark the -r flag as linker input
mark the -r flag as linker input

@MaskRay
Copy link
Member

MaskRay commented Jul 7, 2019

*** Bug llvm/llvm-bugzilla-archive#21357 has been marked as a duplicate of this bug. ***

@MaskRay
Copy link
Member

MaskRay commented Nov 26, 2021

mentioned in issue llvm/llvm-bugzilla-archive#21357

@rnk
Copy link
Collaborator

rnk commented Nov 26, 2021

mentioned in issue llvm/llvm-bugzilla-archive#23688

@llvmbot
Copy link
Member Author

llvmbot commented Nov 26, 2021

mentioned in issue llvm/llvm-bugzilla-archive#24345

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

3 participants