public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Dan <dgisselq@verizon.net>
To: Alan Modra <amodra@gmail.com>
Cc: dgisselq@ieee.org, binutils@sourceware.org
Subject: Re: Missing TO_ADDR
Date: Thu, 31 Mar 2016 11:13:00 -0000	[thread overview]
Message-ID: <1459422766.9097.169.camel@jericho> (raw)
In-Reply-To: <20160331073959.GT15812@bubble.grove.modra.org>

Are you sure you want to take the TO_SIZE directives *away* from the
minfo statements?  With the TO_SIZE directives, the addresses add up:
last address plus size adds up to the next address, and you can see
nothing missing.  Without the TO_SIZE directives, the units don't match.

Dan


On Thu, 2016-03-31 at 18:09 +1030, Alan Modra wrote:
> On Wed, Mar 30, 2016 at 08:04:44AM -0400, Dan wrote:
> > Don't forget the "minfo ("0x%V %W", section->vma ..." line that needs
> > its "section->size" parameter changed to TO_ADDR(section->size), or the
> > "lma = last->lma+last->size" that needs to be changed to "lma =
> > last->lma + TO_ADDR(last->size);".  At least according to my last git
> > pull, those changes still needed to be made as well.
> 
> Yes, there are other places missing TO_ADDR, and one of the minfo
> lines wrongly invokes TO_ADDR.  Thanks for the prod.
> 
> 	* ldlang.c (TO_ADDR, TO_SIZE, opb_shift): Move earlier in file.
> 	(lang_insert_orphan): Use TO_ADDR in __stop sym calculation.
> 	(print_input_section): Don't use TO_ADDR when printing section
> 	size.
> 	(lang_size_sections_1): Use TO_ADDR in overlay lma calculation.
> 	(lang_size_sections): Use TO_ADDR in relro end calculation.
> 
> diff --git a/ld/ldlang.c b/ld/ldlang.c
> index cb6aab6..9fca810 100644
> --- a/ld/ldlang.c
> +++ b/ld/ldlang.c
> @@ -49,7 +49,13 @@
>  #define offsetof(TYPE, MEMBER) ((size_t) & (((TYPE*) 0)->MEMBER))
>  #endif
>  
> -/* Locals variables.  */
> +/* Convert between addresses in bytes and sizes in octets.
> +   For currently supported targets, octets_per_byte is always a power
> +   of two, so we can use shifts.  */
> +#define TO_ADDR(X) ((X) >> opb_shift)
> +#define TO_SIZE(X) ((X) << opb_shift)
> +
> +/* Local variables.  */
>  static struct obstack stat_obstack;
>  static struct obstack map_obstack;
>  
> @@ -68,6 +74,7 @@ static lang_statement_list_type *stat_save[10];
>  static lang_statement_list_type **stat_save_ptr = &stat_save[0];
>  static struct unique_sections *unique_section_list;
>  static struct asneeded_minfo *asneeded_list_head;
> +static unsigned int opb_shift = 0;
>  static bfd_boolean maybe_overlays = FALSE;
>  
>  /* Forward declarations.  */
> @@ -1887,7 +1894,7 @@ lang_insert_orphan (asection *s,
>  	 before sizing dynamic sections.  */
>        dot = os->bfd_section->vma;
>        exp_fold_tree (start_assign->exp, os->bfd_section, &dot);
> -      dot += s->size;
> +      dot += TO_ADDR (s->size);
>        exp_fold_tree (stop_assign->exp, os->bfd_section, &dot);
>      }
>  
> @@ -3209,15 +3216,6 @@ ldlang_open_output (lang_statement_union_type *statement)
>      }
>  }
>  
> -/* Convert between addresses in bytes and sizes in octets.
> -   For currently supported targets, octets_per_byte is always a power
> -   of two, so we can use shifts.  */
> -#define TO_ADDR(X) ((X) >> opb_shift)
> -#define TO_SIZE(X) ((X) << opb_shift)
> -
> -/* Support the above.  */
> -static unsigned int opb_shift = 0;
> -
>  static void
>  init_opb (void)
>  {
> @@ -4225,7 +4223,7 @@ print_input_section (asection *i, bfd_boolean is_discarded)
>  	size = 0;
>      }
>  
> -  minfo ("0x%V %W %B\n", addr, TO_ADDR (size), i->owner);
> +  minfo ("0x%V %W %B\n", addr, size, i->owner);
>  
>    if (size != i->rawsize && i->rawsize != 0)
>      {
> @@ -5132,7 +5130,7 @@ lang_size_sections_1
>  		    /* If this is an overlay, set the current lma to that
>  		       at the end of the previous section.  */
>  		    if (os->sectype == overlay_section)
> -		      lma = last->lma + last->size;
> +		      lma = last->lma + TO_ADDR (last->size);
>  
>  		    /* Otherwise, keep the same lma to vma relationship
>  		       as the previous section.  */
> @@ -5524,7 +5522,7 @@ lang_size_sections (bfd_boolean *relax, bfd_boolean check_regions)
>  
>  	    end = start = sec->vma;
>  	    if (!IS_TBSS (sec))
> -	      end += sec->size;
> +	      end += TO_ADDR (sec->size);
>  	    bump = desired_end - end;
>  	    /* We'd like to increase START by BUMP, but we must heed
>  	       alignment so the increase might be less than optimum.  */
> 

  reply	other threads:[~2016-03-31 11:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-30  7:32 Alan Modra
2016-03-30 12:08 ` Dan
     [not found] ` <1459339484.9097.134.camel@jericho>
2016-03-31  7:40   ` Alan Modra
2016-03-31 11:13     ` Dan [this message]
2016-04-01  1:28       ` Alan Modra
2016-03-31 16:03     ` Dan
2016-04-01  1:31       ` Alan Modra
2016-04-01 14:42         ` [PATCH] " Dan
2016-04-08  5:16           ` Alan Modra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1459422766.9097.169.camel@jericho \
    --to=dgisselq@verizon.net \
    --cc=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=dgisselq@ieee.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).