[PATCH] D130877: [MCObjectFileInfo] Add getPCSection() helper

Marco Elver via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 2 07:28:55 PDT 2022


melver added a subscriber: MaskRay.
melver added inline comments.


================
Comment at: llvm/lib/MC/MCObjectFileInfo.cpp:1189
+  // SHF_WRITE for relocations, and let user post-process data in-place.
+  unsigned Flags = ELF::SHF_WRITE | ELF::SHF_ALLOC | ELF::SHF_LINK_ORDER;
+
----------------
dvyukov wrote:
> Do we actually plan to write to these sections? Does setting SHF_WRITE prevent sharing of pages across multiple processes? Of SHF_WRITE pages still mapped as shared/write-protected first and then subject to copy-on-write?
This was needed for relocations (because linker needs section writable if it contains relocations).
glibc seems to map sections as MAP_COPY (AFAIK), which is MAP_PRIVATE on Linux, so it'll COW.

Now that we have relative relocations, maybe we don't need it anymore, but I'd like to reserve the option to modify the data in-place (whether we do it, or someone else finds a use for it).
Changing it again in future is too painful, and we're likely stuck with whatever we decide now. I don't see a huge downside to it being writable (there's no security concern here).

Cc @MaskRay 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130877/new/

https://reviews.llvm.org/D130877



More information about the llvm-commits mailing list