When a common symbol is merged with a shared symbol, increase st_size if the shared symbol has a larger st_size. At runtime, the executable's symbol overrides the shared symbol. The shared symbol may be created from common symbols in a previous link. This rule makes sure we pick the largest size among all common symbols. This behavior matches GNU ld. See https://sourceware.org/bugzilla/show_bug.cgi?id=25236 for discussions. A shared symbol does not hold alignment constraints. Ignore the alignment update. Reviewed By: peter.smith Differential Revision: https://reviews.llvm.org/D71161
17 lines
493 B
ArmAsm
17 lines
493 B
ArmAsm
# REQUIRES: x86
|
|
## When a common symbol is merged with a shared symbol, pick the larger st_size.
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
|
|
# RUN: echo '.globl com; .comm com, 16' | llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o
|
|
# RUN: ld.lld -shared %t1.o -o %t1.so
|
|
|
|
# RUN: ld.lld %t.o %t1.so -o %t
|
|
# RUN: llvm-readelf -s %t | FileCheck %s
|
|
# RUN: ld.lld %t1.so %t.o -o %t
|
|
# RUN: llvm-readelf -s %t | FileCheck %s
|
|
|
|
# CHECK: 16 OBJECT GLOBAL DEFAULT 7 com
|
|
|
|
.globl com
|
|
.comm com,1
|