[all-commits] [llvm/llvm-project] 9c970d: [LLD] [COFF] Don't add pseudo relocs for dangling ...

Martin Storsjö via All-commits all-commits at lists.llvm.org
Mon Apr 15 10:14:28 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9c970d5ecd6a85188cd2b0a941fcd4d60063ef81
      https://github.com/llvm/llvm-project/commit/9c970d5ecd6a85188cd2b0a941fcd4d60063ef81
  Author: Martin Storsjö <martin at martin.st>
  Date:   2024-04-15 (Mon, 15 Apr 2024)

  Changed paths:
    M lld/COFF/Chunks.cpp
    A lld/test/COFF/autoimport-gc.s

  Log Message:
  -----------
  [LLD] [COFF] Don't add pseudo relocs for dangling references (#88487)

When doing GC, we normally won't have dangling references, because such
a reference would keep the other section alive, keeping it from being
eliminated.

However, references within DWARF sections are ignored for the purposes
of GC (because otherwise, they would essentially keep everything alive,
defeating the point of the GC), see
c579a5b1d92a9bc2046d00ee2d427832e0f5ddec for more context.

Therefore, dangling relocations against discarded symbols are ignored
within DWARF sections (see maybeReportRelocationToDiscarded in
Chunks.cpp). Consequently, we also shouldn't create any pseudo
relocations for these cases, as we run into a null pointer dereference
when trying to generate the pseudo relocation info for it.

This fixes the downstream bug
https://github.com/mstorsjo/llvm-mingw/issues/418, fixing crashes on
combinations with -ffunction-sections, -fdata-sections,
-Wl,--gc-sections and debug info.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list