public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [bfd patch] Regression for Linux vDSO in GDB
@ 2014-09-17 18:56 Jan Kratochvil
  2014-09-17 21:55 ` Alan Modra
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kratochvil @ 2014-09-17 18:56 UTC (permalink / raw)
  To: binutils
  Cc: Pedro Alves, Mark Wielaard, Cary Coutant, Doug Evans, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 2598 bytes --]

Hi,

since
	5979d6b69b20a8355ea94b75fad97415fce4788c
	https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=5979d6b69b20a8355ea94b75fad97415fce4788c
	vdso handling
	https://sourceware.org/ml/binutils/2014-03/msg00082.html
	https://sourceware.org/ml/binutils/2014-04/msg00003.html
	Message-ID: <A78C989F6D9628469189715575E55B230AA884EB@IRSMSX104.ger.corp.intel.com>
I get on
	kernel-3.16.2-200.fc20.x86_64
	https://koji.fedoraproject.org/koji/buildinfo?buildID=575860
	attaching its vdso.bin.gz
GDB (FSF HEAD 5e43d46791c4c66fd83947a12d4f716b561a9103) regression:
reproducer for Fedora systems (as Fedora glibc is patched):
	./gdb -ex r --args $PWD/../../glibc-root/lib/ld-linux-x86-64.so.2 --library-path $PWD/../../glibc-root/lib:/lib64 ./gdb
assuming an untested reproducer for more upstream glibc (Debian?); not tested:
	./gdb -ex start ./gdb
actual result / FAIL:
	Got object file from memory but can't read symbols: File truncated.
expected result / PASS:
	warning: Could not load shared library symbols for linux-vdso.so.1.
	Do you need "set solib-search-path" or "set sysroot"?

That "warning: Could not load shared library..." is mostly harmless (it is
a bug in GDB), in the FAIL case it is not printed just because
bfd_check_format() fails there.

I do not fully understand the original intention for the line I changed there
but it seems logical to me this way when the 'size' parameter has been already
added.

I do not see a regression for add-symbol-file-from-memory for libncurses.so.5
from the original thread above.

  Start of section headers:          1080 (bytes into file)
  Size of section headers:           64 (bytes)
  Number of section headers:         13
  Section header string table index: 8
Section Headers:
  [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
  [ 8] .fake_shstrtab    STRTAB          0000000000000780 000780 000076 00   A  0   0 32
Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
  LOAD           0x000000 0x0000000000000000 0x0000000000000000 0x0012fe 0x0012fe R E 0x1000

size == 0x2000
shdr_end == 0x778 == 1080 + 13 * 64
high_offset == 0x12fe

       else if (size >= shdr_end)
-       high_offset = shdr_end;
+	high_offset = size;

But then 0x778 < 0x780 for "Section header string table index" so whole
bfd_check_format() fails because section headers were not cleared here:
  /* If the segments visible in memory didn't include the section headers,
     then clear them from the file header.  */
  if (high_offset < shdr_end)


Thanks,
Jan

[-- Attachment #2: kernel-3.16.2-200.fc20.x86_64-vdso.patch --]
[-- Type: text/plain, Size: 490 bytes --]

bfd/
2014-09-17  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* elfcode.h (bfd_from_remote_memory): Use SIZE for HIGH_OFFSET.

diff --git a/bfd/elfcode.h b/bfd/elfcode.h
index a49a708..ec53c3b 100644
--- a/bfd/elfcode.h
+++ b/bfd/elfcode.h
@@ -1749,7 +1749,7 @@ NAME(_bfd_elf,bfd_from_remote_memory)
 	     headers.  */
 	}
       else if (size >= shdr_end)
-	high_offset = shdr_end;
+	high_offset = size;
       else
 	{
 	  bfd_vma page_size = get_elf_backend_data (templ)->minpagesize;

[-- Attachment #3: kernel-3.16.2-200.fc20.x86_64-vdso.bin.gz --]
[-- Type: application/gzip, Size: 2252 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [bfd patch] Regression for Linux vDSO in GDB
  2014-09-17 18:56 [bfd patch] Regression for Linux vDSO in GDB Jan Kratochvil
@ 2014-09-17 21:55 ` Alan Modra
  2014-09-18  6:30   ` [bfd commit+gdb-7.8] " Jan Kratochvil
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Modra @ 2014-09-17 21:55 UTC (permalink / raw)
  To: Jan Kratochvil
  Cc: binutils, Pedro Alves, Mark Wielaard, Cary Coutant, Doug Evans,
	gdb-patches

On Wed, Sep 17, 2014 at 08:55:55PM +0200, Jan Kratochvil wrote:
> I do not fully understand the original intention for the line I changed there
> but it seems logical to me this way when the 'size' parameter has been already
> added.

You're correct.  I was wrongly thinking that the section headers were
always last when I wrote that code.  (They are now!  If you relink
that vdso with current binutils master you won't hit this problem, but
that of course doesn't help existing kernels.)  So..

> 	* elfcode.h (bfd_from_remote_memory): Use SIZE for HIGH_OFFSET.

..OK, thanks!

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [bfd commit+gdb-7.8] [bfd patch] Regression for Linux vDSO in GDB
  2014-09-17 21:55 ` Alan Modra
@ 2014-09-18  6:30   ` Jan Kratochvil
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Kratochvil @ 2014-09-18  6:30 UTC (permalink / raw)
  To: binutils
  Cc: Pedro Alves, Mark Wielaard, Cary Coutant, Doug Evans, gdb-patches

On Wed, 17 Sep 2014 23:55:15 +0200, Alan Modra wrote:
> > 	* elfcode.h (bfd_from_remote_memory): Use SIZE for HIGH_OFFSET.
> 
> ..OK, thanks!

Checked in:
	92c9bcd479e4cb388a7f286fc42414b115cfc656
and in gdb-7.8-branch:
	54fbc750b54271efb75ae11ce49f14c4234a9476


Thanks,
Jan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-09-18  6:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-17 18:56 [bfd patch] Regression for Linux vDSO in GDB Jan Kratochvil
2014-09-17 21:55 ` Alan Modra
2014-09-18  6:30   ` [bfd commit+gdb-7.8] " Jan Kratochvil

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).