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.17]) by sourceware.org (Postfix) with UTF8SMTPS id AC5543858C62 for ; Mon, 24 Jul 2023 08:35:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AC5543858C62 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=1690187737; h=from:subject:mime-version:from:date:message-id:subject:to:cc: reply-to:content-type:mime-version:in-reply-to:message-id; bh=HXI/582OPA3RYuknpNNH36mb5cf6Y+S4EmkJANyUGy4=; b=dtxL6ZpYG/3LcYwc2yDjyzgTAUnAhpvfCvr88D01e/dQO73PvscAeyonYJ/S3gYmTDtxGK QsZSGJYYE2q1TGOlBVL89NZo2R9JJFnr3Sgf5QQwvRRDyCh5KsJOrkZlWsbKrJTRzWdz8C APwVAdfP8/Z2donlBOGkthyOyiTJ3CHjG8jGMRsiAY5mPR58uXplPsc0TMB1DPXS1vxm7J h7U7ChrVRvzFkOBtfwbFhZb6fzqHe9sIuUDaEL3ElQUnjJO2zryDd9L8zIbHXzn6dxxGNS cra7t9741D/GmxTSB+7nayFWSqta8hfDyDB7BFUWMBan+Kg+9Mvs6DvXFDPKhA== Cc: , X-Original-From: Ying Huang Content-Language: en-US To: "Mark Wielaard" Message-Id: Content-Type: multipart/alternative; boundary=ab4408612dda4cc709dd599859b3a0463c0d5e0c9d51ba74665a6ce773f3 Content-Transfer-Encoding: 7bit In-Reply-To: <3a59ea20739cde776aad7945ca4cc09055e1db6f.camel@klomp.org> Subject: Re: [PATCH 2/5] readelf: Adapt src/readelf -h/-S/-r/-w/-l/-d/-a on mips Date: Mon, 24 Jul 2023 16:35:28 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 X-Lms-Return-Path: References: <20230411081141.1762395-1-ying.huang@oss.cipunited.com> <20230411081141.1762395-3-ying.huang@oss.cipunited.com> <3a59ea20739cde776aad7945ca4cc09055e1db6f.camel@klomp.org> From: "Ying Huang" Mime-Version: 1.0 X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00,DKIM_INVALID,DKIM_SIGNED,GIT_PATCH_0,HTML_MESSAGE,KAM_DMARC_STATUS,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: --ab4408612dda4cc709dd599859b3a0463c0d5e0c9d51ba74665a6ce773f3 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 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) : NULL; >> + res =3D ebl !=3D NULL ? ebl->reloc_type_name (relocNew, buf, len) : N= ULL; >> 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 file= backends/common-reloc.c, so if we also need a new hook for mips and copy t= he check codes from common-reloc.c? Thanks, Ying= --ab4408612dda4cc709dd599859b3a0463c0d5e0c9d51ba74665a6ce773f3--