[PATCH] D14218: [ELF2] Implements -z relro: create an ELF "PT_GNU_RELRO" segment header in the object.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 9 05:46:10 PST 2015


grimar added inline comments.

================
Comment at: ELF/Writer.cpp:317
@@ +316,3 @@
+// be included into GNU_RELRO but .got.plt will still be writable.
+static int8_t getRelroSectionRank(StringRef SectionName) {
+  return StringSwitch<int8_t>(SectionName)
----------------
rafael wrote:
> Please don't do this.
> 
> The constraint that we have is that now the RW  PT_LOAD is split in two parts. The bits that become ro after relacations are applied and the ones that don't.
> 
> You can implement that directly in the comparison function.
> 
> Also, I think we may as well always sort like that.
> 
> 
Problem is I cant recognize where is "got", "got.plt" and "data" using only section attributes bits.
They all are SHT_PROGBITS and "aw". And the only way to put .data to be the last here is checking its name I think. 

There was no need to check order of got and got.plt because of stable_sort here, so I removed getRelroSectionRank(), but anyways here and in assignAddresses() I was not able to get rid of compare of name with ".data".


http://reviews.llvm.org/D14218





More information about the llvm-commits mailing list