[PATCH] D51089: [LLD] [COFF] [RFC] Add support for creating range extension thunks for ARM

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 22 04:19:01 PDT 2018


peter.smith added a comment.

Sadly I had to resort to using .space to create large binaries. Creating the binaries is usually quick, disassembling them is unfortunately not. I tended to used gnu objdump first as that skips 0 by default to find the address ranges I needed, then used --start-address and --stop-address in llvm-objdump to pull out the bits that I need.

In ELF we can use Linker Scripts for quite a few of the cases; although Linker Scripts make some corner cases possible that wouldn't exist otherwise. You may be able to do most of your tests with the conditional branch (+- 1 Mb), I didn't do that with ELF as the ThunkSections were placed at 16 Mb intervals as the vast majority of the relocations we would encounter were +- 16Mb.



================
Comment at: COFF/Writer.cpp:408
+          // forward - is this a concern?
+          Chunks.insert(Chunks.begin() + ThunkInsertionSpot, Thunk->getChunk());
+          ThunkInsertionSpot++;
----------------
mstorsjo wrote:
> peter.smith wrote:
> > In theory if you are iterating a fixed number (Chunks.size()) of the Chunks vector then inserting thunks into the Chunks vector in the same loop will mean that Chunks near the end may not be scanned for Thunks. Given that the algorithm will only terminate when 0 thunks are inserted you'll eventually scan all of them but it may cost you more passes than you would need if you inserted all Thunks in one go. I think you'll be unlikely to hit 10 passes without a contrived test case though.
> Hmm, I'm not quite sure I understand what you mean here. You mean that since I'm adding more elements to the Chunks vector, I'd miss the last few ones that were pushed forward? The limit on the outer loop, on line 379, explicitly checks for Chunks.size(), so it will loop until the very end of the vector, even if Chunks grows meanwhile.
Apologies, I had it my mind that Chunks.size() would only be calculated once per pass.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D51089





More information about the llvm-commits mailing list