[all-commits] [llvm/llvm-project] 4d3a0c: [BOLT] Section-handling refactoring/overhaul

maksfb via All-commits all-commits at lists.llvm.org
Thu Oct 13 23:11:00 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4d3a0cade2ed0bdc87256c197215691c2e279ed0
      https://github.com/llvm/llvm-project/commit/4d3a0cade2ed0bdc87256c197215691c2e279ed0
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2022-10-13 (Thu, 13 Oct 2022)

  Changed paths:
    M bolt/include/bolt/Core/BinaryContext.h
    M bolt/include/bolt/Core/BinarySection.h
    M bolt/include/bolt/Rewrite/ExecutableFileMemoryManager.h
    M bolt/include/bolt/Rewrite/MachORewriteInstance.h
    M bolt/include/bolt/Rewrite/RewriteInstance.h
    M bolt/lib/Core/BinaryContext.cpp
    M bolt/lib/Core/BinaryEmitter.cpp
    M bolt/lib/Core/BinarySection.cpp
    M bolt/lib/Passes/ReorderData.cpp
    M bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp
    M bolt/lib/Rewrite/MachORewriteInstance.cpp
    M bolt/lib/Rewrite/RewriteInstance.cpp
    M bolt/test/X86/dynrelocs.s

  Log Message:
  -----------
  [BOLT] Section-handling refactoring/overhaul

Simplify the logic of handling sections in BOLT. This change brings more
direct and predictable mapping of BinarySection instances to sections in
the input and output files.

* Only sections from the input binary will have a non-null SectionRef.
  When a new section is created as a copy of the input section,
  its SectionRef is reset to null.

* RewriteInstance::getOutputSectionName() is removed as the section name
  in the output file is now defined by BinarySection::getOutputName().

* Querying BinaryContext for sections by name uses their original name.
  E.g., getUniqueSectionByName(".rodata") will return the original
  section even if the new .rodata section was created.

* Input file sections (with relocations applied) are emitted via MC with
  ".bolt.org" prefix. However, their name in the output binary is
  unchanged unless a new section with the same name is created.

* New sections are emitted internally with ".bolt.new" prefix if there's
  a name conflict with an input file section. Their original name is
  preserved in the output file.

* Section header string table is properly populated with section names
  that are actually used. Previously we used to include discarded
  section names as well.

* Fix the problem when dynamic relocations were propagated to a new
  section with a name that matched a section in the input binary.
  E.g., the new .rodata with jump tables had dynamic relocations from
  the original .rodata.

Reviewed By: rafauler

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




More information about the All-commits mailing list