public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/14704] New: GDB fails to decompress relocatable files
@ 2012-10-11 19:09 hjl.tools at gmail dot com
2012-10-11 23:12 ` [Bug gdb/14704] " dje at google dot com
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: hjl.tools at gmail dot com @ 2012-10-11 19:09 UTC (permalink / raw)
To: gdb-prs
http://sourceware.org/bugzilla/show_bug.cgi?id=14704
Bug #: 14704
Summary: GDB fails to decompress relocatable files
Product: gdb
Version: unknown
Status: NEW
Severity: normal
Priority: P2
Component: gdb
AssignedTo: unassigned@sourceware.org
ReportedBy: hjl.tools@gmail.com
Classification: Unclassified
[hjl@gnu-tools-1 tmp]$ cat x.c
void bar ();
int
main ()
{
bar ();
return 0;
}
[hjl@gnu-tools-1 tmp]$ gcc -g x.c -c
[hjl@gnu-tools-1 tmp]$ objcopy --compress-debug-sections x.o
[hjl@gnu-tools-1 tmp]$ gdb --batch x.o
Dwarf Error: wrong version in compilation unit header (is 0, should be 2, 3, or
4) [in module /tmp/x.o]
[hjl@gnu-tools-1 tmp]$ objcopy --decompress-debug-sections x.o
[hjl@gnu-tools-1 tmp]$ gdb --batch x.o
[hjl@gnu-tools-1 tmp]$
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug gdb/14704] GDB fails to decompress relocatable files
2012-10-11 19:09 [Bug gdb/14704] New: GDB fails to decompress relocatable files hjl.tools at gmail dot com
@ 2012-10-11 23:12 ` dje at google dot com
2012-10-15 17:45 ` tromey at redhat dot com
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: dje at google dot com @ 2012-10-11 23:12 UTC (permalink / raw)
To: gdb-prs
http://sourceware.org/bugzilla/show_bug.cgi?id=14704
dje at google dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dje at google dot com,
| |tromey at redhat dot com
--- Comment #1 from dje at google dot com 2012-10-11 23:12:39 UTC ---
Filing this here for reference sake, having just tripped over this myself in a
different (non .o) context.
In 7.5 the check for whether a section is compressed appears before the check
for whether a section has relocs. In cvs head the tests are (effectively)
reversed.
The change came in here:
2012-07-18 Tom Tromey <tromey@redhat.com>
* dwarf2read.c: Don't include zlib.h or sys/mman.h.
(pagesize): Remove.
(struct dwarf2_section_info) <map_addr, map_len>: Remove.
(zlib_decompress_section): Remove.
(dwarf2_read_section): Use gdb_bfd_map_section.
(munmap_section_buffer): Remove.
(free_dwo_file, dwarf2_per_objfile_free): Don't use
munmap_section_buffer.
* gdb_bfd.c: Include zlib.h, sys/mman.h.
(struct gdb_bfd_section_data): New.
(free_one_bfd_section): New function.
(gdb_bfd_close_or_warn): Use free_one_bfd_section.
(get_section_descriptor, zlib_decompress_section)
(gdb_bfd_map_section): New functions.
* gdb_bfd.h (gdb_bfd_map_section): Declare.
Also, I think there's a separate issue here, which is: Why does bfd attach
SEC_RELOC to a section if its .rela section is empty?
Seems like we want this, but of course I can't discount the possibility of some
obscure reason why things are the way they are:
--- elf.c= 2012-10-11 15:55:02.722802893 -0700
+++ elf.c 2012-10-11 15:55:02.722802893 -0700
@@ -1873,18 +1873,20 @@
*hdr2 = *hdr;
*p_hdr = hdr2;
elf_elfsections (abfd)[shindex] = hdr2;
- target_sect->reloc_count += NUM_SHDR_ENTRIES (hdr);
- target_sect->flags |= SEC_RELOC;
- target_sect->relocation = NULL;
- target_sect->rel_filepos = hdr->sh_offset;
- /* In the section to which the relocations apply, mark whether
- its relocations are of the REL or RELA variety. */
+ /* Don't mark the target section as having relocs if this
+ section is empty. */
if (hdr->sh_size != 0)
{
+ target_sect->reloc_count += NUM_SHDR_ENTRIES (hdr);
+ target_sect->flags |= SEC_RELOC;
+ target_sect->relocation = NULL;
+ target_sect->rel_filepos = hdr->sh_offset;
+ /* In the section to which the relocations apply, mark whether
+ its relocations are of the REL or RELA variety. */
if (hdr->sh_type == SHT_RELA)
target_sect->use_rela_p = 1;
+ abfd->flags |= HAS_RELOC;
}
- abfd->flags |= HAS_RELOC;
return TRUE;
}
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug gdb/14704] GDB fails to decompress relocatable files
2012-10-11 19:09 [Bug gdb/14704] New: GDB fails to decompress relocatable files hjl.tools at gmail dot com
2012-10-11 23:12 ` [Bug gdb/14704] " dje at google dot com
@ 2012-10-15 17:45 ` tromey at redhat dot com
2012-10-15 18:15 ` tromey at redhat dot com
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: tromey at redhat dot com @ 2012-10-15 17:45 UTC (permalink / raw)
To: gdb-prs
http://sourceware.org/bugzilla/show_bug.cgi?id=14704
--- Comment #2 from Tom Tromey <tromey at redhat dot com> 2012-10-15 17:45:15 UTC ---
FWIW, 7.5 decompressed the section but didn't actually apply relocations.
That seems wrong.
There are comments in dwarf2read (now in gdb_bfd.c) dating back to 2008
about this:
1.255 (csilvers 19-Apr-08): /* When debugging .o files, we may need to
apply relocations; see
1.255 (csilvers 19-Apr-08):
http://sourceware.org/ml/gdb-patches/2002-04/msg00136.html .
1.255 (csilvers 19-Apr-08): We never compress sections in .o files,
so we only need to
1.255 (csilvers 19-Apr-08): try this when the section is not
compressed. */
I assume that what should happen instead is that the section be decompressed,
then relocations applied.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug gdb/14704] GDB fails to decompress relocatable files
2012-10-11 19:09 [Bug gdb/14704] New: GDB fails to decompress relocatable files hjl.tools at gmail dot com
2012-10-11 23:12 ` [Bug gdb/14704] " dje at google dot com
2012-10-15 17:45 ` tromey at redhat dot com
@ 2012-10-15 18:15 ` tromey at redhat dot com
2012-10-15 20:45 ` hjl.tools at gmail dot com
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: tromey at redhat dot com @ 2012-10-15 18:15 UTC (permalink / raw)
To: gdb-prs
http://sourceware.org/bugzilla/show_bug.cgi?id=14704
--- Comment #3 from Tom Tromey <tromey at redhat dot com> 2012-10-15 18:15:37 UTC ---
We arrive in bfd_get_full_section_contents with
sec->compress_status == COMPRESS_SECTION_NONE.
This is because BFD_DECOMPRESS is not set when calling
_bfd_elf_make_section_from_shdr.
Maybe having gdb set BFD_DECOMPRESS is the right thing to do.
It is not clear to me; BFD says that this is "for BFD use only",
but then I see uses of it in ld and binutils.
If this is the correct approach we could easily set the flag
in the various wrapper functions in gdb_bfd.c.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug gdb/14704] GDB fails to decompress relocatable files
2012-10-11 19:09 [Bug gdb/14704] New: GDB fails to decompress relocatable files hjl.tools at gmail dot com
` (2 preceding siblings ...)
2012-10-15 18:15 ` tromey at redhat dot com
@ 2012-10-15 20:45 ` hjl.tools at gmail dot com
2012-10-15 20:49 ` hjl.tools at gmail dot com
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: hjl.tools at gmail dot com @ 2012-10-15 20:45 UTC (permalink / raw)
To: gdb-prs
http://sourceware.org/bugzilla/show_bug.cgi?id=14704
--- Comment #4 from H.J. Lu <hjl.tools at gmail dot com> 2012-10-15 20:45:31 UTC ---
(In reply to comment #3)
> We arrive in bfd_get_full_section_contents with
> sec->compress_status == COMPRESS_SECTION_NONE.
> This is because BFD_DECOMPRESS is not set when calling
> _bfd_elf_make_section_from_shdr.
>
> Maybe having gdb set BFD_DECOMPRESS is the right thing to do.
> It is not clear to me; BFD says that this is "for BFD use only",
> but then I see uses of it in ld and binutils.
>
> If this is the correct approach we could easily set the flag
> in the various wrapper functions in gdb_bfd.c.
Yes, it is the right thing to do.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug gdb/14704] GDB fails to decompress relocatable files
2012-10-11 19:09 [Bug gdb/14704] New: GDB fails to decompress relocatable files hjl.tools at gmail dot com
` (3 preceding siblings ...)
2012-10-15 20:45 ` hjl.tools at gmail dot com
@ 2012-10-15 20:49 ` hjl.tools at gmail dot com
2012-10-16 18:06 ` tromey at redhat dot com
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: hjl.tools at gmail dot com @ 2012-10-15 20:49 UTC (permalink / raw)
To: gdb-prs
http://sourceware.org/bugzilla/show_bug.cgi?id=14704
--- Comment #5 from H.J. Lu <hjl.tools at gmail dot com> 2012-10-15 20:49:47 UTC ---
(In reply to comment #3)
>
> Maybe having gdb set BFD_DECOMPRESS is the right thing to do.
> It is not clear to me; BFD says that this is "for BFD use only",
> but then I see uses of it in ld and binutils.
>
It means BFD_DECOMPRESS is used by BFD, not used to describe
the input file:
binutils/objdump.c: printf (_("flags 0x%08x:\n"), abfd->flags &
~BFD_FLAGS_FOR_BFD_USE_MASK);
We don't want to display those bits in objdump.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug gdb/14704] GDB fails to decompress relocatable files
2012-10-11 19:09 [Bug gdb/14704] New: GDB fails to decompress relocatable files hjl.tools at gmail dot com
` (4 preceding siblings ...)
2012-10-15 20:49 ` hjl.tools at gmail dot com
@ 2012-10-16 18:06 ` tromey at redhat dot com
2012-10-16 18:17 ` tromey at redhat dot com
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: tromey at redhat dot com @ 2012-10-16 18:06 UTC (permalink / raw)
To: gdb-prs
http://sourceware.org/bugzilla/show_bug.cgi?id=14704
--- Comment #6 from Tom Tromey <tromey at redhat dot com> 2012-10-16 18:06:18 UTC ---
While trying a cleanup here I found out that
bfd_is_section_compressed does not work if
BFD_DECOMPRESS is set. This is because bfd_get_section_contents
fails for compressed sections.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug gdb/14704] GDB fails to decompress relocatable files
2012-10-11 19:09 [Bug gdb/14704] New: GDB fails to decompress relocatable files hjl.tools at gmail dot com
` (5 preceding siblings ...)
2012-10-16 18:06 ` tromey at redhat dot com
@ 2012-10-16 18:17 ` tromey at redhat dot com
2012-11-08 19:52 ` cvs-commit at gcc dot gnu.org
2012-11-08 19:53 ` tromey at redhat dot com
8 siblings, 0 replies; 10+ messages in thread
From: tromey at redhat dot com @ 2012-10-16 18:17 UTC (permalink / raw)
To: gdb-prs
http://sourceware.org/bugzilla/show_bug.cgi?id=14704
Tom Tromey <tromey at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at sourceware |tromey at redhat dot com
|dot org |
--- Comment #7 from Tom Tromey <tromey at redhat dot com> 2012-10-16 18:16:57 UTC ---
Testing a patch.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug gdb/14704] GDB fails to decompress relocatable files
2012-10-11 19:09 [Bug gdb/14704] New: GDB fails to decompress relocatable files hjl.tools at gmail dot com
` (6 preceding siblings ...)
2012-10-16 18:17 ` tromey at redhat dot com
@ 2012-11-08 19:52 ` cvs-commit at gcc dot gnu.org
2012-11-08 19:53 ` tromey at redhat dot com
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2012-11-08 19:52 UTC (permalink / raw)
To: gdb-prs
http://sourceware.org/bugzilla/show_bug.cgi?id=14704
--- Comment #8 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> 2012-11-08 19:52:47 UTC ---
CVSROOT: /cvs/src
Module name: src
Changes by: tromey@sourceware.org 2012-11-08 19:52:42
Modified files:
gdb : ChangeLog gdb_bfd.c osabi.c xcoffread.c
gdb/contrib : cc-with-tweaks.sh
gdb/python : py-auto-load.c
gdb/testsuite : ChangeLog
Added files:
gdb/testsuite/gdb.base: comprdebug.exp
Log message:
PR gdb/14704:
* gdb_bfd.c (gdb_bfd_ref): Set BFD_DECOMPRESS.
(zlib_decompress_section): Remove.
(gdb_bfd_map_section): Only check for compressed section
in mmap case. Use bfd_get_full_section_contents.
* osabi.c (check_note): Add 'sectsize' argument. Read
section data.
(generic_elf_osabi_sniff_abi_tag_sections): Don't read
section data. Update for check_note change.
* xcoffread.c (xcoff_initial_scan): Use
bfd_get_full_section_contents.
* py-auto-load.c (auto_load_section_scripts): Use
bfd_get_full_section_contents.
* contrib/cc-with-tweaks.sh: Add -Z option.
testsuite
* gdb.base/comprdebug.exp: New file.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.14800&r2=1.14801
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/gdb_bfd.c.diff?cvsroot=src&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/osabi.c.diff?cvsroot=src&r1=1.58&r2=1.59
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/xcoffread.c.diff?cvsroot=src&r1=1.97&r2=1.98
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/contrib/cc-with-tweaks.sh.diff?cvsroot=src&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/python/py-auto-load.c.diff?cvsroot=src&r1=1.24&r2=1.25
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.3443&r2=1.3444
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.base/comprdebug.exp.diff?cvsroot=src&r1=NONE&r2=1.1
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug gdb/14704] GDB fails to decompress relocatable files
2012-10-11 19:09 [Bug gdb/14704] New: GDB fails to decompress relocatable files hjl.tools at gmail dot com
` (7 preceding siblings ...)
2012-11-08 19:52 ` cvs-commit at gcc dot gnu.org
@ 2012-11-08 19:53 ` tromey at redhat dot com
8 siblings, 0 replies; 10+ messages in thread
From: tromey at redhat dot com @ 2012-11-08 19:53 UTC (permalink / raw)
To: gdb-prs
http://sourceware.org/bugzilla/show_bug.cgi?id=14704
Tom Tromey <tromey at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Target Milestone|--- |7.6
--- Comment #9 from Tom Tromey <tromey at redhat dot com> 2012-11-08 19:53:40 UTC ---
Fixed.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2012-11-08 19:53 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-11 19:09 [Bug gdb/14704] New: GDB fails to decompress relocatable files hjl.tools at gmail dot com
2012-10-11 23:12 ` [Bug gdb/14704] " dje at google dot com
2012-10-15 17:45 ` tromey at redhat dot com
2012-10-15 18:15 ` tromey at redhat dot com
2012-10-15 20:45 ` hjl.tools at gmail dot com
2012-10-15 20:49 ` hjl.tools at gmail dot com
2012-10-16 18:06 ` tromey at redhat dot com
2012-10-16 18:17 ` tromey at redhat dot com
2012-11-08 19:52 ` cvs-commit at gcc dot gnu.org
2012-11-08 19:53 ` tromey at redhat dot com
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).