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

            Bug ID: 45719
           Summary: clang appends ".1"/... to asm()-specified symbol names
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C
          Assignee: unassignedclangb...@nondot.org
          Reporter: equinox-l...@diac24.net
                CC: blitzrak...@gmail.com, dgre...@apple.com,
                    erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@metafoo.co.uk

int testfn(void)
{
        do {
                extern int name_c1 asm("name_asm_a");
                static __attribute__((used)) int *ptr = &name_c1;
                static __attribute__((used)) int def_c asm("name_asm_a") =
0x1234;
        } while (0);

        do {
                extern int name_c2 asm("name_asm_b");
                static __attribute__((used)) int *ptr = &name_c2;
                static __attribute__((used)) int def_c asm("name_asm_b") =
0x2345;
        } while (0);

        return 0;
}


compiles to (shortened):

testfn.ptr:
  .quad name_asm_a
name_asm_a.1:
  .long 4660 # 0x1234
testfn.ptr.2:
  .quad name_asm_b
name_asm_b.3:
  .long 9029 # 0x2345


- the "def_c" statements use assembler labels "name_asm_a.1" and "name_asm_b.3"
instead of expected "name_asm_a" and "name_asm_b".
- the initializer for "ptr" uses the asm name without the ".1" or ".3" suffix

This ultimately leads to the linker erroring out due to the symbols not
resolving correctly.

(The example above is extracted from a macro that is trying to create static
variables with cyclical pointers between two of them, hence the odd "extern"
declaration.)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to