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 A61063858D20 for ; Sun, 21 May 2023 21:13:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A61063858D20 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: by gnu.wildebeest.org (Postfix, from userid 1000) id 7191C30343BD; Sun, 21 May 2023 23:13:02 +0200 (CEST) Date: Sun, 21 May 2023 23:13:02 +0200 From: Mark Wielaard To: Ying Huang Cc: elfutils-devel@sourceware.org, yunqiang.su@oss.cipunited.com Subject: Re: [PATCH 1/5] strip: Adapt src/strip -o -f on mips Message-ID: <20230521211302.GH3420@gnu.wildebeest.org> References: <20230411081141.1762395-1-ying.huang@oss.cipunited.com> <20230411081141.1762395-2-ying.huang@oss.cipunited.com> <9035496c-3414-ac66-bd86-281592aa2a77@oss.cipunited.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9035496c-3414-ac66-bd86-281592aa2a77@oss.cipunited.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-3030.0 required=5.0 tests=BAYES_00,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no 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 Tue, May 16, 2023 at 02:38:45PM +0800, Ying Huang wrote: > 在 2023/5/9 23:15, Mark Wielaard 写道: > > On Tue, 2023-04-11 at 16:12 +0800, Ying Huang wrote: > >> In mips64 little-endian, r_info consists of four byte fields(contains > >> three reloc types) and a 32-bit symbol index. In order to adapt > >> GELF_R_SYM and GELF_R_TYPE, need convert raw data to get correct symbol > >> index and type. > > Is there a spec that describes this? >     > > references: > >     https://www.linux-mips.org/pub/linux/mips/doc/ABI/elf64-2.4.pdf > >     Page40 && Page41 Thanks. Interesting. If possible please include this URL in a comment. > > I see you adjusted elf.h to include: > > > > +#define ELF64_MIPS_R_TYPE(i) ((i) & 0xff) > > +#define ELF64_MIPS_R_TYPE2(i) (((i) >> 8) & 0xff) > > +#define ELF64_MIPS_R_TYPE3(i) (((i) >> 16) & 0xff) > > > > And various new relocation types for MIPS variants. > > Our elf.h comes from the glibc project. Have you also submitted these > > changes to libc-alpha@sourceware.org ? >     Has submitted. > >     https://sourceware.org/pipermail/libc-alpha/2023-May/148026.html > >     https://sourceware.org/pipermail/libc-alpha/2023-May/148112.html Thanks. We'll sync them as soon as v3 lands. >     Has tested on big/little endian machine with big/little endian > ELF file, all were OK. Could you post those ELF files somewhere? Maybe we can add some as test files? > > It feels like this is in the wrong place and doesn't take into account > > whether the program itself is running on a big or little endian > > machine. > > > > Maybe I am misunderstanding why this conversion is needed always. But I > > would have expected a specific conversion function for MIPS for > > ELF_T_REL and/or ELF_T_RELA (which are currently generic). > >     1.Considering that some people directly use the original data instead of the interface function gelf_getrela; > >     2.Because there is only one parameter, so can not modify the macro ELF64_R_TYPE; > >     3.If the mips interface function is added, other packages using libelf will not be compatible with mips, and the place where gelf_getrela is used need be modified. > >     Where do you think is the most suitable place to do mips conversion? So for the convert_data case in elf_getdata.c I would expect a special conversion function being defined for ELF_T_REL and ELF_T_RELA. This normally comes from __elf_xfctstom. I realize now that cannot easily take an Elf of machine type. But I would expect to have the conversion be done by a new function that can be assigned to fp in convert_data: /* Get the conversion function. */ fp = __elf_xfctstom[eclass - 1][type]; I still don't fully understand the need of the code in elf_update. I assume that is needed in case the file was used with ELF_C_RDWR_MMAP? Cheers, Mark