https://maskray.me/blog/2022-02-06-all-about-common-symbols#no-define-common
In GNU ld, -dc only affects -r links and causes COMMON symbols to be allocated.
--no-define-common is defined to make COMMON symbols undefined for -shared.
AIUI --no-define-common is a workaround around glibc 2.1 time and not really useful.
gold confuses --define-common with -d/FORCE_COMMON_ALLOCATION and implements
--define-common with -d semantics. Its --no-define-common is incompatible with
GNU ld.
In ld.lld, b2a23cf3c0 fixed the default -r
behavior for COMMON symbols but ported the incompatible gold
--[no-]define-common. To the best of my knowledge, no project uses -dp
--[no-]define-common. So just remove these options.
-d/-dc are used by the following projects:
* grub grub-core/genmod.sh.in uses -Wl,-r,-d (https://lists.gnu.org/archive/html/grub-devel/2022-02/msg00088.html)
* FreeBSD crunchgen uses -Wl,-dc (https://reviews.freebsd.org/D34215)
A no-op implementation works for them. Only when a program inspects relocatable
output by itself and does not recognize COMMON symbols, there may be a problem.
This is an extremely unlikely case.
Reviewed By: peter.smith
Differential Revision: https://reviews.llvm.org/D119108
17 lines
449 B
ArmAsm
17 lines
449 B
ArmAsm
# REQUIRES: x86
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
|
|
# RUN: ld.lld -r %t1.o -o %t
|
|
# RUN: llvm-readobj --symbols -r %t | FileCheck %s
|
|
|
|
# CHECK: Symbol {
|
|
# CHECK: Name: common
|
|
# CHECK-NEXT: Value: 0x4
|
|
# CHECK-NEXT: Size: 4
|
|
# CHECK-NEXT: Binding: Global
|
|
# CHECK-NEXT: Type: Object
|
|
# CHECK-NEXT: Other: 0
|
|
# CHECK-NEXT: Section: Common (0xFFF2)
|
|
# CHECK-NEXT: }
|
|
|
|
.comm common,4,4
|