diff options
author | Alan Modra <amodra@gmail.com> | 2015-04-22 22:46:19 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2015-04-22 23:19:59 +0930 |
commit | 0e5fabeb2c4b90857403995e14550210fe1cae71 (patch) | |
tree | 12b7bf30c5412d4e094c9aba11b0123877ef1831 /ld/ldexp.h | |
parent | d5597ebccca6761fb641b7fc99b6e8b56fbac6e2 (diff) | |
download | gdb-0e5fabeb2c4b90857403995e14550210fe1cae71.zip gdb-0e5fabeb2c4b90857403995e14550210fe1cae71.tar.gz gdb-0e5fabeb2c4b90857403995e14550210fe1cae71.tar.bz2 |
Rewrite relro adjusting code
The linker tries to put the end of the last section in the relro
segment exactly on a page boundary, because the relro segment itself
must end on a page boundary. If for any reason this can't be done,
padding is inserted. Since the end of the relro segment is typically
between .got and .got.plt, padding effectively increases the size of
the GOT. This isn't nice for targets and code models with limited GOT
addressing.
The problem with the current code is that it doesn't cope very well
with aligned sections in the relro segment. When making .got aligned
to a 256 byte boundary for PowerPC64, I found that often the initial
alignment attempt failed and the fallback attempt to be less than
adequate. This is a particular problem for PowerPC64 since the
distance between .got and .plt affects the size of plt call stubs,
leading to "stubs don't match calculated size" errors.
So this rewrite takes a direct approach to calculating a new relro
base. Starting from the last section in the segment, we calculate
where it must start to position its end on the boundary, or as near as
possible considering alignment requirements. The new start then
becomes the goal for the previous section to end, and so on for all
sections. This of course ignores the possibility that user scripts
will place . = ALIGN(xxx); in the relro segment, or provide section
address expressions. In those cases we might fail, but the old code
probably did too, and a fallback is provided.
ld/
* ldexp.h (struct ldexp_control): Delete dataseg.min_base. Add
data_seg.relro_offset.
* ldexp.c (fold_binary <DATA_SEGMENT_ALIGN>): Don't set min_base.
(fold_binary <DATA_SEGMENT_RELRO_END>): Do set relro_offset.
* ldlang.c (lang_size_sections): Rewrite code adjusting relro
segment base to line up last section on page boundary.
ld/testsuite/
* ld-x86-64/pr18176.d: Update.
Diffstat (limited to 'ld/ldexp.h')
-rw-r--r-- | ld/ldexp.h | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -156,7 +156,7 @@ struct ldexp_control { struct { enum phase_enum phase; - bfd_vma base, min_base, relro_end, end, pagesize, maxpagesize; + bfd_vma base, relro_offset, relro_end, end, pagesize, maxpagesize; enum relro_enum relro; |