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

            Bug ID: 24379
           Summary: Incorrect size of ELF symbol for a global alias
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedb...@nondot.org
          Reporter: gli...@google.com
                CC: llvm-bugs@lists.llvm.org
    Classification: Unclassified

Consider the following simplified example based on a Linux kernel module:

$ cat test.c
const int wacom_usb_ids[] = {1, 1, 2, 3, 5, 8, 13, 0};
extern const int __mod_usb_device_table __attribute__
((alias("wacom_usb_ids")));

The types of |wacom_usb_ids| and |__mod_usb_device_table| are different, which
doesn't really look good, but this pattern is extensively used in the kernel.

Both GCC 4.9 and Clang 3.7 produce ELF symbols of the same size for these
variables:

$ clang test.c -shared -o test.so && readelf -s test.so | grep usb
     8: 0000000000000620    32 OBJECT  GLOBAL DEFAULT   12
__mod_usb_device_table
     9: 0000000000000620    32 OBJECT  GLOBAL DEFAULT   12 wacom_usb_ids
    43: 0000000000000620    32 OBJECT  GLOBAL DEFAULT   12
__mod_usb_device_table
    45: 0000000000000620    32 OBJECT  GLOBAL DEFAULT   12 wacom_usb_ids

$ gcc test.c -shared -o test.so && readelf -s test.so | grep usb
     8: 0000000000000680    32 OBJECT  GLOBAL DEFAULT   13
__mod_usb_device_table
     9: 0000000000000680    32 OBJECT  GLOBAL DEFAULT   13 wacom_usb_ids
    44: 0000000000000680    32 OBJECT  GLOBAL DEFAULT   13
__mod_usb_device_table
    46: 0000000000000680    32 OBJECT  GLOBAL DEFAULT   13 wacom_usb_ids

However the ToT Clang (r244231) incorrectly generates the size of the
__mod_usb_device_table symbol (4 instead of 32)

$ $CLANG_BIN/clang test.c -shared -o test.so && readelf -s test.so | grep usb
     8: 0000000000000620     4 OBJECT  GLOBAL DEFAULT   12
__mod_usb_device_table
     9: 0000000000000620    32 OBJECT  GLOBAL DEFAULT   12 wacom_usb_ids
    43: 0000000000000620     4 OBJECT  GLOBAL DEFAULT   12
__mod_usb_device_table
    45: 0000000000000620    32 OBJECT  GLOBAL DEFAULT   12 wacom_usb_ids

Looks like a regression.

-- 
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