[LLVMbugs] [Bug 7635] New: Inline assembly in C++ source fails to link

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jul 13 04:48:18 PDT 2010


           Summary: Inline assembly in C++ source fails to link
           Product: clang
           Version: trunk
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: bjorn at topel.se
                CC: llvmbugs at cs.uiuc.edu

The following snippet generates the following linker (ld) error:

ld: in /var/folders/Eb/Ebu2gEwcHfeuStO9hJ4SQk+++TI/-Tmp-/cc-u4eXeR.o, in
section __TEXT,__text reloc 0: unsupported r_length=0 for scattered vanilla
clang: error: linker command failed with exit code 1 (use -v to see invocation)

which works for g++.

-arch i386

typedef void (*FuncPtr)(void);

extern "C" {

void j(void)

} // extern "C"

int main()
    unsigned int tmp = 655341895;

    asm("neg %0\n\t"
        "addl $(_j + 655341895),%0\n"
        : "+r" (tmp));


    return 0;

Note that the generated .s file generated by clang links using g++, i.e.
$ clang++ -arch i386 -S -o t.s in.cc
$ g++ -arch i386 t.s # OK
$ clang++ -arch i386 t.s # NOK

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