[PATCH] D23655: [ELF] - Fix for PR28976 - Corrupted section contents when using linker scripts

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 19 02:10:04 PDT 2016


grimar added inline comments.

================
Comment at: ELF/Relocations.cpp:559
@@ -558,3 +558,3 @@
         continue;
       Offset = PieceI->OutputOff + RI.r_offset - PieceI->InputOff;
     } else {
----------------
ruiu wrote:
> This seems a cool fix, but is it safe? Specifically, my concern is on this line.
> 
> We used to call `getOffset` only in the following path. If `PieceI != PieceE`, `getOffset` was not called. Now you call `getOffset` on both paths. Didn't change the behavior?
Yep, I think it is safe. See:

If PieceI != PieceE that means C is EhInputSection, right ? (see line 528-529 above)

```
  if (auto *Eh = dyn_cast<EhInputSection<ELFT>>(&C))
    Pieces = Eh->Pieces;
```

and getOffset() for EHFrame always returns just an Offset given:

```
template <class ELFT>
typename ELFT::uint InputSectionBase<ELFT>::getOffset(uintX_t Offset) const {
  switch (SectionKind) {
...
  case EHFrame:
    // The file crtbeginT.o has relocations pointing to the start of an empty
    // .eh_frame that is known to be the first in the link. It does that to
    // identify the start of the output .eh_frame.
    return Offset;
```

So in fact I call getOffset on both paths but that does not change anything I believe.


https://reviews.llvm.org/D23655





More information about the llvm-commits mailing list