This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb/binutils-2_26-branch] Account for .tbss alignment when adjusting start of relro
- From: Alan Modra <amodra at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 10 Dec 2015 13:49:49 -0000
- Subject: [binutils-gdb/binutils-2_26-branch] Account for .tbss alignment when adjusting start of relro
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ccded9db34d062ebea2abd43e021ad1a985b1991
commit ccded9db34d062ebea2abd43e021ad1a985b1991
Author: Alan Modra <amodra@gmail.com>
Date: Thu Nov 19 15:00:13 2015 +1030
Account for .tbss alignment when adjusting start of relro
Another option might be to not bump "dot" for .tbss alignment in the
main section sizing loop, but that could leak some of the following
section into the TLS segment. Leakage shouldn't matter since it will
be to bytes past the end of .tdata, but for now this is a safer
option.
PR ld/19264
* ldlang.c (lang_size_sections): Don't ignore .tbss when
adjusting start of relro region.
Diff:
---
ld/ChangeLog | 8 ++++++++
ld/ldlang.c | 15 ++++++++++-----
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 252d5c9..63ae72a 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,11 @@
+2015-12-10 Alan Modra <amodra@gmail.com>
+
+ Apply from master.
+ 2015-11-19 Alan Modra <amodra@gmail.com>
+ PR ld/19264
+ * ldlang.c (lang_size_sections): Don't ignore .tbss when
+ adjusting start of relro region.
+
2015-11-13 Tristan Gingold <gingold@adacore.com>
* configure: Regenerate.
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 3841afc..c45b912 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -5457,18 +5457,23 @@ lang_size_sections (bfd_boolean *relax, bfd_boolean check_regions)
/* For sections in the relro segment.. */
for (sec = link_info.output_bfd->section_last; sec; sec = sec->prev)
- if (!IGNORE_SECTION (sec)
+ if ((sec->flags & SEC_ALLOC) != 0
&& sec->vma >= expld.dataseg.base
&& sec->vma < expld.dataseg.relro_end - expld.dataseg.relro_offset)
{
/* Where do we want to put this section so that it ends as
desired? */
- bfd_vma start = sec->vma;
- bfd_vma end = start + sec->size;
- bfd_vma bump = desired_end - end;
+ bfd_vma start, end, bump;
+
+ end = start = sec->vma;
+ if ((sec->flags & SEC_HAS_CONTENTS) != 0
+ || (sec->flags & SEC_THREAD_LOCAL) == 0)
+ end += 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. */
- start += bump & ~(((bfd_vma) 1 << sec->alignment_power) - 1);
+ start += bump;
+ start &= ~(((bfd_vma) 1 << sec->alignment_power) - 1);
/* This is now the desired end for the previous section. */
desired_end = start;
}