[all-commits] [llvm/llvm-project] 001ba6: [lld-macho] De-templatize mach_header operations

Jez Ng via All-commits all-commits at lists.llvm.org
Mon May 3 15:31:47 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 001ba65375f79a76491677cc2de05637f15a7a57
      https://github.com/llvm/llvm-project/commit/001ba65375f79a76491677cc2de05637f15a7a57
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-05-03 (Mon, 03 May 2021)

  Changed paths:
    M lld/MachO/Driver.cpp
    M lld/MachO/InputFiles.cpp
    M lld/MachO/InputFiles.h
    M lld/MachO/ObjC.cpp
    M lld/MachO/SyntheticSections.cpp
    M lld/MachO/SyntheticSections.h
    M lld/MachO/Target.h
    M lld/MachO/Writer.cpp
    M lld/MachO/Writer.h
    M lld/test/MachO/objc.s

  Log Message:
  -----------
  [lld-macho] De-templatize mach_header operations

@thakis pointed out that `mach_header` and `mach_header_64`
actually have the same set of (used) fields, with the 64-bit version
having extra padding. So we can access the fields we need using the
single `mach_header` type instead of using templates to switch between
the two.

I also spotted a potential issue where hasObjCSection tries to parse a
file w/o checking if it does indeed match the target arch... As such,
I've added a quick magic number check to ensure we don't access invalid
memory during `findCommand()`.

Addresses PR50180.

Reviewed By: #lld-macho, thakis

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




More information about the All-commits mailing list