[ELF] Fix broken bitstream linking with lld when e_machine > 255

In ELF/InputFiles.cpp, getBitcodeMachineKind() is limited to uint8_t return
type. This works as long as EM_xxx is < 256, which is true for common
architectures, but not for some newly assigned or unofficial EM_* values.

The corresponding ELF field (e_machine) can hold uint16_t.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D89185
This commit is contained in:
Christian Iversen 2020-10-11 14:19:25 -07:00 committed by Fangrui Song
parent 8178e41dc1
commit a9cefc3dee
1 changed files with 1 additions and 1 deletions

View File

@ -1517,7 +1517,7 @@ static ELFKind getBitcodeELFKind(const Triple &t) {
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;