diff options
author | Ian Lance Taylor <ian@airs.com> | 2008-07-22 23:01:20 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 2008-07-22 23:01:20 +0000 |
commit | af6156ef8ded31c7b8e19fa7995e4de14a5b9639 (patch) | |
tree | b6f76e21579975faa46d823307fa81ae589c5b0d /gold/layout.cc | |
parent | 92de84a60cbdb80b808c8571e709c1384c6ee6fc (diff) | |
download | gdb-af6156ef8ded31c7b8e19fa7995e4de14a5b9639.zip gdb-af6156ef8ded31c7b8e19fa7995e4de14a5b9639.tar.gz gdb-af6156ef8ded31c7b8e19fa7995e4de14a5b9639.tar.bz2 |
* options.h (class General_options): Define -n/--nmagic and
-N/--omagic.
* options.cc (General_options::finalize): For -n/--nmagic or
-N/--omagic, set -static.
* layout.cc (Layout::attach_allocated_section_to_segment): If
-N/--omagic, don't put read-only and read-write sections in
different segments.
(Layout::find_first_load_seg): If -N/--omagic, don't insist on
finding a read-only segment.
(Layout::set_segment_offsets): If -N/--omagic or -n/--nmagic,
don't set the minimum segment alignment to the common page size,
and don't set the file offset to the address modulo the page size.
* script-sections.cc (Script_sections::create_segments): If
-n/--omagic, don't put read-only and read-write sections in
different segments.
Diffstat (limited to 'gold/layout.cc')
-rw-r--r-- | gold/layout.cc | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/gold/layout.cc b/gold/layout.cc index 13518d6..8c7cd99 100644 --- a/gold/layout.cc +++ b/gold/layout.cc @@ -865,7 +865,8 @@ Layout::attach_allocated_section_to_segment(Output_section* os) ++p) { if ((*p)->type() == elfcpp::PT_LOAD - && ((*p)->flags() & elfcpp::PF_W) == (seg_flags & elfcpp::PF_W)) + && (parameters->options().omagic() + || ((*p)->flags() & elfcpp::PF_W) == (seg_flags & elfcpp::PF_W))) { // If -Tbss was specified, we need to separate the data // and BSS segments. @@ -1108,7 +1109,8 @@ Layout::find_first_load_seg() { if ((*p)->type() == elfcpp::PT_LOAD && ((*p)->flags() & elfcpp::PF_R) != 0 - && ((*p)->flags() & elfcpp::PF_W) == 0) + && (parameters->options().omagic() + || ((*p)->flags() & elfcpp::PF_W) == 0)) return *p; } @@ -1769,20 +1771,26 @@ Layout::set_segment_offsets(const Target* target, Output_segment* load_seg, uint64_t aligned_addr = 0; uint64_t abi_pagesize = target->abi_pagesize(); + uint64_t common_pagesize = target->common_pagesize(); - // FIXME: This should depend on the -n and -N options. - (*p)->set_minimum_p_align(target->common_pagesize()); + if (!parameters->options().nmagic() + && !parameters->options().omagic()) + (*p)->set_minimum_p_align(common_pagesize); if (are_addresses_set) { - // Adjust the file offset to the same address modulo the - // page size. - uint64_t unsigned_off = off; - uint64_t aligned_off = ((unsigned_off & ~(abi_pagesize - 1)) - | (addr & (abi_pagesize - 1))); - if (aligned_off < unsigned_off) - aligned_off += abi_pagesize; - off = aligned_off; + if (!parameters->options().nmagic() + && !parameters->options().omagic()) + { + // Adjust the file offset to the same address modulo + // the page size. + uint64_t unsigned_off = off; + uint64_t aligned_off = ((unsigned_off & ~(abi_pagesize - 1)) + | (addr & (abi_pagesize - 1))); + if (aligned_off < unsigned_off) + aligned_off += abi_pagesize; + off = aligned_off; + } } else { @@ -1817,7 +1825,6 @@ Layout::set_segment_offsets(const Target* target, Output_segment* load_seg, if (!are_addresses_set && aligned_addr != addr) { - uint64_t common_pagesize = target->common_pagesize(); uint64_t first_off = (common_pagesize - (aligned_addr & (common_pagesize - 1))); |