File tree 2 files changed +23
-8
lines changed
2 files changed +23
-8
lines changed Original file line number Diff line number Diff line change @@ -2021,16 +2021,22 @@ void LinkerDriver::inferMachineType() {
2021
2021
if (config->ekind != ELFNoneKind)
2022
2022
return ;
2023
2023
2024
+ bool inferred = false ;
2024
2025
for (InputFile *f : files) {
2025
2026
if (f->ekind == ELFNoneKind)
2026
2027
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
+ }
2029
2034
config->osabi = f->osabi ;
2030
- config-> mipsN32Abi = config-> emachine == EM_MIPS && isMipsN32Abi (f);
2031
- return ;
2035
+ if (f-> osabi != ELFOSABI_NONE)
2036
+ return ;
2032
2037
}
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" );
2034
2040
}
2035
2041
2036
2042
// Parse -z max-page-size=<value>. The default value is defined by
Original file line number Diff line number Diff line change 1
1
# REQUIRES: x86
2
2
# Verify that OSABI is set to the correct value.
3
3
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
7
12
13
+ #--- empty.s
14
+ #--- a.s
8
15
.globl _start
9
16
_start:
10
17
mov $1 , %rax
11
18
mov $42 , %rdi
12
19
syscall
20
+ #--- gnu.s
21
+ .section retain,"aR"
13
22
14
23
# CHECK: ElfHeader {
15
24
# CHECK-NEXT: Ident {
You can’t perform that action at this time.
0 commit comments