public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Alan Modra <amodra@gmail.com>, binutils@sourceware.org
Subject: Re: Renaming .debug to .zdebug and vice versa
Date: Sun, 4 Dec 2022 20:56:20 -0500	[thread overview]
Message-ID: <60f6a5ed-5ef5-1123-6b4a-8836b150a4bf@polymtl.ca> (raw)
In-Reply-To: <Y40WXnjN0f0LjrIt@squeak.grove.modra.org>



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

  reply	other threads:[~2022-12-05  1:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-04 21:51 Alan Modra
2022-12-05  1:56 ` Simon Marchi [this message]
2022-12-05  4:47   ` Alan Modra
2022-12-05  2:36 ` Jiang, Haochen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=60f6a5ed-5ef5-1123-6b4a-8836b150a4bf@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).