public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PPC ld test failure
@ 2002-04-02  3:51 Andreas Jaeger
  2002-04-02 23:59 ` Alan Modra
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Jaeger @ 2002-04-02  3:51 UTC (permalink / raw)
  To: binutils


The vers14 test from ld fails for me on powerpc with HJ's latest
binutils release with:
/usr/src/packages/BUILD/binutils-2.12.90.0.3/build-dir/ld/../binutils/strip-new tmpdir/vers14.so
BFD: tmpdir/stJdPpsP: warning: allocated section `.data' not in segment

This looks broken to me, readelf on the file shows that .data is empty
but is in the segment:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .hash             HASH            00000094 000094 0000d4 04   A  2   0  4
  [ 2] .dynsym           DYNSYM          00000168 000168 000220 10   A  3  11  4
  [ 3] .dynstr           STRTAB          00000388 000388 000094 00   A  0   0  1
  [ 4] .gnu.version      VERSYM          0000041c 00041c 000044 02   A  2   0  2
  [ 5] .gnu.version_d    VERDEF          00000460 000460 000080 00   A  3   4  4
  [ 6] .rela.dyn         RELA            000004e0 0004e0 000048 0c   A  2   0  4
  [ 7] .text             PROGBITS        00000528 000528 000098 00  AX  0   0  4
  [ 8] .rodata           PROGBITS        000005c0 0005c0 000008 00   A  0   0  4
  [ 9] .data             PROGBITS        000105c8 0005c8 000000 00  WA  0   0  1
  [10] .dynamic          DYNAMIC         000105c8 0005c8 000090 08  WA  3   0  4
  [11] .got              PROGBITS        00010658 000658 000010 04  WA  0   0  4
  [12] .sdata2           PROGBITS        00010668 000668 000000 00   A  0   0  4
  [13] .sdata            PROGBITS        00010668 000668 000008 00  WA  0   0  4
  [14] .sbss             NOBITS          00010670 000670 000000 00  WA  0   0  1
  [15] .bss              NOBITS          00010670 000670 000000 00  WA  0   0  1
  [16] .comment          PROGBITS        00000000 000670 000046 00      0   0  1
  [17] .shstrtab         STRTAB          00000000 0006b6 00009c 00      0   0  1
  [18] .symtab           SYMTAB          00000000 000a74 0002b0 10     19  1a  4
  [19] .strtab           STRTAB          00000000 000d24 000114 00      0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x000000 0x00000000 0x00000000 0x005c8 0x005c8 R E 0x10000
  LOAD           0x0005c8 0x000105c8 0x000105c8 0x000a8 0x000a8 RW  0x10000
  DYNAMIC        0x0005c8 0x000105c8 0x000105c8 0x00090 0x00090 RW  0x4

Any ideas?

Andreas
-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de
    http://www.suse.de/~aj

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

* Re: PPC ld test failure
  2002-04-02  3:51 PPC ld test failure Andreas Jaeger
@ 2002-04-02 23:59 ` Alan Modra
  2002-04-03  5:25   ` Alan Modra
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Modra @ 2002-04-02 23:59 UTC (permalink / raw)
  To: Andreas Jaeger; +Cc: binutils

On Tue, Apr 02, 2002 at 01:51:42PM +0200, Andreas Jaeger wrote:
> 
> The vers14 test from ld fails for me on powerpc with HJ's latest
> binutils release with:
> /usr/src/packages/BUILD/binutils-2.12.90.0.3/build-dir/ld/../binutils/strip-new tmpdir/vers14.so
> BFD: tmpdir/stJdPpsP: warning: allocated section `.data' not in segment
> 
> Any ideas?

Broken by

2002-03-23  Alan Modra  <amodra@bigpond.net.au>

	* elf.c (_bfd_elf_make_section_from_shdr): Don't set lma based on
	section file offset for !SEC_LOAD sections.

It's not that the above patch is wrong, but rather that the test for
whether a section is included in a segment:

	      if (phdr->p_type == PT_LOAD
		  && (bfd_vma) hdr->sh_offset >= phdr->p_offset
		  && (hdr->sh_offset + hdr->sh_size
		      <= phdr->p_offset + phdr->p_memsz)
		  && ((flags & SEC_LOAD) == 0
		      || (phdr->p_offset + phdr->p_filesz
			  >= hdr->sh_offset + hdr->sh_size)))

is broken.

(gdb) p phdr[0]
$1 = {p_type = 1, p_flags = 5, p_offset = 0, p_vaddr = 0, p_paddr = 0, 
  p_filesz = 1848, p_memsz = 1848, p_align = 65536}
(gdb) p phdr[1]
$2 = {p_type = 1, p_flags = 6, p_offset = 1848, p_vaddr = 67384, 
  p_paddr = 67384, p_filesz = 168, p_memsz = 168, p_align = 65536}
(gdb) p *hdr
$3 = {sh_name = 108, sh_type = 1, sh_flags = 3, sh_addr = 67384, sh_size = 0, 
  sh_entsize = 0, sh_link = 0, sh_info = 0, sh_offset = 1848, 
  sh_addralign = 1, bfd_section = 0x0, contents = 0x0}

This hdr ought to be part of the second segment, but we decide that it's
part of the first.  I think we need a test of hdr->sh_addr against
phdr->p_paddr.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

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

* Re: PPC ld test failure
  2002-04-02 23:59 ` Alan Modra
@ 2002-04-03  5:25   ` Alan Modra
  0 siblings, 0 replies; 3+ messages in thread
From: Alan Modra @ 2002-04-03  5:25 UTC (permalink / raw)
  To: binutils

Hmm, Richard Earnshaw's 2001-10-30 change removed the p_vaddr tests
in order to support non-contiguous VMAs.

	* elf.c (_bfd_elf_make_section_from_shdr): When setting section
	LMAs, loop over segments until p_vaddr and p_memsz specify an
	extent enclosing the section.

Note that newsect->lma = hdr->sh_addr courtesy of bfd_set_section_vma,
so the first hunk isn't really changing anything.

Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.134
diff -u -p -r1.134 elf.c
--- elf.c	2002/04/01 18:31:46	1.134
+++ elf.c	2002/04/03 13:04:30
@@ -665,11 +665,12 @@ _bfd_elf_make_section_from_shdr (abfd, h
 		  && (hdr->sh_offset + hdr->sh_size
 		      <= phdr->p_offset + phdr->p_memsz)
 		  && ((flags & SEC_LOAD) == 0
-		      || (phdr->p_offset + phdr->p_filesz
-			  >= hdr->sh_offset + hdr->sh_size)))
+		      || (hdr->sh_offset + hdr->sh_size
+			  <= phdr->p_offset + phdr->p_filesz)))
 		{
 		  if ((flags & SEC_LOAD) == 0)
-		    newsect->lma += phdr->p_paddr - phdr->p_vaddr;
+		    newsect->lma = (phdr->p_paddr
+				    + hdr->sh_addr - phdr->p_vaddr);
 		  else
 		    /* We used to use the same adjustment for SEC_LOAD
 		       sections, but that doesn't work if the segment
@@ -680,7 +681,15 @@ _bfd_elf_make_section_from_shdr (abfd, h
 		       LMAs, even if the VMAs are not.  */
 		    newsect->lma = (phdr->p_paddr
 				    + hdr->sh_offset - phdr->p_offset);
-		  break;
+
+		  /* With contiguous segments, we can't tell from file
+		     offsets whether a section with zero size should
+		     be placed at the end of one segment or the
+		     beginning of the next.  Decide based on vaddr.  */
+		  if (hdr->sh_addr >= phdr->p_vaddr
+		      && (hdr->sh_addr + hdr->sh_size
+			  <= phdr->p_vaddr + phdr->p_memsz))
+		    break;
 		}
 	    }
 	}

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

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

end of thread, other threads:[~2002-04-03 13:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-02  3:51 PPC ld test failure Andreas Jaeger
2002-04-02 23:59 ` Alan Modra
2002-04-03  5:25   ` Alan Modra

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