[LLVMbugs] [Bug 12587] New: -r switch isn't handled properly on linux

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Apr 18 07:30:58 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=12587

             Bug #: 12587
           Summary: -r switch isn't handled properly on linux
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: sbn at tbricks.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Created attachment 8407
  --> http://llvm.org/bugs/attachment.cgi?id=8407
Proposed patch attached

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

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list