aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorliuzhensong <liuzhensong@loongson.cn>2022-08-04 14:30:39 +0800
committerliuzhensong <liuzhensong@loongson.cn>2022-09-30 14:00:47 +0800
commitc4a7e6b56218e1d5a858682186b542e2eae01a4a (patch)
treecc3a1b9f8227ed91cea78da16773225743d1ebc5 /include
parent0d94a8735055432029237612a6eb9165db1ec9dd (diff)
downloadbinutils-c4a7e6b56218e1d5a858682186b542e2eae01a4a.zip
binutils-c4a7e6b56218e1d5a858682186b542e2eae01a4a.tar.gz
binutils-c4a7e6b56218e1d5a858682186b542e2eae01a4a.tar.bz2
LoongArch: Update ELF e_flags handling according to specification.
Update handling of e_flags according to the documentation update [1] (discussions [2][3]). Object file bitness is now represented in the EI_CLASS byte. The e_flags field is now interpreted as follows: e_flags[2:0]: Base ABI modifier - 0x1: soft-float - 0x2: single-precision hard-float - 0x3: double-precision hard-float e_flags[7:6]: ELF object ABI version - 0x0: v0 - 0x1: v1 [1]: https://github.com/loongson/LoongArch-Documentation/blob/main/docs/LoongArch-ELF-ABI-EN.adoc#e_flags-identifies-abi-type-and-version [2]: https://github.com/loongson/LoongArch-Documentation/pull/61 [3]: https://github.com/loongson/LoongArch-Documentation/pull/47
Diffstat (limited to 'include')
-rw-r--r--include/elf/loongarch.h44
1 files changed, 21 insertions, 23 deletions
diff --git a/include/elf/loongarch.h b/include/elf/loongarch.h
index 74757b8..a6341b4 100644
--- a/include/elf/loongarch.h
+++ b/include/elf/loongarch.h
@@ -232,36 +232,34 @@ RELOC_NUMBER (R_LARCH_RELAX, 100)
END_RELOC_NUMBERS (R_LARCH_count)
/* Processor specific flags for the ELF header e_flags field. */
-/*The flag lp64s/lp64f/lp64d/ilp32s/ilp32f/ilp32d 3bits. */
-#define EF_LOONGARCH_ABI_LP64_SOFT_FLOAT 0x1
-#define EF_LOONGARCH_ABI_LP64_SINGLE_FLOAT 0x2
-#define EF_LOONGARCH_ABI_LP64_DOUBLE_FLOAT 0x3
+/* Base ABI modifier, 3bits. */
+#define EF_LOONGARCH_ABI_SOFT_FLOAT 0x1
+#define EF_LOONGARCH_ABI_SINGLE_FLOAT 0x2
+#define EF_LOONGARCH_ABI_DOUBLE_FLOAT 0x3
+#define EF_LOONGARCH_ABI_MODIFIER_MASK 0x7
-#define EF_LOONGARCH_ABI_ILP32_SOFT_FLOAT 0x5
-#define EF_LOONGARCH_ABI_ILP32_SINGLE_FLOAT 0x6
-#define EF_LOONGARCH_ABI_ILP32_DOUBLE_FLOAT 0x7
+#define EF_LOONGARCH_OBJABI_V1 0x40
+#define EF_LOONGARCH_OBJABI_MASK 0xC0
-#define EF_LOONGARCH_ABI_MASK 0x7
-#define EF_LOONGARCH_ABI_ILP32_MASK 0x4
-#define EF_LOONGARCH_ABI_FLOAT_MASK 0x3
-#define EF_LOONGARCH_ABI_SOFT_FLOAT_MASK 0x1
-#define EF_LOONGARCH_ABI_SINGLE_FLOAT_MASK 0x2
-#define EF_LOONGARCH_ABI_DOUBLE_FLOAT_MASK 0x3
+#define EF_LOONGARCH_ABI_MASK \
+ (EF_LOONGARCH_OBJABI_MASK | EF_LOONGARCH_ABI_MODIFIER_MASK)
-#define EF_LOONGARCH_ABI(abi) (EF_LOONGARCH_ABI_MASK & (abi))
+#define EF_LOONGARCH_ABI_MODIFIER(abi) \
+ (EF_LOONGARCH_ABI_MODIFIER_MASK & (abi))
+#define EF_LOONGARCH_OBJABI(abi) \
+ (EF_LOONGARCH_OBJABI_MASK & (abi))
-#define EF_LOONGARCH_IS_LP64(abi) \
- (EF_LOONGARCH_ABI(abi) && (!(EF_LOONGARCH_ABI(abi) & EF_LOONGARCH_ABI_ILP32_MASK)))
-#define EF_LOONGARCH_IS_ILP32(abi) \
- (EF_LOONGARCH_ABI(abi) && (EF_LOONGARCH_ABI(abi) & EF_LOONGARCH_ABI_ILP32_MASK))
+#define EF_LOONGARCH_ABI(abi) ((abi) & EF_LOONGARCH_ABI_MASK)
#define EF_LOONGARCH_IS_SOFT_FLOAT(abi) \
- (!((EF_LOONGARCH_ABI(abi) & EF_LOONGARCH_ABI_FLOAT_MASK) ^ EF_LOONGARCH_ABI_SOFT_FLOAT_MASK))
-
+ (EF_LOONGARCH_ABI_MODIFIER (abi) == EF_LOONGARCH_ABI_SOFT_FLOAT)
#define EF_LOONGARCH_IS_SINGLE_FLOAT(abi) \
- (!((EF_LOONGARCH_ABI(abi) & EF_LOONGARCH_ABI_FLOAT_MASK) ^ EF_LOONGARCH_ABI_SINGLE_FLOAT_MASK))
-
+ (EF_LOONGARCH_ABI_MODIFIER (abi) == EF_LOONGARCH_ABI_SINGLE_FLOAT)
#define EF_LOONGARCH_IS_DOUBLE_FLOAT(abi) \
- (!((EF_LOONGARCH_ABI(abi) & EF_LOONGARCH_ABI_FLOAT_MASK) ^ EF_LOONGARCH_ABI_DOUBLE_FLOAT_MASK))
+ (EF_LOONGARCH_ABI_MODIFIER (abi) == EF_LOONGARCH_ABI_DOUBLE_FLOAT)
+
+#define EF_LOONGARCH_IS_OBJ_V0(abi) (!EF_LOONGARCH_OBJABI (abi))
+#define EF_LOONGARCH_IS_OBJ_V1(abi) \
+ (EF_LOONGARCH_OBJABI (abi) == EF_LOONGARCH_OBJABI_V1)
#endif /* _ELF_LOONGARCH_H */