From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] Fix gdb build on 32-bit hosts w/ --enable-64-bit-bfd
Date: Tue, 04 Dec 2018 18:16:00 -0000 [thread overview]
Message-ID: <20181204181650.18188-1-palves@redhat.com> (raw)
Building for x86_64/-m32 with --enable-64-bit-bfd, compilation fails
with:
src/gdb/dwarf2read.c: In instantiation of âgdb::array_view<const unsigned char> get_gdb_index_contents_from_section(objfile*, T*) [with T = dwarf2_per_objfile]â:
src/gdb/dwarf2read.c:6266:54: required from here
src/gdb/dwarf2read.c:6192:37: error: narrowing conversion of âsection->dwarf2_section_info::sizeâ from âbfd_size_type {aka long long unsigned int}â to âsize_t {aka unsigned int}â inside { } [-Werror=narrowing]
return {section->buffer, section->size};
~~~~~~~~~^~~~
This fixes it.
gdb/ChangeLog:
2018-12-04 Pedro Alves <palves@redhat.com>
* dwarf2read.c (get_gdb_index_contents_from_section): Use
gdb::make_array_view.
---
gdb/dwarf2read.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 8bfbd693940..30bc101f11c 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -6189,7 +6189,13 @@ get_gdb_index_contents_from_section (objfile *obj, T *section_owner)
dwarf2_read_section (obj, section);
- return {section->buffer, section->size};
+ /* dwarf2_section_info::size is a bfd_size_type, while
+ gdb::array_view works with size_t. On 32-bit hosts, with
+ --enable-64-bit-bfd, bfd_size_type is a 64-bit type, while size_t
+ is 32-bit. So we need an explicit narrowing conversion here.
+ This is fine, because it's impossible to allocate or mmap an
+ array/buffer larger than what size_t can represent. */
+ return gdb::make_array_view (section->buffer, section->size);
}
/* Lookup the index cache for the contents of the index associated to
--
2.14.4
next reply other threads:[~2018-12-04 18:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-04 18:16 Pedro Alves [this message]
2018-12-04 18:59 ` Simon Marchi
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=20181204181650.18188-1-palves@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@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