From: "H.J. Lu" <hjl.tools@gmail.com>
To: Tristan Gingold <gingold@adacore.com>
Cc: binutils <binutils@sourceware.org>
Subject: Re: [Patch] ld: check for address space overflow
Date: Tue, 14 Mar 2017 16:13:00 -0000 [thread overview]
Message-ID: <CAMe9rOrL=Vi79JST+ajcgZ6fu=miDGJfSBMo3=DUD8w=OoqkZw@mail.gmail.com> (raw)
In-Reply-To: <F639AA22-1566-43A8-96DD-C3013A5E5B5B@adacore.com>
On Tue, Mar 14, 2017 at 1:15 AM, Tristan Gingold <gingold@adacore.com> wrote:
> [...]
>
>> This works:
>>
>> diff --git a/ld/ldlang.c b/ld/ldlang.c
>> index a0638ea..8c1d829 100644
>> --- a/ld/ldlang.c
>> +++ b/ld/ldlang.c
>> @@ -4783,13 +4783,13 @@ lang_check_section_addresses (void)
>> for (s = link_info.output_bfd->sections; s != NULL; s = s->next)
>> {
>> s_end = (s->vma + s->size) & addr_mask;
>> - if (s_end != 0 && s_end < s->vma)
>> + if (s_end != 0 && s_end < (s->vma & addr_mask))
>> einfo (_("%X%P: section %s VMA wraps around address space\n"),
>> s->name);
>> else
>> {
>> s_end = (s->lma + s->size) & addr_mask;
>> - if (s_end != 0 && s_end < s->lma)
>> + if (s_end != 0 && s_end < (s->lma & addr_mask))
>> einfo (_("%X%P: section %s LMA wraps around address space\n"),
>> s->name);
>> }
>
> Yes, that makes sense.
> Do you plan to commit it ?
>
This is what I checked in.
--
H.J.
---
From 9216a6f33592c350ad50696d5571c82e47b71a5e Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Tue, 14 Mar 2017 09:09:54 -0700
Subject: [PATCH] Use addr_mask to check VMA and LMA
Since BFD64 may be used on 32-bit address, we need to apply addr_mask
to check VMA and LMA.
* ldlang.c (lang_check_section_addresses): Use addr_mask to
check VMA and LMA.
---
ld/ChangeLog | 5 +++++
ld/ldlang.c | 4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/ld/ChangeLog b/ld/ChangeLog
index eb0c309..df8bb32 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,8 @@
+2017-03-14 H.J. Lu <hongjiu.lu@intel.com>
+
+ * ldlang.c (lang_check_section_addresses): Use addr_mask to
+ check VMA and LMA.
+
2017-03-13 Nick Clifton <nickc@redhat.com>
PR binutils/21202
diff --git a/ld/ldlang.c b/ld/ldlang.c
index a0638ea..8c1d829 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -4783,13 +4783,13 @@ lang_check_section_addresses (void)
for (s = link_info.output_bfd->sections; s != NULL; s = s->next)
{
s_end = (s->vma + s->size) & addr_mask;
- if (s_end != 0 && s_end < s->vma)
+ if (s_end != 0 && s_end < (s->vma & addr_mask))
einfo (_("%X%P: section %s VMA wraps around address space\n"),
s->name);
else
{
s_end = (s->lma + s->size) & addr_mask;
- if (s_end != 0 && s_end < s->lma)
+ if (s_end != 0 && s_end < (s->lma & addr_mask))
einfo (_("%X%P: section %s LMA wraps around address space\n"),
s->name);
}
--
2.9.3
prev parent reply other threads:[~2017-03-14 16:13 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-10 14:29 Tristan Gingold
2017-03-11 1:14 ` Alan Modra
2017-03-13 9:47 ` Tristan Gingold
2017-03-13 17:52 ` H.J. Lu
2017-03-13 19:06 ` H.J. Lu
2017-03-13 19:27 ` H.J. Lu
2017-03-14 8:15 ` Tristan Gingold
2017-03-14 10:20 ` Alan Modra
2017-03-14 10:50 ` Tristan Gingold
2017-03-14 12:17 ` Alan Modra
2017-03-14 13:56 ` Tristan Gingold
2017-03-15 1:11 ` Alan Modra
2017-03-15 9:26 ` Tristan Gingold
2017-03-14 16:13 ` H.J. Lu [this message]
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='CAMe9rOrL=Vi79JST+ajcgZ6fu=miDGJfSBMo3=DUD8w=OoqkZw@mail.gmail.com' \
--to=hjl.tools@gmail.com \
--cc=binutils@sourceware.org \
--cc=gingold@adacore.com \
/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).