File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2021,16 +2021,22 @@ void LinkerDriver::inferMachineType() {
20212021 if (config->ekind != ELFNoneKind)
20222022 return ;
20232023
2024+ bool inferred = false ;
20242025 for (InputFile *f : files) {
20252026 if (f->ekind == ELFNoneKind)
20262027 continue ;
2027- config->ekind = f->ekind ;
2028- config->emachine = f->emachine ;
2028+ if (!inferred) {
2029+ inferred = true ;
2030+ config->ekind = f->ekind ;
2031+ config->emachine = f->emachine ;
2032+ config->mipsN32Abi = config->emachine == EM_MIPS && isMipsN32Abi (f);
2033+ }
20292034 config->osabi = f->osabi ;
2030- config-> mipsN32Abi = config-> emachine == EM_MIPS && isMipsN32Abi (f);
2031- return ;
2035+ if (f-> osabi != ELFOSABI_NONE)
2036+ return ;
20322037 }
2033- error (" target emulation unknown: -m or at least one .o file required" );
2038+ if (!inferred)
2039+ error (" target emulation unknown: -m or at least one .o file required" );
20342040}
20352041
20362042// Parse -z max-page-size=<value>. The default value is defined by
Original file line number Diff line number Diff line change 11# REQUIRES: x86
22# Verify that OSABI is set to the correct value.
33
4- # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-freebsd %s -o %t
5- # RUN: ld.lld %t -o %t2
6- # RUN: llvm-readobj --file-headers %t2 | FileCheck %s
4+ # RUN: rm -rf %t && split-file %s %t && cd %t
5+ # RUN: llvm-mc -filetype=obj -triple=x86_64 empty.s -o empty.o
6+ # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-freebsd a.s -o a.o
7+ # RUN: llvm-mc -filetype=obj -triple=x86_64-linux gnu.s -o gnu.o
8+ # RUN: ld.lld a.o -o out
9+ # RUN: llvm-readobj --file-headers out | FileCheck %s
10+ # RUN: ld.lld empty.o a.o gnu.o empty.o -o out2
11+ # RUN: llvm-readobj --file-headers out2 | FileCheck %s
712
13+ #--- empty.s
14+ #--- a.s
815.globl _start
916_start:
1017 mov $1 , %rax
1118 mov $42 , %rdi
1219 syscall
20+ #--- gnu.s
21+ .section retain,"aR"
1322
1423# CHECK: ElfHeader {
1524# CHECK-NEXT: Ident {
You can’t perform that action at this time.
0 commit comments