This is an archive of the discontinued LLVM Phabricator instance.

Make lld actually compatible with gold in terms of filler handling.
ClosedPublic

Authored by ruiu on Aug 4 2016, 2:55 PM.

Diff Detail

Event Timeline

ruiu updated this revision to Diff 66860.Aug 4 2016, 2:55 PM
ruiu updated this revision to Diff 66862.
ruiu retitled this revision from to Make lld actually compatible with gold in terms of filler handling..
ruiu updated this object.
ruiu added reviewers: davide, rafael.
ruiu added a subscriber: llvm-commits.
  • Update comments.
grimar added a subscriber: grimar.Aug 5 2016, 12:07 AM

Not relative to this patch, but relative to filler functionality:

I still have consern about how OutputSection<ELFT>::writeTo() works with filler() method.
Currently it just fills buffer with filler and places sections on top. Filler is usually NOP, nop on x86 can be 0x90,
so that works fine for that case.
But imagine someone decides to use 2 byte version of NOP. For x86 it is (according to wiki https://en.wikipedia.org/wiki/NOP) 0x0F 0x1F.
Lets say we have 2 sections, each one is one byte (0xFF for example) and has aligment of 4. So filler is 0x0F1F0F1F

Current implementation will produce:

  1. Step 1 - place filler to buffer: 0x0F 0x1F 0x0F 0x1F 0x0F 0x1F 0x0F 0x1F
  2. Step 2 - place sections on top: 0xFF 0x1F 0x0F 0x1F 0xFF 0x1F 0x0F 0x1F

At the same time gold/bfd as far I remember starts placing filler in between of sections,
so they would produce:
0xFF 0x0F 0x1F 0x0F 0x1F 0xFF 0x0F 0x1F 0x0F 0x1F

That looks more correct as NOP is 0x0F 0x1F and not the reverse.

ruiu added a comment.Aug 5 2016, 2:44 PM

If you have an easy fix, please send it to review, but discussing it in a different review thread is probably not a good idea.

rafael accepted this revision.Aug 25 2016, 2:36 PM
rafael edited edge metadata.

LGTM

This revision is now accepted and ready to land.Aug 25 2016, 2:36 PM
This revision was automatically updated to reflect the committed changes.