From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id 05AD83858C53 for ; Tue, 1 Aug 2023 09:25:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 05AD83858C53 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from r6.localdomain (82-217-174-174.cable.dynamic.v4.ziggo.nl [82.217.174.174]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id BEA4B3000913; Tue, 1 Aug 2023 11:25:20 +0200 (CEST) Received: by r6.localdomain (Postfix, from userid 1000) id 809A2340276; Tue, 1 Aug 2023 11:25:20 +0200 (CEST) Message-ID: Subject: Re: [PATCH 2/5] readelf: Adapt src/readelf -h/-S/-r/-w/-l/-d/-a on mips From: Mark Wielaard To: Ying Huang Cc: elfutils-devel@sourceware.org, yunqiang.su@oss.cipunited.com Date: Tue, 01 Aug 2023 11:25:20 +0200 In-Reply-To: References: <20230411081141.1762395-1-ying.huang@oss.cipunited.com> <20230411081141.1762395-3-ying.huang@oss.cipunited.com> <3a59ea20739cde776aad7945ca4cc09055e1db6f.camel@klomp.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 X-Spam-Status: No, score=-3032.8 required=5.0 tests=BAYES_00,BODY_8BITS,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,RCVD_IN_BARRACUDACENTRAL,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: Hi Ying, On Mon, 2023-07-24 at 16:35 +0800, Ying Huang wrote: > Hi Mark, >=20 > > > 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 > > > =C2=A0#include=20 >=20 > > > - > > > +#include=20 >=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. > >=20 > > > 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 > > > =C2=A0#include=20 >=20 > > > =C2=A0#include=20 >=20 > > > - > > > +#include=20 >=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 > > > - 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. */ > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0res =3D ""; > > Likewise for hooking reloc_type_name. > >=20 > 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? There are no other arches which use those hooks at the moment. But you should be able to simply define them as mips_reloc_type_xxx and then HOOK them in your mips.c init function. Cheers, Mark