From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from s01.bc.larksuite.com (s01.bc.larksuite.com [209.127.230.18]) by sourceware.org (Postfix) with UTF8SMTPS id 3B1713858C2F for ; Thu, 27 Jul 2023 06:09:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3B1713858C2F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=oss.cipunited.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=oss.cipunited.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=feishu2303200042; d=oss.cipunited.com; t=1690438145; h=from:subject:mime-version:from:date:message-id:subject:to:cc: reply-to:content-type:mime-version:in-reply-to:message-id; bh=usTjNEcix4tBivi3ji8u6AFjU7ZS8oOiHHArUn2GB74=; b=WFnjTPWZ7f7VYoT706iNwj37sOb4LEdx+eNs+JKIfawwOV6Ca73hqzVsKSBrS6atl/cOyd 3pCalQC3a1XVwXGJwbSdNoIyCGUewuVrlGic9T0spTL4UthSV9/1h2h7t4wFLp4hOJXoN/ CoDwLsTp3FCWhc9U3Li+RlaiaNoir9E5t3FQB7vw4zOO2tONZqUamYBeK/RrAlJpzFnXVI 4a827x9r/nSbd+Ml+i9o6T3uSHgtfYHJQnb1LP2vsKHc1SQJsow/tncIzvB73sCg5JMWyh sS/Rpyef1gEL/U6Uidh4zE+gaAY883Pr4Fj1Hf4xJJqA2WRyoLOhtorx22BTow== From: "Ying Huang" Message-Id: Content-Type: multipart/alternative; boundary=dd1fc79dc18983a136f4ade1743f1fc8db67b2e2d9c7e2df6c07c82dfd3d References: <20230411081141.1762395-1-ying.huang@oss.cipunited.com> <20230411081141.1762395-3-ying.huang@oss.cipunited.com> <3a59ea20739cde776aad7945ca4cc09055e1db6f.camel@klomp.org> <18ad5b3f-a640-7923-3ff5-0c52e66a25a1@oss.cipunited.com> To: "Mark Wielaard" Cc: , Content-Language: en-US User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 X-Lms-Return-Path: Subject: Re: [PATCH 2/5] readelf: Adapt src/readelf -h/-S/-r/-w/-l/-d/-a on mips Mime-Version: 1.0 In-Reply-To: <18ad5b3f-a640-7923-3ff5-0c52e66a25a1@oss.cipunited.com> Content-Transfer-Encoding: 8bit Date: Thu, 27 Jul 2023 14:08:52 +0800 X-Original-From: Ying Huang X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,HTML_MESSAGE,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --dd1fc79dc18983a136f4ade1743f1fc8db67b2e2d9c7e2df6c07c82dfd3d Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 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 =E5=9C=A8 2023/7/25 16:15, Ying Huang =E5=86=99=E9=81=93: > Hi Mark=EF=BC=8C > > In file common-reloc.c, hook functions reloc_type_check/reloc_type_use/re= loc_type_name have these codes: > > #ifdef RELOC_TYPE_ID > =C2=A0 reloc =3D 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 > =C2=A0=C2=A0 r_type field to encode a secondary addend.=C2=A0 Make sure t= he routines > =C2=A0=C2=A0 in common-reloc.c acknowledge this.=C2=A0 */ > #define RELOC_TYPE_ID(type) ((type) & 0xff) > > The contents of macro RELOC_TYPE_ID were same as ELF64_MIPS_R_TYPE(new ad= ded), so my view is did not add new hook for mips, if we can do like sparc? > > Thanks, > > Ying > > =E5=9C=A8 2023/7/24 16:35, Ying Huang =E5=86=99=E9=81=93: >> 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 >>>>=20=20 >>>> #include >>>> - >>>> +#include >>>>=20=20 >>>> bool >>>> ebl_reloc_type_check (Ebl *ebl, int reloc) >>>> { >>>> - return ebl !=3D NULL ? ebl->reloc_type_check (reloc) : false; >>>> + int relocNew =3D reloc; >>>> + GElf_Ehdr ehdr; >>>> + if(ebl->elf->class =3D=3D ELFCLASS64 && gelf_getehdr(ebl->elf, &ehd= r) !=3D NULL && ehdr.e_machine =3D=3D EM_MIPS) >>>> + relocNew =3D ELF64_MIPS_R_TYPE(reloc); >>>> + return ebl !=3D 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 @@ >>>>=20=20 >>>> #include >>>> #include >>>> - >>>> +#include >>>>=20=20 >>>> const char * >>>> ebl_reloc_type_name (Ebl *ebl, int reloc, char *buf, size_t len) >>>> { >>>> const char *res; >>>> + int relocNew =3D reloc; >>>> + GElf_Ehdr ehdr; >>>> + if(ebl->elf->class =3D=3D ELFCLASS64 && gelf_getehdr(ebl->elf, &ehd= r) !=3D NULL && ehdr.e_machine =3D=3D EM_MIPS) >>>> + relocNew =3D ELF64_MIPS_R_TYPE(reloc); >>>>=20=20 >>>> - res =3D ebl !=3D NULL ? ebl->reloc_type_name (reloc, buf, len) : NU= LL; >>>> + res =3D ebl !=3D NULL ? ebl->reloc_type_name (relocNew, buf, len) := NULL; >>>> if (res =3D=3D NULL) >>>> /* There are no generic relocation type names. */ >>>> res =3D ""; >>> Likewise for hooking reloc_type_name. >>> >> The function reloc_type_check and reloc_type_name were common hooks in f= ile backends/common-reloc.c, so if we also need a new hook for mips and cop= y the check codes from common-reloc.c? >> >> Thanks, >> >> Ying >> >>= --dd1fc79dc18983a136f4ade1743f1fc8db67b2e2d9c7e2df6c07c82dfd3d--