[PATCH] D117233: [llvm-objcopy] Preserve ARM and AArch64 mapping symbols

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 13 09:46:19 PST 2022


MaskRay added subscribers: DavidSpickett, peter.smith.
MaskRay added a comment.

This doesn't seem like GNU objcopy/strip behavior. --strip-unneeded/--discard-locals removes mapping symbols.
Are they going to make similar changes? @DavidSpickett @peter.smith may know who may answer the question.

> They help to disassemble files correctly and are also used in linkers.

ld.lld doesn't have special rules for mapping symbols.

Disassembling is an interesting angle. But removing unneeded local symbols (e.g. internal linkage functions) can make the disassembly results worse, too.
It is unclear to me how to want to preserve some local symbols but not others.
The documentation for --discard-locals (in llvm-objcopy and GNU objcopy) mentions `compiler-generated local symbols`, and I may put mapping symbols into this category as well, but it seems to need some clarification.



================
Comment at: llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp:231
+static bool isAArch64MappingSymbol(const Symbol &Sym) {
+  if (Sym.Binding != STB_LOCAL || Sym.Type != STT_NOTYPE ||
+      Sym.getShndx() == SHN_UNDEF)
----------------
aaelf64 says `All mapping symbols have type ``STT_NOTYPE`` and binding ``STB_LOCAL``.`

The `Sym.getShndx() == SHN_UNDEF` condition shouldn't appear in practice but seems fine to keep (an undefined local is assuredly an error).




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117233



More information about the llvm-commits mailing list