[PATCH] D23181: Make lld actually compatible with gold in terms of filler handling.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 5 00:07:46 PDT 2016


grimar added a subscriber: grimar.
grimar added a comment.

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.


https://reviews.llvm.org/D23181





More information about the llvm-commits mailing list