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.13]) by sourceware.org (Postfix) with UTF8SMTPS id 307843858C66 for ; Tue, 25 Jul 2023 08:16:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 307843858C66 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=oss.cipunited.com Authentication-Results: sourceware.org; spf=pass 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=1690272964; h=from:subject:mime-version:from:date:message-id:subject:to:cc: reply-to:content-type:mime-version:in-reply-to:message-id; bh=MypJmGvzFRlWR6PC8g+sJ5sI52+lG+FXw+MpAAgcrNk=; b=NAej6UmE6Oi7cglV3sPVtNPF7iLYFzEq4D9t/JTUf0aLKH5IoC8Cp1Z+4We/zbfKwnnVuA Sg82hGqt0NWdvlokTweakFcWsrG39aZaf2UpUGMJoCc9MFlHuBtosKLLtBmE7PaUowM5pu DPSgedzNFDnf+qM4S6c3DhmNQp/ynXTTZE+bG/udn5LPvfM4zvI9ygUtbaiQQUUnQLr63h DH2Y4UZjYUCmRB6VPKpuq6u1COoh80zyrZk52Ha7SpLef/7P6BSiDFJMts5aTdYPFY7C9G 9Jg0RPo5JDhA3rry6ud37lBu8b2U9ZbADqi/sRJsVUreWzbI1/6Bo/JbP+P8CQ== To: "Mark Wielaard" X-Original-From: Ying Huang Content-Type: multipart/alternative; boundary=a76078bb940fd8fd349584e4f2814dc136e50122c5219666694b86f677fc X-Lms-Return-Path: Cc: , Date: Tue, 25 Jul 2023 16:15:48 +0800 Content-Transfer-Encoding: 8bit User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 In-Reply-To: Content-Language: en-US From: "Ying Huang" Subject: Re: [PATCH 2/5] readelf: Adapt src/readelf -h/-S/-r/-w/-l/-d/-a on mips Message-Id: <18ad5b3f-a640-7923-3ff5-0c52e66a25a1@oss.cipunited.com> Mime-Version: 1.0 References: <20230411081141.1762395-1-ying.huang@oss.cipunited.com> <20230411081141.1762395-3-ying.huang@oss.cipunited.com> <3a59ea20739cde776aad7945ca4cc09055e1db6f.camel@klomp.org> X-Spam-Status: No, score=-11.7 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: --a76078bb940fd8fd349584e4f2814dc136e50122c5219666694b86f677fc Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Hi Mark=EF=BC=8C In file common-reloc.c, hook functions reloc_type_check/reloc_type_use/relo= c_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 the= 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 adde= d), 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, &ehdr= ) !=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, &ehdr= ) !=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) : NUL= L; >>> + 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 fi= le 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 > >= --a76078bb940fd8fd349584e4f2814dc136e50122c5219666694b86f677fc--