[PATCH] D152944: [BOLT] Set IsRelro section attribute based on PT_GNU_RELRO segment
Maksim Panchenko via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 20 11:57:26 PDT 2023
maksfb added inline comments.
================
Comment at: bolt/lib/Rewrite/RewriteInstance.cpp:446
+
+Error RewriteInstance::markGnuRelroSections() {
+ using ELFT = ELF64LE;
----------------
The function currently always returns `Error::success()`. Thinking about it, it will be an error condition when only part of the section is in RELRO segment. Let's add such check.
================
Comment at: bolt/lib/Rewrite/RewriteInstance.cpp:457-458
+ const ELFShdrTy *Sec = cantFail(Obj.getSection(SecRef.getIndex()));
+ bool IsTbss =
+ (Sec->sh_type == ELF::SHT_NOBITS) && (Sec->sh_flags & ELF::SHF_TLS);
+ if (IsTbss || !checkOffsets<ELFT>(Phdr, *Sec) ||
----------------
Use `BinarySection(*BC, SecRef).isTBSS()`. Or better yet move the search for the matching `BinarySection` here and call `isTBSS()`.
================
Comment at: bolt/test/X86/pt_gnu_relro.s:4
+# Check that BOLT recognizes PT_GNU_RELRO segment and marks respective sections
+# read-only.
+
----------------
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D152944/new/
https://reviews.llvm.org/D152944
More information about the llvm-commits
mailing list