[all-commits] [llvm/llvm-project] 16d784: [lld-macho] Don't fold subsections with symbols at...

Jez Ng via All-commits all-commits at lists.llvm.org
Tue Oct 18 14:22:32 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 16d784159f6873ff5ca860c0e490103127aa2e4e
      https://github.com/llvm/llvm-project/commit/16d784159f6873ff5ca860c0e490103127aa2e4e
  Author: Jez Ng <jezng at fb.com>
  Date:   2022-10-18 (Tue, 18 Oct 2022)

  Changed paths:
    M lld/MachO/ICF.cpp
    M lld/MachO/InputFiles.cpp
    M lld/MachO/InputSection.cpp
    M lld/MachO/InputSection.h
    M lld/test/MachO/icf.s

  Log Message:
  -----------
  [lld-macho] Don't fold subsections with symbols at nonzero offsets

Symbols occur at non-zero offsets in a subsection if they are
`.alt_entry` symbols, or if `.subsections_via_symbols` is omitted.

It doesn't seem like ld64 supports folding those subsections either.
Moreover, supporting this it makes `foldIdentical` a lot more
complicated to implement. The existing implementation has some
questionable behavior around STABS omission -- if a section with an
non-zero offset symbol was folded into one without, we would omit the
STABS entry for the non-zero offset symbol.

I will be following up with a diff that makes `foldIdentical` zero out
the symbol sizes for folded symbols. Again, this is much easier to
implement if we don't have to worry about non-zero offsets.

Reviewed By: #lld-macho, oontvoo

Differential Revision: https://reviews.llvm.org/D136000


  Commit: 316d4f96f22afa6630ee1069e48f970362f50f0a
      https://github.com/llvm/llvm-project/commit/316d4f96f22afa6630ee1069e48f970362f50f0a
  Author: Jez Ng <jezng at fb.com>
  Date:   2022-10-18 (Tue, 18 Oct 2022)

  Changed paths:
    M lld/MachO/InputSection.cpp
    M lld/test/MachO/map-file.s
    M lld/test/MachO/stabs-icf.s

  Log Message:
  -----------
  [lld-macho] Folded symbols should have size zero in linker map

This matches ld64's behavior.

I also extended the icf-stabs.s test to demonstrate that even though
folded symbols have size zero, we cannot use the size-zero property in
lieu of `wasIdenticalCodeFolded`, because size zero symbols should still
get STABS entries.

Reviewed By: #lld-macho, thakis

Differential Revision: https://reviews.llvm.org/D136001


Compare: https://github.com/llvm/llvm-project/compare/181b04d276a8...316d4f96f22a


More information about the All-commits mailing list