This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: mips .bss lma broken
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Catherine Moore <clm at redhat dot com>
- Cc: rearnsha at arm dot com, binutils at sources dot redhat dot com, hunt at cygnus dot com, clm at cygnus dot com
- Date: Sat, 23 Mar 2002 23:42:04 +1030
- Subject: Re: mips .bss lma broken
- References: <200203221525.HAA00417@cygnus.com>
On Fri, Mar 22, 2002 at 07:25:35AM -0800, Catherine Moore wrote:
>
> In particular, the lma for the bss section should be the same value as
> the vma. In this example, it is not, and gdb relies on a correct lma
> for this particular port.
>
> 10 .sbss 00000010 0001b090 0001b090 0000c090 2**3
> ALLOC
> 11 .bss 000001d0 0001b0a0 0001b090 0000c090 2**4
> ALLOC
Yeah, calculating based on file offset doesn't make much sense for
sections that don't take up file space. This should fix it.
* elf.c (_bfd_elf_make_section_from_shdr): Don't set lma based on
section file offset for !SEC_LOAD sections.
--
Alan Modra
IBM OzLabs - Linux Technology Centre
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.131
diff -u -p -r1.131 elf.c
--- elf.c 2002/03/04 20:41:55 1.131
+++ elf.c 2002/03/23 12:59:10
@@ -655,9 +655,9 @@ _bfd_elf_make_section_from_shdr (abfd, h
Note - we used to check the p_paddr field as well, and
refuse to set the LMA if it was 0. This is wrong
- though as a perfectly valid, initialised segment can
+ though, as a perfectly valid initialised segment can
have a p_paddr of zero. Some architectures, eg ARM,
- place special significance one the address 0 and
+ place special significance on the address 0 and
executables need to be able to have a segment which
covers this address. */
if (phdr->p_type == PT_LOAD
@@ -668,15 +668,18 @@ _bfd_elf_make_section_from_shdr (abfd, h
|| (phdr->p_offset + phdr->p_filesz
>= hdr->sh_offset + hdr->sh_size)))
{
- /* We used to do a relative adjustment here, but
- that doesn't work if the segment is packed with
- code from multiple VMAs. Instead we calculate
- the LMA absoultely, based on the LMA of the
- segment (it is assumed that the segment will
- contain sections with contiguous LMAs, even if
- the VMAs are not). */
- newsect->lma = phdr->p_paddr
- + hdr->sh_offset - phdr->p_offset;
+ if ((flags & SEC_LOAD) == 0)
+ newsect->lma += phdr->p_paddr - phdr->p_vaddr;
+ else
+ /* We used to use the same adjustment for SEC_LOAD
+ sections, but that doesn't work if the segment
+ is packed with code from multiple VMAs.
+ Instead we calculate the section LMA based on
+ the segment LMA. It is assumed that the
+ segment will contain sections with contiguous
+ LMAs, even if the VMAs are not. */
+ newsect->lma = (phdr->p_paddr
+ + hdr->sh_offset - phdr->p_offset);
break;
}
}