aboutsummaryrefslogtreecommitdiff
path: root/gold/output.h
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-10-13 05:18:13 -0700
committerH.J. Lu <hjl.tools@gmail.com>2020-10-13 05:18:24 -0700
commit6bf4a34047452f882c5cc66bd85812ee1bb5a41c (patch)
tree2d96b0c8ef59de1d9e026497798470bc9504bb08 /gold/output.h
parentaac1d94f19492fb6bea7193497bce599952c429d (diff)
downloadgdb-6bf4a34047452f882c5cc66bd85812ee1bb5a41c.zip
gdb-6bf4a34047452f882c5cc66bd85812ee1bb5a41c.tar.gz
gdb-6bf4a34047452f882c5cc66bd85812ee1bb5a41c.tar.bz2
gold: Properly align the NT_GNU_PROPERTY_TYPE_0 note
The NT_GNU_PROPERTY_TYPE_0 note should be aligned to 8 bytes for 64-bit ELF as specified by gABI. A note section can be only placed in a PT_NOTE segment with the same alignment. PR gold/22914 PR gold/23535 * layout.cc (Layout::attach_allocated_section_to_segment): Place a note section in a PT_NOTE segment with the same alignment. Set the alignment of the PT_NOTE segment from the alignment of the note section. (Layout::create_note): Align the NT_GNU_PROPERTY_TYPE_0 note to 8 bytes for 64-bit ELF. (Layout::segment_precedes): Place segments with larger alignments first. * output.cc (Output_segment::Output_segment): Initialize align_. * output.h (Output_segment): Add align, set_align and align_. * testsuite/Makefile.am (gnu_property_test.stdout): Pass -lhSWn to $(TEST_READELF). (gnu_property_test): Pass --build-id to ld. * testsuite/Makefile.in: Regenerated. * testsuite/gnu_property_test.sh (check_alignment): New. Use check_alignment to check the NT_GNU_PROPERTY_TYPE_0 note alignment. Verify that there are 2 PT_NOTE segments.
Diffstat (limited to 'gold/output.h')
-rw-r--r--gold/output.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/gold/output.h b/gold/output.h
index 77b6697..35170c3 100644
--- a/gold/output.h
+++ b/gold/output.h
@@ -4688,6 +4688,16 @@ class Output_segment
offset() const
{ return this->offset_; }
+ // Return the segment alignment.
+ uint64_t
+ align() const
+ { return this->align_; }
+
+ // Set the segment alignment.
+ void
+ set_align(uint64_t align)
+ { this->align_ = align; }
+
// Whether this is a segment created to hold large data sections.
bool
is_large_data_segment() const
@@ -4910,6 +4920,8 @@ class Output_segment
uint64_t paddr_;
// The size of the segment in memory.
uint64_t memsz_;
+ // The segment alignment.
+ uint64_t align_;
// The maximum section alignment. The is_max_align_known_ field
// indicates whether this has been finalized.
uint64_t max_align_;