[all-commits] [llvm/llvm-project] 5401c6: [BOLT][instr] Avoid WX segment (#128982)

YongKang Zhu via All-commits all-commits at lists.llvm.org
Thu Feb 27 16:14:18 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5401c675ebe4114198af068b333aa541fac42491
      https://github.com/llvm/llvm-project/commit/5401c675ebe4114198af068b333aa541fac42491
  Author: YongKang Zhu <yongzhu at fb.com>
  Date:   2025-02-27 (Thu, 27 Feb 2025)

  Changed paths:
    M bolt/include/bolt/Rewrite/RewriteInstance.h
    M bolt/lib/Passes/Instrumentation.cpp
    M bolt/lib/Rewrite/RewriteInstance.cpp
    A bolt/test/avoid-wx-segment.c

  Log Message:
  -----------
  [BOLT][instr] Avoid WX segment (#128982)

BOLT instrumented binary today has a readable (R), writeable (W) and also
executable (X) segment, which Android system won't load due to its WX
attribute. Such RWX segment was produced because BOLT has a two step linking,
first for everything in the updated or rewritten input binary and next for
runtime library. Each linking will layout sections in the order of RX sections
followed by RO sections and then followed by RW sections. So we could end up
having a RW section `.bolt.instr.counters` surrounded by a number of RO and RX
sections, and a new text segment was then formed by including all RX sections
which includes the RW section in the middle, and hence the RWX segment. One
way to fix this is to separate the RW `.bolt.instr.counters` section into its
own segment by a). assigning the starting addresses for section
`.bolt.instr.counters` and its following section with regular page aligned
addresses and b). creating two extra program headers accordingly.



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