From: "Ying Huang" <ying.huang@oss.cipunited.com>
To: "Mark Wielaard" <mark@klomp.org>
Cc: <elfutils-devel@sourceware.org>, <yunqiang.su@oss.cipunited.com>
Subject: Re: [PATCH 2/5] readelf: Adapt src/readelf -h/-S/-r/-w/-l/-d/-a on mips
Date: Thu, 27 Jul 2023 14:08:52 +0800 [thread overview]
Message-ID: <b41a02cc-60f0-131b-73e7-93126930e8db@oss.cipunited.com> (raw)
In-Reply-To: <18ad5b3f-a640-7923-3ff5-0c52e66a25a1@oss.cipunited.com>
[-- Attachment #1: Type: text/plain, Size: 3205 bytes --]
Hi Mark,
Can we add a new file mips.h in backends, and move defines of ELF64_MIPS_R_TYPE/ELF64_MIPS_R_TYPE2/ELF64_MIPS_R_TYPE3 from elf.h to mips.h?
And rename the macro name ELF64_MIPS_R_TYPE to ELF64_MIPS_R_TYPE1 in mips.h? Or rename it directly in elf.h of glibc?
Thanks,
Ying
在 2023/7/25 16:15, Ying Huang 写道:
> Hi Mark,
>
> In file common-reloc.c, hook functions reloc_type_check/reloc_type_use/reloc_type_name have these codes:
>
> #ifdef RELOC_TYPE_ID
> reloc = RELOC_TYPE_ID (reloc);
> #endif
>
> And the macro RELOC_TYPE_ID was defined in file backends/sparc_init.c:
>
> /* In SPARC some relocations use the most significative 24 bits of the
> r_type field to encode a secondary addend. Make sure the routines
> in common-reloc.c acknowledge this. */
> #define RELOC_TYPE_ID(type) ((type) & 0xff)
>
> The contents of macro RELOC_TYPE_ID were same as ELF64_MIPS_R_TYPE(new added), so my view is did not add new hook for mips, if we can do like sparc?
>
> Thanks,
>
> Ying
>
> 在 2023/7/24 16:35, Ying Huang 写道:
>> Hi Mark,
>>
>>>> diff --git a/libebl/eblreloctypecheck.c b/libebl/eblreloctypecheck.c
>>>> index 80e67ef7..e3c43944 100644
>>>> --- a/libebl/eblreloctypecheck.c
>>>> +++ b/libebl/eblreloctypecheck.c
>>>> @@ -32,10 +32,14 @@
>>>> #endif
>>>>
>>>> #include <libeblP.h>
>>>> -
>>>> +#include <libelfP.h>
>>>>
>>>> bool
>>>> ebl_reloc_type_check (Ebl *ebl, int reloc)
>>>> {
>>>> - return ebl != NULL ? ebl->reloc_type_check (reloc) : false;
>>>> + int relocNew = reloc;
>>>> + GElf_Ehdr ehdr;
>>>> + if(ebl->elf->class == ELFCLASS64 && gelf_getehdr(ebl->elf, &ehdr) != NULL && ehdr.e_machine == EM_MIPS)
>>>> + relocNew = ELF64_MIPS_R_TYPE(reloc);
>>>> + return ebl != NULL ? ebl->reloc_type_check (relocNew) : false;
>>>> }
>>> This should not go into the generic ebl_reloc_type_check but has to be
>>> hooked so it uses a mips_reloc_type_check.
>>>
>>>> diff --git a/libebl/eblreloctypename.c b/libebl/eblreloctypename.c
>>>> index e53ec0c0..4276d8e3 100644
>>>> --- a/libebl/eblreloctypename.c
>>>> +++ b/libebl/eblreloctypename.c
>>>> @@ -33,14 +33,18 @@
>>>>
>>>> #include <stdio.h>
>>>> #include <libeblP.h>
>>>> -
>>>> +#include <libelfP.h>
>>>>
>>>> const char *
>>>> ebl_reloc_type_name (Ebl *ebl, int reloc, char *buf, size_t len)
>>>> {
>>>> const char *res;
>>>> + int relocNew = reloc;
>>>> + GElf_Ehdr ehdr;
>>>> + if(ebl->elf->class == ELFCLASS64 && gelf_getehdr(ebl->elf, &ehdr) != NULL && ehdr.e_machine == EM_MIPS)
>>>> + relocNew = ELF64_MIPS_R_TYPE(reloc);
>>>>
>>>> - res = ebl != NULL ? ebl->reloc_type_name (reloc, buf, len) : NULL;
>>>> + res = ebl != NULL ? ebl->reloc_type_name (relocNew, buf, len) : NULL;
>>>> if (res == NULL)
>>>> /* There are no generic relocation type names. */
>>>> res = "<INVALID RELOC>";
>>> Likewise for hooking reloc_type_name.
>>>
>> The function reloc_type_check and reloc_type_name were common hooks in file backends/common-reloc.c, so if we also need a new hook for mips and copy the check codes from common-reloc.c?
>>
>> Thanks,
>>
>> Ying
>>
>>
next prev parent reply other threads:[~2023-07-27 6:09 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-11 8:12 [PATCH 0/5] Add support for MIPS Ying Huang
2023-04-11 8:12 ` [PATCH 1/5] strip: Adapt src/strip -o -f on mips Ying Huang
2023-05-09 15:15 ` Mark Wielaard
2023-05-16 6:38 ` Ying Huang
2023-05-21 21:13 ` Mark Wielaard
2023-05-24 6:21 ` Ying Huang
2023-05-16 6:46 ` Ying Huang
2023-05-16 7:34 ` Ying Huang
2023-05-21 21:14 ` Mark Wielaard
2023-05-26 2:48 ` Ying Huang
2023-05-16 8:05 ` [EXTERNAL] " Luke Diamand
2023-04-11 8:12 ` [PATCH 2/5] readelf: Adapt src/readelf -h/-S/-r/-w/-l/-d/-a " Ying Huang
2023-05-11 14:31 ` Mark Wielaard
2023-05-16 8:01 ` Ying Huang
2023-07-24 8:35 ` Ying Huang
2023-07-25 8:15 ` Ying Huang
2023-07-27 6:08 ` Ying Huang [this message]
2023-08-01 21:43 ` Mark Wielaard
2023-08-01 13:14 ` Mark Wielaard
2023-08-01 9:25 ` Mark Wielaard
2023-04-11 8:12 ` [PATCH 3/5] elflint: Fix invalid type of relocation info and other issues " Ying Huang
2023-05-11 15:59 ` Mark Wielaard
2023-05-17 9:14 ` Ying Huang
2023-04-11 8:12 ` [PATCH 4/5] stack: Fix stack unwind failure " Ying Huang
2023-05-11 16:07 ` Mark Wielaard
2023-05-18 6:14 ` Ying Huang
2023-04-11 8:12 ` [PATCH 5/5] backends: Fix run-native-test.sh and run-funcretval++11.sh run fail " Ying Huang
2023-05-11 16:38 ` Mark Wielaard
2023-05-18 9:06 ` Ying Huang
2023-05-04 2:24 ` [PATCH 0/5] Add support for MIPS 黄莺
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b41a02cc-60f0-131b-73e7-93126930e8db@oss.cipunited.com \
--to=ying.huang@oss.cipunited.com \
--cc=elfutils-devel@sourceware.org \
--cc=mark@klomp.org \
--cc=yunqiang.su@oss.cipunited.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).