2008-01-23 01:31:13 +00:00
|
|
|
// script-sections.h -- linker script SECTIONS for gold -*- C++ -*-
|
|
|
|
|
2009-03-19 05:51:49 +00:00
|
|
|
// Copyright 2008, 2009 Free Software Foundation, Inc.
|
2008-01-23 01:31:13 +00:00
|
|
|
// Written by Ian Lance Taylor <iant@google.com>.
|
|
|
|
|
|
|
|
// This file is part of gold.
|
|
|
|
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation; either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
|
|
|
// MA 02110-1301, USA.
|
|
|
|
|
|
|
|
// This is for the support of the SECTIONS clause in linker scripts.
|
|
|
|
|
|
|
|
#ifndef GOLD_SCRIPT_SECTIONS_H
|
|
|
|
#define GOLD_SCRIPT_SECTIONS_H
|
|
|
|
|
|
|
|
#include <cstdio>
|
2009-03-19 05:51:49 +00:00
|
|
|
#include <list>
|
2008-01-23 01:31:13 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace gold
|
|
|
|
{
|
|
|
|
|
|
|
|
struct Parser_output_section_header;
|
|
|
|
struct Parser_output_section_trailer;
|
|
|
|
struct Input_section_spec;
|
|
|
|
class Expression;
|
|
|
|
class Sections_element;
|
2010-09-08 16:10:33 +00:00
|
|
|
class Memory_region;
|
2008-02-04 22:54:31 +00:00
|
|
|
class Phdrs_element;
|
|
|
|
class Output_data;
|
2008-01-23 01:31:13 +00:00
|
|
|
class Output_section_definition;
|
2008-02-04 05:43:05 +00:00
|
|
|
class Output_section;
|
|
|
|
class Output_segment;
|
2009-03-19 05:51:49 +00:00
|
|
|
class Orphan_section_placement;
|
2008-01-23 01:31:13 +00:00
|
|
|
|
|
|
|
class Script_sections
|
|
|
|
{
|
2010-10-12 19:21:41 +00:00
|
|
|
public:
|
2009-03-19 05:51:49 +00:00
|
|
|
// This is a list, not a vector, because we insert orphan sections
|
|
|
|
// in the middle.
|
|
|
|
typedef std::list<Sections_element*> Sections_elements;
|
|
|
|
|
2010-04-09 17:32:58 +00:00
|
|
|
// Logical script section types. We map section types returned by the
|
|
|
|
// parser into these since some section types have the same semantics.
|
|
|
|
enum Section_type
|
|
|
|
{
|
|
|
|
// No section type specified.
|
|
|
|
ST_NONE,
|
|
|
|
// Section is NOLOAD. We allocate space in the output but section
|
|
|
|
// is not loaded in runtime.
|
|
|
|
ST_NOLOAD,
|
|
|
|
// No space is allocated to section.
|
|
|
|
ST_NOALLOC
|
|
|
|
};
|
|
|
|
|
2008-01-23 01:31:13 +00:00
|
|
|
Script_sections();
|
|
|
|
|
|
|
|
// Start a SECTIONS clause.
|
|
|
|
void
|
|
|
|
start_sections();
|
|
|
|
|
|
|
|
// Finish a SECTIONS clause.
|
|
|
|
void
|
|
|
|
finish_sections();
|
|
|
|
|
|
|
|
// Return whether we ever saw a SECTIONS clause. If we did, then
|
|
|
|
// all section layout needs to go through this class.
|
|
|
|
bool
|
|
|
|
saw_sections_clause() const
|
|
|
|
{ return this->saw_sections_clause_; }
|
|
|
|
|
|
|
|
// Return whether we are currently processing a SECTIONS clause.
|
|
|
|
bool
|
|
|
|
in_sections_clause() const
|
|
|
|
{ return this->in_sections_clause_; }
|
|
|
|
|
2008-02-04 22:54:31 +00:00
|
|
|
// Return whether we ever saw a PHDRS clause. We ignore the PHDRS
|
|
|
|
// clause unless we also saw a SECTIONS clause.
|
|
|
|
bool
|
|
|
|
saw_phdrs_clause() const
|
|
|
|
{ return this->saw_sections_clause_ && this->phdrs_elements_ != NULL; }
|
|
|
|
|
2008-01-23 01:31:13 +00:00
|
|
|
// Start processing entries for an output section.
|
|
|
|
void
|
|
|
|
start_output_section(const char* name, size_t namelen,
|
|
|
|
const Parser_output_section_header*);
|
|
|
|
|
|
|
|
// Finish processing entries for an output section.
|
|
|
|
void
|
|
|
|
finish_output_section(const Parser_output_section_trailer*);
|
|
|
|
|
|
|
|
// Add a data item to the current output section.
|
|
|
|
void
|
|
|
|
add_data(int size, bool is_signed, Expression* val);
|
|
|
|
|
|
|
|
// Add a symbol to be defined.
|
|
|
|
void
|
|
|
|
add_symbol_assignment(const char* name, size_t length, Expression* value,
|
|
|
|
bool provide, bool hidden);
|
2008-02-04 05:43:05 +00:00
|
|
|
|
|
|
|
// Add an assignment to the special dot symbol.
|
|
|
|
void
|
|
|
|
add_dot_assignment(Expression* value);
|
|
|
|
|
2008-01-23 01:31:13 +00:00
|
|
|
// Add an assertion.
|
|
|
|
void
|
|
|
|
add_assertion(Expression* check, const char* message, size_t messagelen);
|
|
|
|
|
|
|
|
// Add a setting for the fill value.
|
|
|
|
void
|
|
|
|
add_fill(Expression* val);
|
|
|
|
|
|
|
|
// Add an input section specification.
|
|
|
|
void
|
|
|
|
add_input_section(const Input_section_spec* spec, bool keep);
|
|
|
|
|
2008-08-13 07:37:46 +00:00
|
|
|
// Saw DATA_SEGMENT_ALIGN.
|
|
|
|
void
|
|
|
|
data_segment_align();
|
|
|
|
|
|
|
|
// Saw DATA_SEGMENT_RELRO_END.
|
|
|
|
void
|
|
|
|
data_segment_relro_end();
|
|
|
|
|
2008-02-28 04:45:47 +00:00
|
|
|
// Create any required sections.
|
|
|
|
void
|
|
|
|
create_sections(Layout*);
|
|
|
|
|
2008-02-04 05:43:05 +00:00
|
|
|
// Add any symbols we are defining to the symbol table.
|
|
|
|
void
|
|
|
|
add_symbols_to_table(Symbol_table*);
|
|
|
|
|
|
|
|
// Finalize symbol values and check assertions.
|
|
|
|
void
|
|
|
|
finalize_symbols(Symbol_table* symtab, const Layout* layout);
|
|
|
|
|
|
|
|
// Find the name of the output section to use for an input file name
|
|
|
|
// and section name. This returns a name, and sets
|
|
|
|
// *OUTPUT_SECTION_SLOT to point to the address where the actual
|
|
|
|
// output section may be stored.
|
|
|
|
// 1) If the input section should be discarded, this returns NULL
|
|
|
|
// and sets *OUTPUT_SECTION_SLOT to NULL.
|
|
|
|
// 2) If the input section is mapped by the SECTIONS clause, this
|
|
|
|
// returns the name to use for the output section (in permanent
|
|
|
|
// storage), and sets *OUTPUT_SECTION_SLOT to point to where the
|
|
|
|
// output section should be stored. **OUTPUT_SECTION_SLOT will be
|
|
|
|
// non-NULL if we have seen this output section already.
|
|
|
|
// 3) If the input section is not mapped by the SECTIONS clause,
|
|
|
|
// this returns SECTION_NAME, and sets *OUTPUT_SECTION_SLOT to
|
|
|
|
// NULL.
|
2010-04-09 17:32:58 +00:00
|
|
|
// PSCRIPT_SECTION_TYPE points to a location for returning the section
|
|
|
|
// type specified in script. This can be SCRIPT_SECTION_TYPE_NONE if
|
|
|
|
// no type is specified.
|
2012-08-14 08:31:57 +00:00
|
|
|
// *KEEP indicates whether the section should survive garbage collection.
|
2008-02-04 05:43:05 +00:00
|
|
|
const char*
|
|
|
|
output_section_name(const char* file_name, const char* section_name,
|
2010-04-09 17:32:58 +00:00
|
|
|
Output_section*** output_section_slot,
|
2012-08-14 08:31:57 +00:00
|
|
|
Section_type* pscript_section_type,
|
|
|
|
bool* keep);
|
2008-02-04 05:43:05 +00:00
|
|
|
|
|
|
|
// Place a marker for an orphan output section into the SECTIONS
|
|
|
|
// clause.
|
|
|
|
void
|
|
|
|
place_orphan(Output_section* os);
|
|
|
|
|
|
|
|
// Set the addresses of all the output sections. Return the segment
|
|
|
|
// which holds the file header and segment headers, if any.
|
|
|
|
Output_segment*
|
|
|
|
set_section_addresses(Symbol_table*, Layout*);
|
|
|
|
|
2008-02-04 22:54:31 +00:00
|
|
|
// Add a program header definition.
|
|
|
|
void
|
|
|
|
add_phdr(const char* name, size_t namelen, unsigned int type,
|
|
|
|
bool filehdr, bool phdrs, bool is_flags_valid, unsigned int flags,
|
|
|
|
Expression* load_address);
|
|
|
|
|
2008-02-04 06:45:50 +00:00
|
|
|
// Return the number of segments we expect to create based on the
|
|
|
|
// SECTIONS clause.
|
|
|
|
size_t
|
|
|
|
expected_segment_count(const Layout*) const;
|
|
|
|
|
2008-02-04 22:54:31 +00:00
|
|
|
// Add the file header and segment header to non-load segments as
|
|
|
|
// specified by the PHDRS clause.
|
|
|
|
void
|
|
|
|
put_headers_in_phdrs(Output_data* file_header, Output_data* segment_headers);
|
|
|
|
|
2008-02-29 00:04:06 +00:00
|
|
|
// Look for an output section by name and return the address, the
|
|
|
|
// load address, the alignment, and the size. This is used when an
|
|
|
|
// expression refers to an output section which was not actually
|
|
|
|
// created. This returns true if the section was found, false
|
|
|
|
// otherwise.
|
|
|
|
bool
|
|
|
|
get_output_section_info(const char* name, uint64_t* address,
|
|
|
|
uint64_t* load_address, uint64_t* addralign,
|
|
|
|
uint64_t* size) const;
|
|
|
|
|
2009-09-17 Doug Kwan <dougkwan@google.com>
* debug.h (DEBUG_RELAXATION): New constant.
(DEBUG_ALL): Add DEBUG_RELAXATION.
(debug_string_to_enum): Add relaxation debug option.
* layout.cc
(Layout::Relaxation_debug_check::check_output_data_for_reset_values,
Layout::Relaxation_debug_check::read_sections,
Layout::Relaxation_debug_check::read_sections): New method definitions.
(Layout::Layout): Initialize data members
record_output_section_data_from_scrips_,
script_output_section_data_list_ and relaxation_debug_check_.
(Layout::save_segments, Layout::restore_segments,
Layout::clean_up_after_relaxation, Layout::prepare_for_relaxation,
Layout::relaxation_loop_body): New method definitions.
(Layout::finalize): Support relaxation. Move section layout code to
Layout::relaxation_loop_body.
(Layout::set_asection_address_from_script): Move code for orphan
section placement out.
(Layout::place_orphan_sections_in_script): New method definition.
* layout.h (Output_segment_headers, Output_file_header):
New forward class declarations.
(Layout::~Layout): Define.
(Layout::new_output_section_data_from_script): New method definition.
(Layout::place_orphan_sections_in_script): New method declaration.
(Layout::Segment_states): New type declaration.
(Layout::save_segments, Layout::restore_segments,
Layout::clean_up_after_relaxation, Layout::prepare_for_relaxation,
Layout::relaxation_loop_body): New method declarations.
(Layout::Output_section_data_list): New type declaration.
(Layout::Relaxation_debug_check): New class definition.
(Layout::record_output_section_data_from_script_,
Layout::script_output_section_data_list_, Layout::segment_states_,
Layout::relaxation_debug_check_): New data members.
* output.cc: (Output_section_headers::do_size): New method definition.
(Output_section_headers::Output_section_headers): Move size
computation to Output_section_headers::do_size.
(Output_segment_headers::do_size): New method definition.
(Output_file_header::Output_file_header): Move size computation to
Output_file_header::do_size and call it.
(Output_file_header::do_size): New method definition.
(Output_data_group::Output_data_group): Adjust call to
Output_section_data.
(Output_data_dynamic::set_final_data_size): Add DT_NULL tag only once.
(Output_symtab_xindex::do_write): Add array bound check.
(Output_section::Input_section::print_to_mapfile): Handle
RELAXED_INPUT_SECTION_CODE.
(Output_section::Output_section): Initialize data member checkpoint_.
(Output_section::~Output_section): Delete checkpoint object pointed
by checkpoint_.
(Output_section::add_input_section): Always add an Input_section if
relaxing.
(Output_section::add_merge_input_section): Add assert.
(Output_section::relax_input_section): New method definition.
(Output_section::set_final_data_size): Set load address to zero for
an unallocated section.
(Output_section::do_address_and_file_offset_have_reset_values):
New method definition.
(Output_section::Input_section_sort_enty::Input_section_sort_enty):
Handle relaxed input section.
(Output_section::sort_attached_input_sections): Checkpoint input
section list lazily.
(Output_section::get_input_sections): Change type of input_sections to
list of Simple_input_section pointers. Checkpoint input section list
lazily. Also handle relaxed input sections.
(Output_section::add_input_section_for_script): Take a reference to
a Simple_input_section object instead of Relobj pointer and section
index as parameter. Handle relaxed input sections.
(Output_section::save_states, Output_section::restore_states): New
method definitions.
* output.h (Output_data::Output_data): Initialize is_data_size_fixed_.
(Output_data::is_data_size_fixed): New method definition.
(Output_data::reset_addresss_and_file_offset): Do not reset data size
if it is fixed.
(Output_data::address_and_file_offset_have_reset_values): New method
definition.
(Output_data::do_address_and_file_offset_have_reset_values): New method
definition.
(Output_data::set_data_size): Check that data size is not fixed.
(Output_data::fix_data_size): New method definition.
(Output_data::is_data_size_fixed_): New data member.
(Output_section_headers::set_final_data_size): New method definition.
(Output_section_headers::do_size): New method declaration.
(Output_segment_headers::set_final_data_size): New method definition.
(Output_segment_headers::do_size): New method declaration.
(Output_file_header::set_final_data_size)::New method definition.
(Output_file_header::do_size)::New method declaration.
(Output_section_data::Output_section_data): Add new parameter
is_data_size_fixed and use it to fix data size.
(Output_data_const::Output_data_const): Adjust call to base class
constructor and fix data size.
(Output_data_const_buffer::Output_data_const_buffer): Adjust call to
base class constructor and fix data size.
(Output_data_fixed_space::Output_data_fixed_space): Adjust call to
base class constructor and fix data size.
(Output_data_zero_fill::Output_data_zero_fill): Adjust call to base
class constructor and fix data size.
(Output_data_group::set_final_data_size): New method definition.
(Output_data_dynamic::Dynamic_entry::tag): New method definition.
(Output_symtab_xindex::Output_symtab_xindex): Adjust call to base
class constructor and fix data size.
(Output_relaxed_input_section): New class definition.
(Output_section::Simple_input_section): New class definition.
(Output_section::get_input_sections): Adjust parameter list.
(Output_section::add_input_section_for_script): Same.
(Output_section::save_states, Output_section::restore_states,
Output_section::do_address_and_file_offset_have_reset_values,
(Output_section::Input_section::Input_section): Handle
RELAXED_INPUT_SECTION_CODE. Add new overload for
Output_relaxed_input_section.
(Output_section::Input_section::is_input_section,
Output_section::Input_section::set_output_section): Handle relaxed
input section.
(Output_section::Input_section::is_relaxed_input_section,
Output_section::Input_section::output_section_data,
Output_section::Input_section::relaxed_input_section): New method
definitions.
(Output_section::Input_section::RELAXED_INPUT_SECTION_CODE): New enum
value.
(Output_section::Input_section::u1_): Update comments.
(Output_section::Input_section::u2_): Add new union member poris.
(Output_section::Checkpoint_output_section): New classs definition.
(Output_section::relax_input_section): New method declaration.
(Output_section::checkpoint_): New data member.
(Output_segment): Update comments.
(Output_segment::Output_segment): Un-privatize copy constructor.
(Output_segment::operator=): Un-privatize.
* script-sections.cc (Output_section_element::Input_section_list):
Change element type to Output_section::Simple_input_section.
(Output_section_element_dot_assignment::set_section_addresses):
Register output section data for relaxation clean up.
(Output_data_exression::Output_data_expression): Adjust call to base
constructor to fix data size.
(Output_section_element_data::set_section_addresses): Register
Output_data_expression object for relaxation clean up.
(struct Input_section_info): Replace Relobj pointer and section index
pair with Output_section::Simple_input_section and Convert struct to a
class.
(Input_section_sorter::operator()): Adjust access to
Input_section_info data member to use accessors.
(Output_section_element_input::set_section_addresses): Use layout
parameter. Adjust code to use Output_section::Simple_input_section
and Input_secction_info classes. Register filler for relaxation
clean up.
(Orphan_output_section::set_section_addresses): Replace Relobj pointer
and section index pair with Output_section::Simple_input_section
class. Adjust code accordingly.
(Phdrs_element::release_segment): New method definition.
(Script_sections::attach_sections_using_phdrs_clause): Do not modify
segment list.
(Script_sections::release_segments): New method definition.
* gold/script-sections.h (Script_sections::release_segments): New
method declaration.
* gold/target.h (Target::may_relax, Target::relax,
Target::do_may_relax, Target::do_relax): New method definitions.
2009-09-18 01:10:38 +00:00
|
|
|
// Release all Output_segments. This is used in relaxation.
|
|
|
|
void
|
|
|
|
release_segments();
|
|
|
|
|
2009-10-16 Doug Kwan <dougkwan@google.com>
* expression.cc (class Segment_start_expression): New class definition.
(Segment_start_expression::value): New method definition.
(script_exp_function_segment_start): Return a new
Segment_start_expression.
* gold/script-c.h (script_saw_segment_start_expression): New function
prototype.
* script-sections.cc (Script_sections::Script_sections): Initialize
SAW_SEGMENT_START_EXPRESSION_ to false.
(Script_sections::set_section_addresses): Use -Ttext, -Tdata
and -Tbbs options to specify section addresses if given in
command line and no SEGMENT_START expression is seen in a script.
* script-sections.h (Script_sections::saw_segment_start_expression,
Script_sections::set_saw_segment_start_expression): New method
definition.
(Script_sections::saw_segment_start_expression_): New data member
declaration.
* script.cc (script_saw_segment_start_expression): New function.
* yyscript.y (SEGMENT_START): Call script_saw_segment_start_expression.
* testsuite/Makefile.am (check_SCRIPTS): Add script_test_6.sh,
script_test_7.sh and script_test_8.sh.
(check_DATA): Add script_test_6.stdout, script_test_7.stdout and
script_test_8.stdout.
(MOSTLYCLEANFILES): Add script_test_6, script_test_7 and script_test_8.
(script_test_6, script_test_6.stdout, script_test_7,
script_test_7.stdout, script_test_8, script_test_8.stdout): New rules.
* Makefile.in: Regenerate.
* testsuite/script_test_6.sh: New file.
* testsuite/script_test_6.t: Same.
* testsuite/script_test_7.sh: Same.
* testsuite/script_test_7.t: Same.
* testsuite/script_test_8.sh: Same.
2009-10-16 18:56:07 +00:00
|
|
|
// Whether we ever saw a SEGMENT_START expression, the presence of which
|
|
|
|
// changes the behaviour of -Ttext, -Tdata and -Tbss options.
|
|
|
|
bool
|
|
|
|
saw_segment_start_expression() const
|
|
|
|
{ return this->saw_segment_start_expression_; }
|
|
|
|
|
|
|
|
// Set the flag which indicates whether we saw a SEGMENT_START expression.
|
|
|
|
void
|
|
|
|
set_saw_segment_start_expression(bool value)
|
|
|
|
{ this->saw_segment_start_expression_ = value; }
|
|
|
|
|
2010-09-08 16:10:33 +00:00
|
|
|
// Add a memory region.
|
|
|
|
void
|
|
|
|
add_memory_region(const char*, size_t, unsigned int,
|
|
|
|
Expression*, Expression*);
|
|
|
|
|
|
|
|
// Find a memory region's origin.
|
|
|
|
Expression*
|
|
|
|
find_memory_region_origin(const char*, size_t);
|
|
|
|
|
|
|
|
// Find a memory region's length.
|
|
|
|
Expression*
|
|
|
|
find_memory_region_length(const char*, size_t);
|
|
|
|
|
2010-10-06 08:58:59 +00:00
|
|
|
// Find a memory region by name.
|
2010-09-08 16:10:33 +00:00
|
|
|
Memory_region*
|
|
|
|
find_memory_region(const char*, size_t);
|
|
|
|
|
2010-10-06 08:58:59 +00:00
|
|
|
// Find a memory region that should be used by a given output section.
|
|
|
|
Memory_region*
|
|
|
|
find_memory_region(Output_section_definition*, bool,
|
|
|
|
Output_section_definition**);
|
|
|
|
|
|
|
|
// Returns true if the provide block of memory is contained
|
|
|
|
// within a memory region.
|
|
|
|
bool
|
|
|
|
block_in_region(Symbol_table*, Layout*, uint64_t, uint64_t) const;
|
|
|
|
|
2010-09-08 16:10:33 +00:00
|
|
|
// Set the memory region of the section.
|
|
|
|
void
|
|
|
|
set_memory_region(Memory_region*, bool);
|
|
|
|
|
2008-01-23 01:31:13 +00:00
|
|
|
// Print the contents to the FILE. This is for debugging.
|
|
|
|
void
|
|
|
|
print(FILE*) const;
|
|
|
|
|
2009-03-19 05:51:49 +00:00
|
|
|
// Used for orphan sections.
|
|
|
|
typedef Sections_elements::iterator Elements_iterator;
|
2008-01-23 01:31:13 +00:00
|
|
|
|
2009-03-19 05:51:49 +00:00
|
|
|
private:
|
2010-09-08 16:10:33 +00:00
|
|
|
typedef std::vector<Memory_region*> Memory_regions;
|
2008-02-04 22:54:31 +00:00
|
|
|
typedef std::vector<Phdrs_element*> Phdrs_elements;
|
|
|
|
|
2008-02-04 05:43:05 +00:00
|
|
|
// Create segments.
|
|
|
|
Output_segment*
|
2010-04-23 04:47:33 +00:00
|
|
|
create_segments(Layout*, uint64_t);
|
2008-02-04 05:43:05 +00:00
|
|
|
|
|
|
|
// Create PT_NOTE and PT_TLS segments.
|
|
|
|
void
|
|
|
|
create_note_and_tls_segments(Layout*, const std::vector<Output_section*>*);
|
|
|
|
|
|
|
|
// Return whether the section is a BSS section.
|
|
|
|
static bool
|
|
|
|
is_bss_section(const Output_section*);
|
|
|
|
|
2008-02-04 22:54:31 +00:00
|
|
|
// Return the total size of the headers.
|
|
|
|
size_t
|
|
|
|
total_header_size(Layout* layout) const;
|
|
|
|
|
|
|
|
// Return the amount we have to subtract from the LMA to accomodate
|
|
|
|
// headers of the given size.
|
|
|
|
uint64_t
|
|
|
|
header_size_adjustment(uint64_t lma, size_t sizeof_headers) const;
|
|
|
|
|
|
|
|
// Create the segments from a PHDRS clause.
|
|
|
|
Output_segment*
|
2010-04-23 04:47:33 +00:00
|
|
|
create_segments_from_phdrs_clause(Layout* layout, uint64_t);
|
2008-02-04 22:54:31 +00:00
|
|
|
|
|
|
|
// Attach sections to segments from a PHDRS clause.
|
|
|
|
void
|
|
|
|
attach_sections_using_phdrs_clause(Layout*);
|
|
|
|
|
|
|
|
// Set addresses of segments from a PHDRS clause.
|
|
|
|
Output_segment*
|
2010-04-23 04:47:33 +00:00
|
|
|
set_phdrs_clause_addresses(Layout*, uint64_t);
|
2008-02-04 22:54:31 +00:00
|
|
|
|
2008-01-23 01:31:13 +00:00
|
|
|
// True if we ever saw a SECTIONS clause.
|
|
|
|
bool saw_sections_clause_;
|
|
|
|
// True if we are currently processing a SECTIONS clause.
|
|
|
|
bool in_sections_clause_;
|
|
|
|
// The list of elements in the SECTIONS clause.
|
|
|
|
Sections_elements* sections_elements_;
|
|
|
|
// The current output section, if there is one.
|
|
|
|
Output_section_definition* output_section_;
|
2010-09-08 16:10:33 +00:00
|
|
|
// The list of memory regions in the MEMORY clause.
|
|
|
|
Memory_regions* memory_regions_;
|
2008-02-04 22:54:31 +00:00
|
|
|
// The list of program headers in the PHDRS clause.
|
|
|
|
Phdrs_elements* phdrs_elements_;
|
2009-03-19 05:51:49 +00:00
|
|
|
// Where to put orphan sections.
|
|
|
|
Orphan_section_placement* orphan_section_placement_;
|
|
|
|
// A pointer to the last Sections_element when we see
|
2008-08-13 07:37:46 +00:00
|
|
|
// DATA_SEGMENT_ALIGN.
|
2009-03-19 05:51:49 +00:00
|
|
|
Sections_elements::iterator data_segment_align_start_;
|
|
|
|
// Whether we have seen DATA_SEGMENT_ALIGN.
|
|
|
|
bool saw_data_segment_align_;
|
2008-08-13 07:37:46 +00:00
|
|
|
// Whether we have seen DATA_SEGMENT_RELRO_END.
|
|
|
|
bool saw_relro_end_;
|
2009-10-16 Doug Kwan <dougkwan@google.com>
* expression.cc (class Segment_start_expression): New class definition.
(Segment_start_expression::value): New method definition.
(script_exp_function_segment_start): Return a new
Segment_start_expression.
* gold/script-c.h (script_saw_segment_start_expression): New function
prototype.
* script-sections.cc (Script_sections::Script_sections): Initialize
SAW_SEGMENT_START_EXPRESSION_ to false.
(Script_sections::set_section_addresses): Use -Ttext, -Tdata
and -Tbbs options to specify section addresses if given in
command line and no SEGMENT_START expression is seen in a script.
* script-sections.h (Script_sections::saw_segment_start_expression,
Script_sections::set_saw_segment_start_expression): New method
definition.
(Script_sections::saw_segment_start_expression_): New data member
declaration.
* script.cc (script_saw_segment_start_expression): New function.
* yyscript.y (SEGMENT_START): Call script_saw_segment_start_expression.
* testsuite/Makefile.am (check_SCRIPTS): Add script_test_6.sh,
script_test_7.sh and script_test_8.sh.
(check_DATA): Add script_test_6.stdout, script_test_7.stdout and
script_test_8.stdout.
(MOSTLYCLEANFILES): Add script_test_6, script_test_7 and script_test_8.
(script_test_6, script_test_6.stdout, script_test_7,
script_test_7.stdout, script_test_8, script_test_8.stdout): New rules.
* Makefile.in: Regenerate.
* testsuite/script_test_6.sh: New file.
* testsuite/script_test_6.t: Same.
* testsuite/script_test_7.sh: Same.
* testsuite/script_test_7.t: Same.
* testsuite/script_test_8.sh: Same.
2009-10-16 18:56:07 +00:00
|
|
|
// Whether we have seen SEGMENT_START.
|
|
|
|
bool saw_segment_start_expression_;
|
2008-01-23 01:31:13 +00:00
|
|
|
};
|
|
|
|
|
2010-09-08 16:10:33 +00:00
|
|
|
// Attributes for memory regions.
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
MEM_EXECUTABLE = (1 << 0),
|
|
|
|
MEM_WRITEABLE = (1 << 1),
|
|
|
|
MEM_READABLE = (1 << 2),
|
|
|
|
MEM_ALLOCATABLE = (1 << 3),
|
|
|
|
MEM_INITIALIZED = (1 << 4),
|
|
|
|
MEM_ATTR_MASK = (1 << 5) - 1
|
|
|
|
};
|
|
|
|
|
2008-01-23 01:31:13 +00:00
|
|
|
} // End namespace gold.
|
|
|
|
|
|
|
|
#endif // !defined(GOLD_SCRIPT_SECTIONS_H
|