[BOLT] Set IsRelro section attribute based on PT_GNU_RELRO segment
authorAmir Ayupov <aaupov@fb.com>
Wed, 21 Jun 2023 03:43:53 +0000 (20:43 -0700)
committerAmir Ayupov <aaupov@fb.com>
Wed, 21 Jun 2023 03:44:18 +0000 (20:44 -0700)
commit82ef86c194cadd018349df68b4da6db110fdecb4
treef2ab7078acd813922c98212e5d552e6cf7ede6fd
parente1051414a16e970c2e36c2ab7dfe2b17353c4751
[BOLT] Set IsRelro section attribute based on PT_GNU_RELRO segment

Handle PT_GNU_RELRO segment in accordance with Linux Standard Base spec
chapter 12:

> PT_GNU_RELRO
> The array element specifies the location and size of a segment which may
> be made *read-only* after relocations have been processed.

Perform a readelf-style mapping check between this segment and sections,
set `IsRelro` section attribute.

Reviewed By: #bolt, maksfb

Differential Revision: https://reviews.llvm.org/D152944
bolt/include/bolt/Core/BinarySection.h
bolt/include/bolt/Rewrite/RewriteInstance.h
bolt/lib/Rewrite/RewriteInstance.cpp
bolt/test/X86/pt_gnu_relro.s [new file with mode: 0644]