[all-commits] [llvm/llvm-project] 673114: [LLD] Implement --enable-non-contiguous-regions (#...

Daniel Thornburgh via All-commits all-commits at lists.llvm.org
Mon May 13 10:31:11 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 673114447b66335268467396a073cdaaadd0b601
      https://github.com/llvm/llvm-project/commit/673114447b66335268467396a073cdaaadd0b601
  Author: Daniel Thornburgh <dthorn at google.com>
  Date:   2024-05-13 (Mon, 13 May 2024)

  Changed paths:
    M lld/ELF/Config.h
    M lld/ELF/Driver.cpp
    M lld/ELF/InputSection.cpp
    M lld/ELF/InputSection.h
    M lld/ELF/LinkerScript.cpp
    M lld/ELF/LinkerScript.h
    M lld/ELF/Options.td
    M lld/ELF/OutputSections.cpp
    M lld/ELF/OutputSections.h
    M lld/ELF/SyntheticSections.cpp
    M lld/ELF/SyntheticSections.h
    M lld/ELF/Writer.cpp
    M lld/docs/ELF/linker_script.rst
    M lld/docs/ReleaseNotes.rst
    M lld/docs/ld.lld.1
    A lld/test/ELF/linkerscript/enable-non-contiguous-regions-arm-exidx.test
    A lld/test/ELF/linkerscript/enable-non-contiguous-regions.test

  Log Message:
  -----------
  [LLD] Implement --enable-non-contiguous-regions (#90007)

When enabled, input sections that would otherwise overflow a memory
region are instead spilled to the next matching output section.

This feature parallels the one in GNU LD, but there are some differences
from its documented behavior:

- /DISCARD/ only matches previously-unmatched sections (i.e., the flag
does not affect it).

- If a section fails to fit at any of its matches, the link fails
instead of discarding the section.

- The flag --enable-non-contiguous-regions-warnings is not implemented,
as it exists to warn about such occurrences.

The implementation places stubs at possible spill locations, and
replaces them with the original input section when effecting spills.
Spilling decisions occur after address assignment. Sections are spilled
in reverse order of assignment, with each spill naively decreasing the
size of the affected memory regions. This continues until the memory
regions are brought back under size. Spilling anything causes another
pass of address assignment, and this continues to fixed point.

Spilling after rather than during assignment allows the algorithm to
consider the size effects of unspillable input sections that appear
later in the assignment. Otherwise, such sections (e.g. thunks) may
force an overflow, even if spilling something earlier could have avoided
it.

A few notable feature interactions occur:

- Stubs affect alignment, ONLY_IF_RO, etc, broadly as if a copy of the
input section were actually placed there.

- SHF_MERGE synthetic sections use the spill list of their first
contained input section (the one that gives the section its name).

- ICF occurs oblivious to spill sections; spill lists for merged-away
sections become inert and are removed after assignment.

- SHF_LINK_ORDER and .ARM.exidx are ordered according to the final
section ordering, after all spilling has completed.

- INSERT BEFORE/AFTER and OVERWRITE_SECTIONS are explicitly disallowed.



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