[all-commits] [llvm/llvm-project] 6f6d91: [lld-macho] Add some relocation validation logic

Jez Ng via All-commits all-commits at lists.llvm.org
Tue Jun 2 13:20:21 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 6f6d91867da1bbdd13379a7aac8d6d2526672783
      https://github.com/llvm/llvm-project/commit/6f6d91867da1bbdd13379a7aac8d6d2526672783
  Author: Jez Ng <jezng at fb.com>
  Date:   2020-06-02 (Tue, 02 Jun 2020)

  Changed paths:
    M lld/MachO/Arch/X86_64.cpp
    M lld/MachO/InputFiles.cpp
    M lld/MachO/Target.h
    A lld/test/MachO/invalid/invalid-relocation.yaml

  Log Message:
  -----------
  [lld-macho] Add some relocation validation logic

I considered making a `Target::validate()` method, but I wasn't sure how
I felt about the overhead of doing yet another switch-dispatch on the
relocation type, so I put the validation in `relocateOne` instead...
might be a bit of a micro-optimization, but `relocateOne` does assume
certain things about the relocations it gets, and this error handling
makes that explicit, so it's not a totally unreasonable code
organization.

Reviewed By: smeenai

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


  Commit: df2a5778c32bb0757448f667d570d4e5fd18c16e
      https://github.com/llvm/llvm-project/commit/df2a5778c32bb0757448f667d570d4e5fd18c16e
  Author: Jez Ng <jezng at fb.com>
  Date:   2020-06-02 (Tue, 02 Jun 2020)

  Changed paths:
    M lld/MachO/InputSection.cpp
    M lld/MachO/Writer.cpp
    A lld/test/MachO/invalid/undefined-symbol.s

  Log Message:
  -----------
  [lld-macho] Error on encountering undefined symbols

... instead of silently emitting a reference to the zero address.

Reviewed By: smeenai

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


  Commit: a04c133564e6083f297d39136a6aa268c0ac9a06
      https://github.com/llvm/llvm-project/commit/a04c133564e6083f297d39136a6aa268c0ac9a06
  Author: Jez Ng <jezng at fb.com>
  Date:   2020-06-02 (Tue, 02 Jun 2020)

  Changed paths:
    M lld/MachO/Symbols.cpp
    M lld/MachO/Symbols.h
    M lld/MachO/SyntheticSections.h
    M lld/MachO/Target.h
    M lld/MachO/Writer.cpp
    M lld/test/MachO/entry-symbol.s
    M lld/test/MachO/segments.s
    M lld/test/MachO/x86-64-reloc-signed.s
    M lld/test/MachO/x86-64-reloc-unsigned.s

  Log Message:
  -----------
  [lld-macho] Set __PAGEZERO size to 4GB

That's what ld64 uses for 64-bit targets. I figured it's best to make
this change sooner rather than later since a bunch of our tests are
relying on hardcoded addresses that depend on this value.

Reviewed By: smeenai

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


  Commit: f04d1c3b90c19f5c01b99f8fcd5794a6b338f124
      https://github.com/llvm/llvm-project/commit/f04d1c3b90c19f5c01b99f8fcd5794a6b338f124
  Author: Jez Ng <jezng at fb.com>
  Date:   2020-06-02 (Tue, 02 Jun 2020)

  Changed paths:
    R lld/test/MachO/Inputs/no-id-dylib.yaml
    R lld/test/MachO/alignment-too-large.yaml
    R lld/test/MachO/duplicate-symbol.s
    R lld/test/MachO/invalid-executable.s
    R lld/test/MachO/invalid-fat-narch.s
    R lld/test/MachO/invalid-fat-offset.s
    A lld/test/MachO/invalid/alignment-too-large.yaml
    A lld/test/MachO/invalid/duplicate-symbol.s
    A lld/test/MachO/invalid/invalid-executable.s
    A lld/test/MachO/invalid/invalid-fat-narch.s
    A lld/test/MachO/invalid/invalid-fat-offset.s
    A lld/test/MachO/invalid/missing-dylib.s
    A lld/test/MachO/invalid/no-id-dylink.yaml
    A lld/test/MachO/invalid/no-such-file.s
    R lld/test/MachO/missing-dylib.s
    R lld/test/MachO/no-id-dylink.s
    R lld/test/MachO/no-such-file.s

  Log Message:
  -----------
  [lld-macho] Move all tests for erroneous inputs under invalid/

For consistency.

The no-id-dylib test was originally referencing the Inputs/ folder via a
relative path. Instead of updating that path, I decided to make the test
self-contained.

Reviewed By: MaskRay

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


  Commit: 1e1a3f67ee717ebb71c461e51c5c233a13f25edb
      https://github.com/llvm/llvm-project/commit/1e1a3f67ee717ebb71c461e51c5c233a13f25edb
  Author: Jez Ng <jezng at fb.com>
  Date:   2020-06-02 (Tue, 02 Jun 2020)

  Changed paths:
    M lld/MachO/InputFiles.cpp
    M lld/MachO/InputFiles.h
    A lld/MachO/MachOStructs.h
    M lld/MachO/SyntheticSections.cpp
    M lld/MachO/Writer.cpp

  Log Message:
  -----------
  [lld-macho] Ensure reads from nlist_64 structs are aligned when necessary

My test refactoring in D80217 seems to have caused yaml2obj to emit
unaligned nlist_64 structs, causing ASAN'd lld to be unhappy. I don't
think this is an issue with yaml2obj though -- llvm-mc also seems to
emit unaligned nlist_64s. This diff makes lld able to safely do aligned
reads under ASAN builds while hopefully creating no overhead for regular
builds on architectures that support unaligned reads.

Reviewed By: thakis

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


Compare: https://github.com/llvm/llvm-project/compare/086be9fb2048...1e1a3f67ee71


More information about the All-commits mailing list