diff options
Diffstat (limited to 'gold/layout.h')
-rw-r--r-- | gold/layout.h | 133 |
1 files changed, 115 insertions, 18 deletions
diff --git a/gold/layout.h b/gold/layout.h index 60ae114..b5b266c 100644 --- a/gold/layout.h +++ b/gold/layout.h @@ -286,6 +286,107 @@ class Kept_section } u_; }; +// The ordering for output sections. This controls how output +// sections are ordered within a PT_LOAD output segment. + +enum Output_section_order +{ + // Unspecified. Used for non-load segments. Also used for the file + // and segment headers. + ORDER_INVALID, + + // The PT_INTERP section should come first, so that the dynamic + // linker can pick it up quickly. + ORDER_INTERP, + + // Loadable read-only note sections come next so that the PT_NOTE + // segment is on the first page of the executable. + ORDER_RO_NOTE, + + // Put read-only sections used by the dynamic linker early in the + // executable to minimize paging. + ORDER_DYNAMIC_LINKER, + + // Put reloc sections used by the dynamic linker after other + // sections used by the dynamic linker; otherwise, objcopy and strip + // get confused. + ORDER_DYNAMIC_RELOCS, + + // Put the PLT reloc section after the other dynamic relocs; + // otherwise, prelink gets foncused. + ORDER_DYNAMIC_PLT_RELOCS, + + // The .init section. + ORDER_INIT, + + // The PLT. + ORDER_PLT, + + // The regular text sections. + ORDER_TEXT, + + // The .fini section. + ORDER_FINI, + + // The read-only sections. + ORDER_READONLY, + + // The exception frame sections. + ORDER_EHFRAME, + + // The TLS sections come first in the data section. + ORDER_TLS_DATA, + ORDER_TLS_BSS, + + // Local RELRO (read-only after relocation) sections come before + // non-local RELRO sections. This data will be fully resolved by + // the prelinker. + ORDER_RELRO_LOCAL, + + // Non-local RELRO sections are grouped together after local RELRO + // sections. All RELRO sections must be adjacent so that they can + // all be put into a PT_GNU_RELRO segment. + ORDER_RELRO, + + // We permit marking exactly one output section as the last RELRO + // section. We do this so that the read-only GOT can be adjacent to + // the writable GOT. + ORDER_RELRO_LAST, + + // Similarly, we permit marking exactly one output section as the + // first non-RELRO section. + ORDER_NON_RELRO_FIRST, + + // The regular data sections come after the RELRO sections. + ORDER_DATA, + + // Large data sections normally go in large data segments. + ORDER_LARGE_DATA, + + // Group writable notes so that we can have a single PT_NOTE + // segment. + ORDER_RW_NOTE, + + // The small data sections must be at the end of the data sections, + // so that they can be adjacent to the small BSS sections. + ORDER_SMALL_DATA, + + // The BSS sections start here. + + // The small BSS sections must be at the start of the BSS sections, + // so that they can be adjacent to the small data sections. + ORDER_SMALL_BSS, + + // The regular BSS sections. + ORDER_BSS, + + // The large BSS sections come after the other BSS sections. + ORDER_LARGE_BSS, + + // Maximum value. + ORDER_MAX +}; + // This class handles the details of laying out input sections. class Layout @@ -371,18 +472,14 @@ class Layout layout_gnu_stack(bool seen_gnu_stack, uint64_t gnu_stack_flags); // Add an Output_section_data to the layout. This is used for - // special sections like the GOT section. IS_DYNAMIC_LINKER_SECTION - // is true for sections which are used by the dynamic linker, such - // as dynamic reloc sections. IS_RELRO is true for relro sections. - // IS_LAST_RELRO is true for the last relro section. - // IS_FIRST_NON_RELRO is true for the first section after the relro - // sections. + // special sections like the GOT section. ORDER is where the + // section should wind up in the output segment. IS_RELRO is true + // for relro sections. Output_section* add_output_section_data(const char* name, elfcpp::Elf_Word type, elfcpp::Elf_Xword flags, - Output_section_data*, bool is_dynamic_linker_section, - bool is_relro, bool is_last_relro, - bool is_first_non_relro); + Output_section_data*, Output_section_order order, + bool is_relro); // Increase the size of the relro segment by this much. void @@ -788,29 +885,29 @@ class Layout Output_section* get_output_section(const char* name, Stringpool::Key name_key, elfcpp::Elf_Word type, elfcpp::Elf_Xword flags, - bool is_interp, bool is_dynamic_linker_section, - bool is_relro, bool is_last_relro, - bool is_first_non_relro); + Output_section_order order, bool is_relro); // Choose the output section for NAME in RELOBJ. Output_section* choose_output_section(const Relobj* relobj, const char* name, elfcpp::Elf_Word type, elfcpp::Elf_Xword flags, - bool is_input_section, bool is_interp, - bool is_dynamic_linker_section, bool is_relro, - bool is_last_relro, bool is_first_non_relro); + bool is_input_section, Output_section_order order, + bool is_relro); // Create a new Output_section. Output_section* make_output_section(const char* name, elfcpp::Elf_Word type, - elfcpp::Elf_Xword flags, bool is_interp, - bool is_dynamic_linker_section, bool is_relro, - bool is_last_relro, bool is_first_non_relro); + elfcpp::Elf_Xword flags, Output_section_order order, + bool is_relro); // Attach a section to a segment. void attach_section_to_segment(Output_section*); + // Get section order. + Output_section_order + default_section_order(Output_section*, bool is_relro_local); + // Attach an allocated section to a segment. void attach_allocated_section_to_segment(Output_section*); |