[all-commits] [llvm/llvm-project] ce45c9: [ELF] Remove obscure -dp and GNU ld incompatible -...

Fangrui Song via All-commits all-commits at lists.llvm.org
Wed Feb 9 10:36:14 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ce45c956942e4fe301102ed807efc726399623f9
      https://github.com/llvm/llvm-project/commit/ce45c956942e4fe301102ed807efc726399623f9
  Author: Fangrui Song <i at maskray.me>
  Date:   2022-02-09 (Wed, 09 Feb 2022)

  Changed paths:
    M lld/ELF/Config.h
    M lld/ELF/Driver.cpp
    M lld/ELF/Options.td
    M lld/ELF/SyntheticSections.cpp
    M lld/docs/ReleaseNotes.rst
    M lld/docs/ld.lld.1
    M lld/test/ELF/relocatable-common.s
    M lld/test/ELF/silent-ignore.test

  Log Message:
  -----------
  [ELF] Remove obscure -dp and GNU ld incompatible --[no-]define-common, ignore -d/-dc

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




More information about the All-commits mailing list