public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [Patch] Keep bfd section lma in sync with elf data structures
@ 2010-02-05 17:13 Sterling Augustine
  2010-02-05 17:40 ` H.J. Lu
  0 siblings, 1 reply; 2+ messages in thread
From: Sterling Augustine @ 2010-02-05 17:13 UTC (permalink / raw)
  To: binutils

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

I have committed the attached patch which updates the lma of a section 
inside the bfd data structure when it is changed inside the elf 
structure. The updated value is now printed in the map file, rather than 
the formerly stale value. This fixes bugzilla #11219.

Sterling

2010-02-05  Sterling Augustine  <sterling@tensilica.com>

         * elf.c (assign_file_positions_for_load_sections) Update lma of
         section if necessary.


[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 1059 bytes --]

Index: elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.500
diff -u -p -r1.500 elf.c
--- elf.c	4 Feb 2010 09:16:38 -0000	1.500
+++ elf.c	5 Feb 2010 17:02:01 -0000
@@ -4462,6 +4462,22 @@ assign_file_positions_for_load_sections 
 		}
 	      p->p_memsz += adjust;
 
+	      if (p->p_paddr + p->p_memsz != sec->lma)
+		{
+		  /* This behavior is a compromise--ld has long
+		     silently changed the lma of sections when
+		     lma - vma is not equal for every section in a
+		     pheader--but only in the internal elf structures.
+		     Silently changing the lma is probably a bug, but
+		     changing it would have subtle and unknown
+		     consequences for existing scripts.
+
+		     Instead modify the bfd data structure to reflect
+		     what happened.  This at least fixes the values
+		     for the lma in the mapfile.  */
+		  sec->lma = p->p_paddr + p->p_memsz;
+		}
+
 	      if (this_hdr->sh_type != SHT_NOBITS)
 		{
 		  if (p->p_filesz + adjust < p->p_memsz)

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

* Re: [Patch] Keep bfd section lma in sync with elf data structures
  2010-02-05 17:13 [Patch] Keep bfd section lma in sync with elf data structures Sterling Augustine
@ 2010-02-05 17:40 ` H.J. Lu
  0 siblings, 0 replies; 2+ messages in thread
From: H.J. Lu @ 2010-02-05 17:40 UTC (permalink / raw)
  To: Sterling Augustine; +Cc: binutils

Can put PR 11219 in ChangeLog entry?

Thanks.


H.J.

On Fri, Feb 5, 2010 at 9:13 AM, Sterling Augustine
<sterling@tensilica.com> wrote:
> I have committed the attached patch which updates the lma of a section
> inside the bfd data structure when it is changed inside the elf structure.
> The updated value is now printed in the map file, rather than the formerly
> stale value. This fixes bugzilla #11219.
>
> Sterling
>
> 2010-02-05  Sterling Augustine  <sterling@tensilica.com>
>
>        * elf.c (assign_file_positions_for_load_sections) Update lma of
>        section if necessary.
>
>
> Index: elf.c
> ===================================================================
> RCS file: /cvs/src/src/bfd/elf.c,v
> retrieving revision 1.500
> diff -u -p -r1.500 elf.c
> --- elf.c       4 Feb 2010 09:16:38 -0000       1.500
> +++ elf.c       5 Feb 2010 17:02:01 -0000
> @@ -4462,6 +4462,22 @@ assign_file_positions_for_load_sections
>                }
>              p->p_memsz += adjust;
>
> +             if (p->p_paddr + p->p_memsz != sec->lma)
> +               {
> +                 /* This behavior is a compromise--ld has long
> +                    silently changed the lma of sections when
> +                    lma - vma is not equal for every section in a
> +                    pheader--but only in the internal elf structures.
> +                    Silently changing the lma is probably a bug, but
> +                    changing it would have subtle and unknown
> +                    consequences for existing scripts.
> +
> +                    Instead modify the bfd data structure to reflect
> +                    what happened.  This at least fixes the values
> +                    for the lma in the mapfile.  */
> +                 sec->lma = p->p_paddr + p->p_memsz;
> +               }
> +
>              if (this_hdr->sh_type != SHT_NOBITS)
>                {
>                  if (p->p_filesz + adjust < p->p_memsz)
>
>



-- 
H.J.

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

end of thread, other threads:[~2010-02-05 17:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-05 17:13 [Patch] Keep bfd section lma in sync with elf data structures Sterling Augustine
2010-02-05 17:40 ` H.J. Lu

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