This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gold patch] Fix problem with alignment of relro sections


If any relro sections have unusual alignment that cause padding to be
introduced, the alignment of the PT_GNU_RELRO segment is not
calculated correctly. This patch fixes gold to account for any
alignment padding correctly. It also fixes a problem where gold was
trying to optimize the page alignment of the data segment to make it
fit on one less page, while simultaneously trying to align the relro
segment. The result was a waste of a page in the output file.

There is still an open question about the ARM port -- the .got
section, which includes the GOT PLT, is currently placed entirely
within relro. I don't think that's intended (all but the very
beginning of the GOT PLT should be on the page following the relro
segment), but I'll leave it for a separate patch.

OK?

-cary

        * 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.

Attachment: gold-relro-patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]