[PATCH] D40029: [ELF] Only add contiguous isRelro sections to PT_GNU_RELRO PHDR

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 15 02:31:39 PST 2017


peter.smith added a comment.

In https://reviews.llvm.org/D40029#925731, @ruiu wrote:

> I wonder if we can just have two or more PT_GNU_RELRO segments. Is it illegal?


In theory there is nothing in what passes for the specification of PT_GNU_RELRO that prohibits it, the most official reference I could find was the Linux Standards Base (https://refspecs.linuxfoundation.org/LSB_4.0.0/LSB-Core-generic/LSB-Core-generic.html):

> 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.

In practice relro is a collaboration/collusion between linkers and loaders and to the best of my knowledge the linux loader only records one relro segment per link_map. See struct link_map in https://code.woboq.org/userspace/glibc/include/link.h.html . The ELF processing code also seems to assume only one PT_GNU_RELRO, I think the loader would process either the first or last and ignore the others. I don't know if the BSD loader can handle more than one PT_GNU_RELRO program header.


https://reviews.llvm.org/D40029





More information about the llvm-commits mailing list