aboutsummaryrefslogtreecommitdiff
path: root/gold/layout.cc
diff options
context:
space:
mode:
authorCary Coutant <ccoutant@google.com>2010-10-16 00:37:25 +0000
committerCary Coutant <ccoutant@google.com>2010-10-16 00:37:25 +0000
commitfc497986a30ad75ecb056a9b8a92a157529046c3 (patch)
treebcef1c6ca8c27640ab38e58791aa618792466f20 /gold/layout.cc
parent591c89577742f555137a31e24e1138c17182aab6 (diff)
downloadgdb-fc497986a30ad75ecb056a9b8a92a157529046c3.zip
gdb-fc497986a30ad75ecb056a9b8a92a157529046c3.tar.gz
gdb-fc497986a30ad75ecb056a9b8a92a157529046c3.tar.bz2
* layout.cc (Layout::set_segment_offsets): Don't try to realign data
segment that has been aligned for relro. * output.cc (Output_segment::set_section_addresses): Change signature; adjust all callers. Account for alignment when totalling size of relro sections. * output.h (Output_segment::set_section_addresses): Change signature. * testsuite/Makefile.am (relro_test.sh, relro_test.stdout): New targets. * testsuite/Makefile.in: Regenerate. * testsuite/relro_test.cc: Add alignment attributes to test proper alignment of relro sections when padding is necessary. * testsuite/relro_test.sh: New script.
Diffstat (limited to 'gold/layout.cc')
-rw-r--r--gold/layout.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/gold/layout.cc b/gold/layout.cc
index 2f56d27..3df7d3d 100644
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -2656,17 +2656,21 @@ Layout::set_segment_offsets(const Target* target, Output_segment* load_seg,
}
unsigned int shndx_hold = *pshndx;
+ bool has_relro = false;
uint64_t new_addr = (*p)->set_section_addresses(this, false, addr,
- increase_relro,
+ &increase_relro,
+ &has_relro,
&off, pshndx);
// Now that we know the size of this segment, we may be able
// to save a page in memory, at the cost of wasting some
// file space, by instead aligning to the start of a new
// page. Here we use the real machine page size rather than
- // the ABI mandated page size.
+ // the ABI mandated page size. If the segment has been
+ // aligned so that the relro data ends at a page boundary,
+ // we do not try to realign it.
- if (!are_addresses_set && aligned_addr != addr)
+ if (!are_addresses_set && !has_relro && aligned_addr != addr)
{
uint64_t first_off = (common_pagesize
- (aligned_addr
@@ -2684,7 +2688,8 @@ Layout::set_segment_offsets(const Target* target, Output_segment* load_seg,
off = orig_off + ((addr - orig_addr) & (abi_pagesize - 1));
off = align_file_offset(off, addr, abi_pagesize);
new_addr = (*p)->set_section_addresses(this, true, addr,
- increase_relro,
+ &increase_relro,
+ &has_relro,
&off, pshndx);
}
}