[PATCH] D36739: [LLD][ELF] Move fixSectionAlignments() before first call to assignAddresses()
Peter Smith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 15 07:50:08 PDT 2017
peter.smith created this revision.
Herald added a subscriber: emaste.
The fixSectionAlignments() function may alter the alignment of some OutputSections, this is likely to alter the addresses calculated earlier in assignAddresses(). By moving the call to fixSectionAlignments() we make sure that assignAddresses() is consistent with the early calculation used for RangeThunks and the final call just before writing the image.
This difference in address between the first call the assignAddresses() and the second may, with some linker scripts, cause some range-thunk calculations to go wrong, however for the majority of links it won't affect the relative offsets between callers and callees.
It is more important for a fix for pr33463 https://bugs.llvm.org/show_bug.cgi?id=33463 as the sequence of instructions that trigger the cortex-a53 errata are sensitive to address modulo 0x1000.
https://reviews.llvm.org/D36739
Files:
ELF/Writer.cpp
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -193,9 +193,6 @@
if (ErrorCount)
return;
- if (!Script->Opt.HasSections && !Config->Relocatable)
- fixSectionAlignments();
-
// If -compressed-debug-sections is specified, we need to compress
// .debug_* sections. Do it right now because it changes the size of
// output sections.
@@ -1303,6 +1300,9 @@
In<ELFT>::VerSym, In<ELFT>::VerNeed, InX::Dynamic},
[](SyntheticSection *SS) { SS->finalizeContents(); });
+ if (!Script->Opt.HasSections && !Config->Relocatable)
+ fixSectionAlignments();
+
// Some architectures use small displacements for jump instructions.
// It is linker's responsibility to create thunks containing long
// jump instructions if jump targets are too far. Create thunks.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36739.111164.patch
Type: text/x-patch
Size: 902 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170815/b12adfff/attachment.bin>
More information about the llvm-commits
mailing list