GNU gold handles output section fillers as 32-bit values.
This patch makes LLD compatible with that behavior.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
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:
- Step 1 - place filler to buffer: 0x0F 0x1F 0x0F 0x1F 0x0F 0x1F 0x0F 0x1F
- 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.
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.