aboutsummaryrefslogtreecommitdiff
path: root/bfd/elfnn-loongarch.c
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 /bfd/elfnn-loongarch.c
parent0d94a8735055432029237612a6eb9165db1ec9dd (diff)
downloadgdb-c4a7e6b56218e1d5a858682186b542e2eae01a4a.zip
gdb-c4a7e6b56218e1d5a858682186b542e2eae01a4a.tar.gz
gdb-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 'bfd/elfnn-loongarch.c')
-rw-r--r--bfd/elfnn-loongarch.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
index 33c85e5..c040c5b 100644
--- a/bfd/elfnn-loongarch.c
+++ b/bfd/elfnn-loongarch.c
@@ -416,8 +416,22 @@ elfNN_loongarch_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
elf_elfheader (obfd)->e_flags = in_flags;
return true;
}
+ else if (out_flags != in_flags)
+ {
+ if ((EF_LOONGARCH_IS_OBJ_V0 (out_flags)
+ && EF_LOONGARCH_IS_OBJ_V1 (in_flags))
+ || (EF_LOONGARCH_IS_OBJ_V0 (in_flags)
+ && EF_LOONGARCH_IS_OBJ_V1 (out_flags)))
+ {
+ elf_elfheader (obfd)->e_flags |= EF_LOONGARCH_OBJABI_V1;
+ out_flags = elf_elfheader (obfd)->e_flags;
+ in_flags = out_flags;
+ }
+ }
/* Disallow linking different ABIs. */
+ /* Only check relocation version.
+ The obj_v0 is compatible with obj_v1. */
if (EF_LOONGARCH_ABI(out_flags ^ in_flags) & EF_LOONGARCH_ABI_MASK)
{
_bfd_error_handler (_("%pB: can't link different ABI object."), ibfd);
@@ -1579,15 +1593,16 @@ loongarch_elf_size_dynamic_sections (bfd *output_bfd,
if (bfd_link_executable (info) && !info->nointerp)
{
const char *interpreter;
- flagword flags = elf_elfheader (output_bfd)->e_flags;
s = bfd_get_linker_section (dynobj, ".interp");
BFD_ASSERT (s != NULL);
- if (EF_LOONGARCH_IS_ILP32 (flags))
+
+ if (elf_elfheader (output_bfd)->e_ident[EI_CLASS] == ELFCLASS32)
interpreter = "/lib32/ld.so.1";
- else if (EF_LOONGARCH_IS_LP64 (flags))
+ else if (elf_elfheader (output_bfd)->e_ident[EI_CLASS] == ELFCLASS64)
interpreter = "/lib64/ld.so.1";
else
interpreter = "/lib/ld.so.1";
+
s->contents = (unsigned char *) interpreter;
s->size = strlen (interpreter) + 1;
}