diff options
author | Alan Modra <amodra@gmail.com> | 2015-11-19 15:00:13 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2015-11-19 16:22:25 +1030 |
commit | b39910205f54538f53e77b9ae13f1d41ff728f5a (patch) | |
tree | b96e3067d69c9a79a85db68be717d3c9bc8b372a /ld/ldlang.c | |
parent | 62aa7be1959a8d1202ab2c4809d76147aadeeeab (diff) | |
download | gdb-b39910205f54538f53e77b9ae13f1d41ff728f5a.zip gdb-b39910205f54538f53e77b9ae13f1d41ff728f5a.tar.gz gdb-b39910205f54538f53e77b9ae13f1d41ff728f5a.tar.bz2 |
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.
Diffstat (limited to 'ld/ldlang.c')
-rw-r--r-- | ld/ldlang.c | 15 |
1 files changed, 10 insertions, 5 deletions
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; } |