llvm.org GIT mirror llvm / 3da6527
[mips] Correct ELF e_flags for the N32 ABI when using a mips-* triple rather than a mips64-* triple Summary: Generally speaking, mips-* vs mips64-* should not be used to make decisions about the content or format of the ELF. This should be based on the ABI and CPU in use. For example, `mips-linux-gnu-clang -mips64r2 -mabi=64` should produce an ELF64 as should `mips64-linux-gnu-clang -mabi=64`. Conversely, `mips64-linux-gnu-clang -mabi=n32` should produce an ELF32 as should `mips-linux-gnu-clang -mips64r2 -mabi=n32`. This patch fixes the e_flags but leaves the ELF32 vs ELF64 issue for now since there is no apparent way to base this decision on the ABI and CPU. Differential Revision: http://reviews.llvm.org/D4539 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213244 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Sanders 5 years ago
2 changed file(s) with 18 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
280280 else
281281 EFlags |= ELF::EF_MIPS_ARCH_1;
282282
283 if (T.isArch64Bit()) {
284 if (Features & Mips::FeatureN32)
285 EFlags |= ELF::EF_MIPS_ABI2;
286 else if (Features & Mips::FeatureO32) {
287 EFlags |= ELF::EF_MIPS_ABI_O32;
283 // ABI
284 // N64 does not require any ABI bits.
285 if (Features & Mips::FeatureO32)
286 EFlags |= ELF::EF_MIPS_ABI_O32;
287 else if (Features & Mips::FeatureN32)
288 EFlags |= ELF::EF_MIPS_ABI2;
289
290 if (Features & Mips::FeatureGP64Bit) {
291 if (Features & Mips::FeatureO32)
288292 EFlags |= ELF::EF_MIPS_32BITMODE; /* Compatibility Mode */
289 }
290 // No need to set any bit for N64 which is the default ABI at the moment
291 // for 64-bit Mips architectures.
292 } else {
293 if (Features & Mips::FeatureMips64r2 || Features & Mips::FeatureMips64)
294 EFlags |= ELF::EF_MIPS_32BITMODE;
295
296 // ABI
297 EFlags |= ELF::EF_MIPS_ABI_O32;
298 }
293 } else if (Features & Mips::FeatureMips64r2 || Features & Mips::FeatureMips64)
294 EFlags |= ELF::EF_MIPS_32BITMODE;
299295
300296 // Other options.
301297 if (Features & Mips::FeatureNaN2008)
11 # corresponding options (-mcpu=mips32 -> -mips32 for example).
22
33 # RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r6 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPSEL-MIPS64R6 %s
4 # MIPSEL-MIPS64R6: Flags [ (0xA0001506)
4 # MIPSEL-MIPS64R6: Flags [ (0xA0000406)
55
66 # RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r6 -mattr=+nan2008 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPSEL-MIPS64R6-NAN2008 %s
7 # MIPSEL-MIPS64R6-NAN2008: Flags [ (0xA0001506)
7 # MIPSEL-MIPS64R6-NAN2008: Flags [ (0xA0000406)
88
99 # RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r2 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPSEL-MIPS64R2 %s
10 # MIPSEL-MIPS64R2: Flags [ (0x80001106)
10 # MIPSEL-MIPS64R2: Flags [ (0x80000006)
1111
1212 # RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r2 -mattr=+nan2008 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPSEL-MIPS64R2-NAN2008 %s
13 # MIPSEL-MIPS64R2-NAN2008: Flags [ (0x80001506)
13 # MIPSEL-MIPS64R2-NAN2008: Flags [ (0x80000406)
1414
1515 # RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPSEL-MIPS64 %s
16 # MIPSEL-MIPS64: Flags [ (0x60001106)
16 # MIPSEL-MIPS64: Flags [ (0x60000006)
1717
1818 # RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64 -mattr=+nan2008 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPSEL-MIPS64-NAN2008 %s
19 # MIPSEL-MIPS64-NAN2008: Flags [ (0x60001506)
19 # MIPSEL-MIPS64-NAN2008: Flags [ (0x60000406)
2020
2121 # RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips32r6 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPSEL-MIPS32R6 %s
2222 # MIPSEL-MIPS32R6: Flags [ (0x90001404)
3636 # RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips32 -mattr=+nan2008 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPSEL-MIPS32-NAN2008 %s
3737 # MIPSEL-MIPS32-NAN2008: Flags [ (0x50001404)
3838
39 # RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r2 -mattr=-n64,n32 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPS64EL-MIPS64R2-N32 %s
3940 # RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r2 -mattr=-n64,n32 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPS64EL-MIPS64R2-N32 %s
4041 # MIPS64EL-MIPS64R2-N32: Flags [ (0x80000024)
4142