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

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 21 09:44:21 PST 2017


On 21 November 2017 at 17:41, Rafael Avila de Espindola
<rafael.espindola at gmail.com> wrote:
> I think I am fine with the overall direction of this change.
>
> My main request is to split the patch in 2 or even better 3:
>
> * Give an error if relro is not contiguous.
> * Relax handling of empty sections.
> * Name change when linker scripts are used.
>

Ok, I'll work on that tomorrow.

>> +  bool InRelroPhdr = false;
>> +  bool IsRelroFinished = false;
>> +  for (OutputSection *Sec : OutputSections) {
>> +    if (!needsPtLoad(Sec))
>> +      continue;
>> +    if (isRelroSection(Sec)) {
>> +      InRelroPhdr = true;
>> +      if (!IsRelroFinished)
>> +        RelRo->add(Sec);
>> +      else if (Sec->Size)
>> +        error("section: " + Sec->Name + " is not contiguous with other relro" +
>> +              " sections");
>> +    } else if (InRelroPhdr && Sec->Size) {
>> +      InRelroPhdr = false;
>> +      IsRelroFinished = true;
>> +    }
>> +  }
>
> With this an empty relro section can still start the PT_GNU_RELRO. Is
> that intentional?
>

I think I've missed that case, I'll fix and make sure I've got a test
to cover it.

Thanks very much for the comments.

Peter


More information about the llvm-commits mailing list