diff options
author | Alexey Sheplyakov <asheplyakov@basealt.ru> | 2023-03-20 18:45:02 +0400 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2023-03-20 23:33:40 +0100 |
commit | b2871fa8d430e2c5fb39e3ebc6745ea32f1bddb4 (patch) | |
tree | 67b627a53ea3d94bafc5255e6ea3f81c80ab0096 | |
parent | 5527216460c6131527c27b06dada015b67525966 (diff) | |
download | elfutils-b2871fa8d430e2c5fb39e3ebc6745ea32f1bddb4.tar.gz |
LoongArch: implemented a basic machine flag check
With this patch I can use eu-elflint to verify LoongArch ELF
binaries. Previously eu-elflint was complaining about invalid
machine flags:
$ ./src/elflint --gnu-ld ./src/elflint
invalid machine flags: 0x43
$ echo $?
1
* backends/loongarch_symbol.c (loongarch_init): Hook
machine_flag_check.
* backends/loongarch_symbol.c (loongarch_machine_flag_check):
New function.
https://sourceware.org/bugzilla/show_bug.cgi?id=30251
Signed-off-by: Alexey Sheplyakov <asheplyakov@basealt.ru>
-rw-r--r-- | backends/loongarch_init.c | 1 | ||||
-rw-r--r-- | backends/loongarch_symbol.c | 7 |
2 files changed, 8 insertions, 0 deletions
diff --git a/backends/loongarch_init.c b/backends/loongarch_init.c index a8ed9e81..59d8cc3d 100644 --- a/backends/loongarch_init.c +++ b/backends/loongarch_init.c @@ -45,6 +45,7 @@ loongarch_init (Elf *elf __attribute__ ((unused)), { loongarch_init_reloc (eh); HOOK (eh, reloc_simple_type); + HOOK (eh, machine_flag_check); return eh; } diff --git a/backends/loongarch_symbol.c b/backends/loongarch_symbol.c index 8ba66a09..43306ab8 100644 --- a/backends/loongarch_symbol.c +++ b/backends/loongarch_symbol.c @@ -72,3 +72,10 @@ loongarch_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type, return ELF_T_NUM; } } + +bool +loongarch_machine_flag_check (GElf_Word flags) +{ + return ((flags &~ (EF_LARCH_ABI_MODIFIER_MASK + | EF_LARCH_OBJABI_V1)) == 0); +} |