[PATCH] D140291: [llvm-objcopy] Use getNumberOfSymbols() instead of getRawNumberOfSymbols()

Daan De Meyer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 19 04:49:42 PST 2022


DaanDeMeyer added a comment.

> This sounds like an argument saying the existing code is correct, no?

My bad, I switched the order of getRawNumberOfSymbols() and getNumberOfSymbols() around.

> From reading COFFObjectFile::getNumberOfSymbols() and COFFObjectFile::getRawNumberOfSymbols(), the only difference I see would be if we're operating on an object file without a symbol table - where the former nicely returns 0 while the latter hits llvm_unreachable? What's the actual situation you've got at hand here?

When running llvm-objcopy built from source on an AARCH64 EFI executable built from source without this patch, I get the following error:

  ➜  llvm-project git:(main) build/bin/llvm-objcopy linuxaa64.efi.stub abc
  build/bin/llvm-objcopy: error: 'linuxaa64.efi.stub': Invalid data was encountered while parsing the file

I looked into the error, and the root cause of the error is that `getRawNumberOfSymbols()` returns `1` while `getNumberOfSymbols()` returns `0


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140291



More information about the llvm-commits mailing list