[PATCH] D89185: Fix broken bitstream linking with lld when e_machine > 255

Christian Iversen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 10 05:39:05 PDT 2020


chrivers created this revision.
Herald added subscribers: llvm-commits, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a reviewer: MaskRay.
Herald added a project: LLVM.
chrivers requested review of this revision.

In lld's ELF/InputFiles.cpp, getBitcodeMachineKind() is limited to uint8_t return type.

This works as long as EM_xxx is < 256, which is true for all common architectures,
but not for all (experimental) targets.

The corresponding ELF field can hold uint16_t, so change getBitcodeMachineKind() to uint16_t as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89185

Files:
  lld/ELF/InputFiles.cpp


Index: lld/ELF/InputFiles.cpp
===================================================================
--- lld/ELF/InputFiles.cpp
+++ lld/ELF/InputFiles.cpp
@@ -1364,7 +1364,7 @@
   return t.isArch64Bit() ? ELF64BEKind : ELF32BEKind;
 }

-static uint8_t getBitcodeMachineKind(StringRef path, const Triple &t) {
+static uint16_t getBitcodeMachineKind(StringRef path, const Triple &t) {
   switch (t.getArch()) {
   case Triple::aarch64:
     return EM_AARCH64;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89185.297406.patch
Type: text/x-patch
Size: 455 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201010/6fa9b7dc/attachment.bin>


More information about the llvm-commits mailing list