[PATCH] D150870: [lld][Arm] Big Endian - Byte invariant support.

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 12 05:32:14 PDT 2023


peter.smith added a comment.

Only a small comment about making sure the mapping symbols remain sorted when adding symbols later.



================
Comment at: lld/ELF/Arch/ARM.cpp:969
+// Add a mapping symbol to the mapping symbol list.
+void elf::addArmMappingSymbols(Defined *sym) {
+  if (!isArmMapSymbol(sym) && !isDataMapSymbol(sym) && !isThumbMapSymbol(sym))
----------------
We are only adding a single symbol, whereas the name `addArmMappingSymbols` implies many symbols.

We should also be careful with using push_back here as we need to make sure that the mapping symbols are sorted. As it happens the way the code is used today push_back is fine as we always add the symbols in ascending order, but it would be easy to make a mistake in the future.

Possible solutions include:
* use insert rather than push_back
* sort the section map for the section after push_back
* possibly delay the sorting of the mapping symbols till the first use.
* change the name to push rather than add, make sure there is a comment to state that symbols must be pushed in ascending order.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150870/new/

https://reviews.llvm.org/D150870



More information about the llvm-commits mailing list