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

            Bug ID: 34301
           Summary: lld drops the weak symbol
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: ELF
          Assignee: unassignedb...@nondot.org
          Reporter: sylves...@debian.org
                CC: dav...@freebsd.org, joker....@gmail.com,
                    llvm-bugs@lists.llvm.org, r...@google.com

Reported here: 
https://bugzilla.mozilla.org/show_bug.cgi?id=1391183#c3

------
here's what main looks like in that dummy:
00000000002010f8 <main>:
  2010f8:       31 c0                   xor    %eax,%eax
  2010fa:       e9 01 ef df ff          jmpq   0
  2010ff:       cc                      int3   

Here's what it's expected to look like:
00000000000006e0 <main>:
 6e0:   55                      push   %rbp
 6e1:   48 89 e5                mov    %rsp,%rbp
 6e4:   b8 00 00 00 00          mov    $0x0,%eax
 6e9:   e8 b2 fe ff ff          callq  5a0 <print_status@plt>
 6ee:   5d                      pop    %rbp
 6ef:   c3                      retq   

And dummy.c is:
extern __attribute__((visibility("default"), weak)) int print_status();

int main() {
    return print_status();
}

This is what objdump -dr dummy.o looks like on my machine:
0000000000000000 <main>:
   0:   55                      push   %rbp
   1:   48 89 e5                mov    %rsp,%rbp
   4:   b8 00 00 00 00          mov    $0x0,%eax
   9:   e8 00 00 00 00          callq  e <main+0xe>
                        a: R_X86_64_PLT32       print_status-0x4
   e:   5d                      pop    %rbp
   f:   c3                      retq   

And what it looks like on yours:
0000000000000000 <main>:
   0:   31 c0                   xor    %eax,%eax
   2:   e9 00 00 00 00          jmpq   7 <main+0x7>
                        3: R_X86_64_PLT32       print_status-0x4

The code is fine, but lld is completely dropping the weak symbol.
------

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

Reply via email to