[all-commits] [llvm/llvm-project] 2539b4: [LLD][ELF] Allow empty (.init|.preinit|.fini)_arra...

Peter Smith via All-commits all-commits at lists.llvm.org
Tue Mar 31 04:55:25 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 2539b4ae4765b14cd7774e801ba12f0a200ef734
      https://github.com/llvm/llvm-project/commit/2539b4ae4765b14cd7774e801ba12f0a200ef734
  Author: Peter Smith <peter.smith at arm.com>
  Date:   2020-03-31 (Tue, 31 Mar 2020)

  Changed paths:
    M lld/ELF/Writer.cpp
    A lld/test/ELF/relro-init-fini-script.s

  Log Message:
  -----------
  [LLD][ELF] Allow empty (.init|.preinit|.fini)_array to be RELRO

The default GNU linker script uses the following idiom for the array
sections. I'll use .init_array here, but this also applies to
.preinit_array and .fini_array sections.

  .init_array    :
  {
    PROVIDE_HIDDEN (__init_array_start = .);
    KEEP (*(.init_array))
    PROVIDE_HIDDEN (__init_array_end = .);
  }

The C-library will take references to the _start and _end symbols to
process the array. This will make LLD keep the OutputSection even if there
are no .init_array sections. As the current check for RELRO uses the
section type for .init_array the above example with no .init_array
InputSections fails the checks as there are no .init_array sections to give
the OutputSection a type of SHT_INIT_ARRAY. This often leads to a
non-contiguous RELRO error message.

The simple fix is to a textual section match as well as a section type
match.

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




More information about the All-commits mailing list