From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id C7BC1382FAD8 for ; Mon, 5 Dec 2022 01:56:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C7BC1382FAD8 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 2B51uLuK018677 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 4 Dec 2022 20:56:26 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 2B51uLuK018677 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=default; t=1670205386; bh=VOrPp3OmJMOx2byiQt7ZigLGyWTe1r1c8W5hb7LXayg=; h=Date:Subject:To:References:From:In-Reply-To:From; b=XKHCqh5HKO/3zR3CrUPzJe528PGiigduI9Vk9FDIVMn4lJlGdVvzbpsr72HDYEhkM t+QI7i2+VdUMLg9N/Sca7dEX7IBLtb8JaomWDCyUIcWgxvvnjhF3aA3XC8WTk8mQOU BEqGp+k+TZ8a3OaukzA37KKDVJPfcFuDdSJmbJow= Received: from [10.0.0.11] (unknown [217.28.27.60]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 9C9991E0CB; Sun, 4 Dec 2022 20:56:21 -0500 (EST) Message-ID: <60f6a5ed-5ef5-1123-6b4a-8836b150a4bf@polymtl.ca> Date: Sun, 4 Dec 2022 20:56:20 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: Renaming .debug to .zdebug and vice versa Content-Language: en-US To: Alan Modra , binutils@sourceware.org References: From: Simon Marchi In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Mon, 5 Dec 2022 01:56:21 +0000 X-Spam-Status: No, score=-3038.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,TXREP 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: On 12/4/22 16:51, Alan Modra wrote: > Move a couple of elf.c functions to compress.c. > > * compress.c (bfd_debug_name_to_zdebug): New inline function. > (bfd_zdebug_name_to_debug): Likewise. > * elf.c (convert_debug_to_zdebug, convert_zdebug_to_debug): Delete. > (_bfd_elf_make_section_from_shdr, elf_fake_sections), > (_bfd_elf_assign_file_positions_for_non_load): Adjust to suit. > * coffgen.c (make_a_section_from_file): Use new inlines here. > > diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h > index 0b071dda1e5..48451175364 100644 > --- a/bfd/bfd-in2.h > +++ b/bfd/bfd-in2.h > @@ -7963,6 +7963,31 @@ bfd_byte *bfd_simple_get_relocated_section_contents > (bfd *abfd, asection *sec, bfd_byte *outbuf, asymbol **symbol_table); > > /* Extracted from compress.c. */ > +static inline char * > +bfd_debug_name_to_zdebug (bfd *abfd, const char *name) > +{ > + size_t len = strlen (name); > + char *new_name = bfd_alloc (abfd, len + 2); > + if (new_name == NULL) > + return NULL; > + new_name[0] = '.'; > + new_name[1] = 'z'; > + memcpy (new_name + 2, name + 1, len); > + return new_name; > +} > + > +static inline char * > +bfd_zdebug_name_to_debug (bfd *abfd, const char *name) > +{ > + size_t len = strlen (name); > + char *new_name = bfd_alloc (abfd, len); > + if (new_name == NULL) > + return NULL; > + new_name[0] = '.'; > + memcpy (new_name + 1, name + 2, len - 1); > + return new_name; > +} Hi Alan, This breaks GDB. We need to cast the bfd_alloc return value so that it compiles as C++. CXX gdb.o In file included from /home/simark/src/binutils-gdb/gdb/defs.h:37, from /home/simark/src/binutils-gdb/gdb/gdb.c:19: ../bfd/bfd.h: In function ‘char* bfd_debug_name_to_zdebug(bfd*, const char*)’: ../bfd/bfd.h:7970:30: error: invalid conversion from ‘void*’ to ‘char*’ [-fpermissive] 7970 | char *new_name = bfd_alloc (abfd, len + 2); | ~~~~~~~~~~^~~~~~~~~~~~~~~ | | | void* Simon