[llvm-bugs] [Bug 43187] New: Crash given weak symbol in C, normal symbol in inline assembly

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Aug 31 18:08:10 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=43187

            Bug ID: 43187
           Summary: Crash given weak symbol in C, normal symbol in inline
                    assembly
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: jonathanchesterfield at gmail.com
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, spatel+llvm at rotateright.com

For example,

__attribute__((weak)) int x = 4;
__asm__(".type x, at object\n"
        ".data\n"
        ".p2align 2\n"
        "x:\n"
        ".long 42\n");
=> fatal error: error in backend: symbol 'x' is already defined

or, equivalently:

module asm ".type x, at object"
module asm ".data"
module asm ".p2align 2"
module asm "x:"
module asm ".long 42"
@x = weak dso_local global i32 4, align 4
=> same error

Expected behaviour is for x to have the initial value 42, replacing the weak
symbol. Observed behaviour is the fatal error.

Using non-inline assembly works as expected. Symbol overridden, no error.

Weak on either (or both) symbol(s) shows the same behaviour.

Non-reduced case has inline assembly in one translation unit and the weak
symbol in another. Compiling each separately to an elf and linking works fine,
llvm-link then llc fails as above.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190901/b9bdb855/attachment.html>


More information about the llvm-bugs mailing list