[all-commits] [llvm/llvm-project] f1969b: [lld/mac] Fix nondeterminism in output section ord...

Nico Weber via All-commits all-commits at lists.llvm.org
Mon Jun 28 15:41:49 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f1969b74a7e70623129872d69caba4759df47fb0
      https://github.com/llvm/llvm-project/commit/f1969b74a7e70623129872d69caba4759df47fb0
  Author: Nico Weber <thakis at chromium.org>
  Date:   2021-06-28 (Mon, 28 Jun 2021)

  Changed paths:
    M lld/MachO/OutputSegment.cpp
    M lld/MachO/Writer.cpp
    M lld/test/MachO/tlv-dylib.s

  Log Message:
  -----------
  [lld/mac] Fix nondeterminism in output section ordering

The two different thread_local_regular sections (__thread_data and
more_thread_data) had nondeterminstic ordering for two reasons:

1. https://reviews.llvm.org/D102972 changed concatOutputSections
   from MapVector to DenseMap, so when we iterate it to make
   output segments, we would add the two sections to the __DATA
   output segment in nondeterministic order.

2. The same change also moved the two stable_sort()s for segments
   and sections to sort(). Since sections with assigned priority
   (such as TLV data) have the same priority for all sections,
   this is incorrect -- we must use stable_sort() so that the
   initial (input-order-based) order remains.

As a side effect, we now (deterministically) put the __common
section in front of __bss (while previously we happened to
put it after it). (__common and __bss are both zerofill so
both have order INT_MAX, but common symbols are added to
inputSections before normal sections are collected.)

Makes lld/test/MachO/tlv.s and lld/test/MachO/tlv-dylib.s pass with
LLVM_ENABLE_EXPENSIVE_CHECKS=ON.

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




More information about the All-commits mailing list