From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 52144 invoked by alias); 31 Mar 2016 07:40:10 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 52125 invoked by uid 89); 31 Mar 2016 07:40:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=Dan, offsetof, prod, optimum X-HELO: mail-pa0-f47.google.com Received: from mail-pa0-f47.google.com (HELO mail-pa0-f47.google.com) (209.85.220.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 31 Mar 2016 07:40:07 +0000 Received: by mail-pa0-f47.google.com with SMTP id td3so60194128pab.2 for ; Thu, 31 Mar 2016 00:40:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=tMNMT5/zfHbveHHhpWTjIGhH9xTlsW5a8CMmu9g8jIc=; b=d7203Yji7xz78Wiqos8C7lSoMqiP15GzaeNvI/bDdTmzXIvr5f8iMGHWu6MmPBCu7y JA5diS0Tt1hogt9bP23z4AOglEFBHIjZ2HDpg4koGx9eDgXxnmllCCBFyYT4GaenU9bh /h2wh6KXWpSMtAaGPAafO5qkHSXzAjMdtIfFG3OQcUZU4IuYhfcDNYjYN/iBmjrXsU6O xFHax0EqWL58nug1JEvKdHe2SJdFKXaRgRgKCZifxztnoNTnNoaC0d3pQ/uzsv4FxaEH MbGIHlcs5oJy39uRDrHczW8veQiWEM5TRfzBQbWZd3Ij3e5aBaxhx4/tqdDjOHUq6KEJ 83kQ== X-Gm-Message-State: AD7BkJJd+y4Iq7paDgowLKuPJm4h5bQcd3NOnf/S1qx+AEvLagFJ5ciEVyOBEDIZR9TRfA== X-Received: by 10.66.66.46 with SMTP id c14mr19869281pat.79.1459410005308; Thu, 31 Mar 2016 00:40:05 -0700 (PDT) Received: from bubble.grove.modra.org (CPE-58-160-146-233.sa.bigpond.net.au. [58.160.146.233]) by smtp.gmail.com with ESMTPSA id yj1sm10996210pac.16.2016.03.31.00.40.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Mar 2016 00:40:04 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id D8BBCEA0153; Thu, 31 Mar 2016 18:09:59 +1030 (ACDT) Date: Thu, 31 Mar 2016 07:40:00 -0000 From: Alan Modra To: dgisselq@ieee.org Cc: binutils@sourceware.org Subject: Re: Missing TO_ADDR Message-ID: <20160331073959.GT15812@bubble.grove.modra.org> References: <20160330073151.GK15812@bubble.grove.modra.org> <1459339484.9097.134.camel@jericho> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1459339484.9097.134.camel@jericho> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2016-03/txt/msg00451.txt.bz2 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. */ -- Alan Modra Australia Development Lab, IBM