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. */
include it, so that they can communicate back and forth. */
#ifndef GOLD_SCRIPT_C_H
#define GOLD_SCRIPT_C_H
#ifdef __cplusplus
#include <vector>
#include <string>
#endif
#ifdef __cplusplus
namespace gold
{
#endif
struct Parser_string
{
const char* value;
size_t length;
};
Since the bison parser generates C code, this is a hack to keep the
C++ code type safe. This hacks assumes that all pointers look
alike. */
#ifdef __cplusplus
class Expression;
typedef Expression* Expression_ptr;
#else
typedef void* Expression_ptr;
#endif
enum Script_section_type
{
SCRIPT_SECTION_TYPE_NONE,
SCRIPT_SECTION_TYPE_NOLOAD,
SCRIPT_SECTION_TYPE_DSECT,
SCRIPT_SECTION_TYPE_COPY,
SCRIPT_SECTION_TYPE_INFO,
SCRIPT_SECTION_TYPE_OVERLAY
};
definition. */
enum Section_constraint
{
CONSTRAINT_NONE,
CONSTRAINT_ONLY_IF_RO,
CONSTRAINT_ONLY_IF_RW,
CONSTRAINT_SPECIAL
};
parser. */
struct Parser_output_section_header
{
Expression_ptr address;
enum Script_section_type section_type;
Expression_ptr load_address;
Expression_ptr align;
may be NULL. */
Expression_ptr subalign;
enum Section_constraint constraint;
};
C++, we use a pointer to a vector. This assumes that all pointers
look the same. */
#ifdef __cplusplus
typedef std::vector<std::string> String_list;
typedef String_list* String_list_ptr;
#else
typedef void* String_list_ptr;
#endif
parser. */
struct Parser_output_section_trailer
{
Expression_ptr fill;
NULL. */
String_list_ptr phdrs;
};
enum Sort_wildcard
{
SORT_WILDCARD_NONE,
SORT_WILDCARD_BY_NAME,
SORT_WILDCARD_BY_ALIGNMENT,
SORT_WILDCARD_BY_NAME_BY_ALIGNMENT,
SORT_WILDCARD_BY_ALIGNMENT_BY_NAME
};
struct Wildcard_section
{
struct Parser_string name;
enum Sort_wildcard sort;
};
#ifdef __cplusplus
typedef std::vector<Wildcard_section> String_sort_list;
typedef String_sort_list* String_sort_list_ptr;
#else
typedef void* String_sort_list_ptr;
#endif
clauses. */
struct Wildcard_sections
{
String_sort_list_ptr sections;
String_list_ptr exclude;
};
struct Input_section_spec
{
struct Wildcard_section file;
struct Wildcard_sections input_sections;
};
struct Phdr_info
{
int includes_filehdr;
int includes_phdrs;
int is_flags_valid;
unsigned int flags;
Expression_ptr load_address;
};
struct Version_dependency_list;
struct Version_expression_list;
struct Version_tree;
#ifdef __cplusplus
extern "C" {
#endif
#include "yyscript.h"
extern int
yyparse(void* closure);
extern int
yylex(YYSTYPE*, void* closure);
extern void
yyerror(void* closure, const char*);
an EXTERN declaration) to the link. */
extern void
script_add_extern(void* closure, const char*, size_t);
extern void
script_add_file(void* closure, const char*, size_t);
extern void
script_add_library(void* closure, const char*, size_t);
extern void
script_start_group(void* closure);
extern void
script_end_group(void* closure);
extern void
script_start_as_needed(void* closure);
extern void
script_end_as_needed(void* closure);
extern void
script_set_entry(void* closure, const char*, size_t);
extern void
script_set_common_allocation(void* closure, int);
extern void
script_parse_option(void* closure, const char*, size_t);
if the parse should be aborted. */
extern int
script_check_output_format(void* closure, const char*, size_t,
const char*, size_t, const char*, size_t);
extern void
script_set_target(void* closure, const char*, size_t);
extern void
script_add_search_dir(void* closure, const char*, size_t);
mode. */
extern void
script_push_lex_into_expression_mode(void* closure);
mode. */
extern void
script_push_lex_into_version_mode(void* closure);
extern void
script_pop_lex_mode(void* closure);
called for a reference to a symbol, but is not called for something
like "sym += 10". Uses of the special symbol "." can just call
script_exp_string. */
extern Expression_ptr
script_symbol(void* closure, const char*, size_t);
non-zero if the symbol should be provided--only defined if there is
an undefined reference. HIDDEN is non-zero if the symbol should be
hidden. */
extern void
script_set_symbol(void* closure, const char*, size_t, Expression_ptr,
int provide, int hidden);
extern void
script_add_assertion(void* closure, Expression_ptr, const char* message,
size_t messagelen);
extern void
script_start_sections(void* closure);
extern void
script_finish_sections(void* closure);
specifications for an output section. */
extern void
script_start_output_section(void* closure, const char* name, size_t namelen,
const struct Parser_output_section_header*);
specifications for an output section. */
extern void
script_finish_output_section(void* closure,
const struct Parser_output_section_trailer*);
etc.) in an output section. */
extern void
script_add_data(void* closure, int data_token, Expression_ptr val);
section. */
extern void
script_add_fill(void* closure, Expression_ptr val);
an output section. The KEEP parameter is non-zero if this is
within a KEEP clause, meaning that the garbage collector should not
discard it. */
extern void
script_add_input_section(void* closure, const struct Input_section_spec*,
int keep);
extern String_sort_list_ptr
script_new_string_sort_list(const struct Wildcard_section*);
extern String_sort_list_ptr
script_string_sort_list_add(String_sort_list_ptr,
const struct Wildcard_section*);
extern String_list_ptr
script_new_string_list(const char*, size_t);
extern String_list_ptr
script_string_list_push_back(String_list_ptr, const char*, size_t);
extern String_list_ptr
script_string_list_append(String_list_ptr, String_list_ptr);
extern void
script_add_phdr(void* closure, const char* name, size_t namelen,
unsigned int type, const struct Phdr_info*);
extern unsigned int
script_phdr_string_to_type(void* closure, const char*, size_t);
extern void
script_data_segment_align(void* closure);
extern void
script_data_segment_relro_end(void* closure);
extern void
script_saw_segment_start_expression(void* closure);
extern void
script_add_memory(void*, const char*, size_t, unsigned int,
Expression_ptr, Expression_ptr);
extern unsigned int
script_parse_memory_attr(void*, const char*, size_t, int);
extern void
script_set_section_region(void*, const char*, size_t, int);
extern void
script_include_directive(void *, const char*, size_t);
extern Expression_ptr
script_exp_unary_minus(Expression_ptr);
extern Expression_ptr
script_exp_unary_logical_not(Expression_ptr);
extern Expression_ptr
script_exp_unary_bitwise_not(Expression_ptr);
extern Expression_ptr
script_exp_binary_mult(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_div(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_mod(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_add(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_sub(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_lshift(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_rshift(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_eq(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_ne(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_le(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_ge(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_lt(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_gt(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_bitwise_and(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_bitwise_xor(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_bitwise_or(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_logical_and(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_binary_logical_or(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_trinary_cond(Expression_ptr, Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_integer(uint64_t);
extern Expression_ptr
script_exp_string(const char*, size_t);
extern Expression_ptr
script_exp_function_max(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_function_min(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_function_defined(const char*, size_t);
extern Expression_ptr
script_exp_function_sizeof_headers(void);
extern Expression_ptr
script_exp_function_alignof(const char*, size_t);
extern Expression_ptr
script_exp_function_sizeof(const char*, size_t);
extern Expression_ptr
script_exp_function_addr(const char*, size_t);
extern Expression_ptr
script_exp_function_loadaddr(const char*, size_t);
extern Expression_ptr
script_exp_function_origin(void*, const char*, size_t);
extern Expression_ptr
script_exp_function_length(void*, const char*, size_t);
extern Expression_ptr
script_exp_function_constant(const char*, size_t);
extern Expression_ptr
script_exp_function_absolute(Expression_ptr);
extern Expression_ptr
script_exp_function_align(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_function_data_segment_align(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_function_data_segment_relro_end(Expression_ptr, Expression_ptr);
extern Expression_ptr
script_exp_function_data_segment_end(Expression_ptr);
extern Expression_ptr
script_exp_function_segment_start(const char*, size_t, Expression_ptr);
extern Expression_ptr
script_exp_function_assert(Expression_ptr, const char*, size_t);
extern void
script_register_vers_node(void* closure,
const char* tag,
int taglen,
struct Version_tree*,
struct Version_dependency_list*);
extern struct Version_dependency_list*
script_add_vers_depend(void* closure,
struct Version_dependency_list* existing_dependencies,
const char* depend_to_add, int deplen);
extern struct Version_expression_list*
script_new_vers_pattern(void* closure,
struct Version_expression_list*,
const char*, int, int);
extern struct Version_expression_list*
script_merge_expressions(struct Version_expression_list* a,
struct Version_expression_list* b);
extern struct Version_tree*
script_new_vers_node(void* closure,
struct Version_expression_list* global,
struct Version_expression_list* local);
extern void
version_script_push_lang(void* closure, const char* lang, int langlen);
extern void
version_script_pop_lang(void* closure);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
}
#endif
#endif