binutils-gdb/ld/ldlang.h

625 lines
18 KiB
C
Raw Normal View History

1999-05-03 09:29:11 +02:00
/* ldlang.h - linker command language support
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2008-01-16 02:29:42 +01:00
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
Free Software Foundation, Inc.
2007-07-06 16:09:45 +02:00
This file is part of the GNU Binutils.
2007-07-06 16:09:45 +02:00
This program is free software; you can redistribute it and/or modify
1999-05-03 09:29:11 +02:00
it under the terms of the GNU General Public License as published by
2007-07-06 16:09:45 +02:00
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
2007-07-06 16:09:45 +02:00
This program is distributed in the hope that it will be useful,
1999-05-03 09:29:11 +02:00
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.
1999-05-03 09:29:11 +02:00
You should have received a copy of the GNU General Public License
2007-07-06 16:09:45 +02:00
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
1999-05-03 09:29:11 +02:00
#ifndef LDLANG_H
#define LDLANG_H
#define DEFAULT_MEMORY_REGION "*default*"
typedef enum
{
1999-05-03 09:29:11 +02:00
lang_input_file_is_l_enum,
lang_input_file_is_symbols_only_enum,
lang_input_file_is_marker_enum,
lang_input_file_is_fake_enum,
lang_input_file_is_search_file_enum,
lang_input_file_is_file_enum
} lang_input_file_enum_type;
struct _fill_type
{
Support arbitrary length fill patterns. * ldexp.h (etree_value_type): Add "str" field. (union etree_union): Add "str" to "value" struct. (exp_bigintop): Declare. (exp_get_fill): Declare. * ldexp.c: Include "safe-ctype.h". (exp_intop): Set value.str to NULL. (exp_bigintop): New function. (new_rel): Pass in "str", and set new.str from it. (new_rel_from_section): Set new.str to NULL. (fold_name): Adjust calls to new_rel. (exp_fold_tree): Likewise. (exp_get_fill): New function. * ldgram.y (struct big_int bigint, fill_type *fill): New. (INT): Returns a "bigint". Adjust all code handling INTs. (fill_opt): Returns a "fill". (fill_exp): Split out of fill_opt, use for FILL. * ldlang.h (struct _fill_type): New. (fill_type): Move typedef to ldexp.h. (lang_output_section_statement_type): "fill" is now a pointer. (lang_fill_statement_type): Likewise. (lang_padding_statement_type): Likewise. (lang_add_fill): Now takes a "fill_type *" param. (lang_leave_output_section_statement): Likewise. (lang_do_assignments): Likewise. (lang_size_sections): Likewise. (lang_leave_overlay_section): Likewise. (lang_leave_overlay): Likewise. * ldlang.c: Include ldgram.h after ldexp.h. (lang_output_section_statement_lookup): Adjust for fill_type change. (print_fill_statement): Likewise. (print_padding_statement): Likewise. (insert_pad): Now takes a "fill_type *" arg. (size_input_section): Likewise. (lang_size_sections_1): Likewise. (lang_size_sections): Likewise. (lang_do_assignments): Likewise. (lang_add_fill): Likewise. (lang_leave_output_section_statement): Likewise. (lang_leave_overlay_section): Likewise. (lang_leave_overlay): Likewise. Adjust all callers of the above function. * ldlex.l: Include ldgram.h after ldexp.h. Allow hex numbers starting with "0X" as well as "0x". Return bigint.str for hex numbers starting with "0x" or "0X", zero bigint.str otherwise. Always use base 16 for numbers starting with "$". * ldmain.c: Include ldgram.h after ldexp.h. * ldwrite.c (build_link_order): Use bfd_data_link_order in place of bfd_fill_link_order. * pe-dll.c: Adjust lang_do_assignments calls. * emultempl/elf32.em: Likewise. * emultempl/hppaelf.em: Likewise. * emultempl/ppc64elf.em: Likewise. * emultempl/beos.em: Include ldgram.h after ldexp.h, adjust lang_add_assignment call. * emultempl/pe.em: Likewise.
2002-02-15 03:11:05 +01:00
size_t size;
unsigned char data[1];
};
typedef struct statement_list
{
1999-05-03 09:29:11 +02:00
union lang_statement_union *head;
union lang_statement_union **tail;
} lang_statement_list_type;
typedef struct memory_region_struct
{
1999-05-03 09:29:11 +02:00
char *name;
struct memory_region_struct *next;
bfd_vma origin;
bfd_size_type length;
bfd_vma current;
union lang_statement_union *last_os;
1999-05-03 09:29:11 +02:00
flagword flags;
flagword not_flags;
bfd_boolean had_full_message;
} lang_memory_region_type;
typedef struct lang_statement_header_struct
{
union lang_statement_union *next;
enum statement_enum
{
lang_output_section_statement_enum,
lang_assignment_statement_enum,
lang_input_statement_enum,
lang_address_statement_enum,
lang_wild_statement_enum,
lang_input_section_enum,
lang_object_symbols_statement_enum,
lang_fill_statement_enum,
lang_data_statement_enum,
lang_reloc_statement_enum,
lang_target_statement_enum,
lang_output_statement_enum,
lang_padding_statement_enum,
lang_group_statement_enum,
lang_insert_statement_enum,
lang_constructors_statement_enum
} type;
1999-05-03 09:29:11 +02:00
} lang_statement_header_type;
typedef struct
{
1999-05-03 09:29:11 +02:00
lang_statement_header_type header;
union etree_union *exp;
} lang_assignment_statement_type;
typedef struct lang_target_statement_struct
{
1999-05-03 09:29:11 +02:00
lang_statement_header_type header;
const char *target;
} lang_target_statement_type;
typedef struct lang_output_statement_struct
{
1999-05-03 09:29:11 +02:00
lang_statement_header_type header;
const char *name;
} lang_output_statement_type;
/* Section types specified in a linker script. */
enum section_type
{
1999-05-03 09:29:11 +02:00
normal_section,
overlay_section,
1999-05-03 09:29:11 +02:00
noload_section,
noalloc_section
1999-05-03 09:29:11 +02:00
};
/* This structure holds a list of program headers describing
segments in which this section should be placed. */
1999-05-03 09:29:11 +02:00
typedef struct lang_output_section_phdr_list
{
1999-05-03 09:29:11 +02:00
struct lang_output_section_phdr_list *next;
const char *name;
bfd_boolean used;
} lang_output_section_phdr_list;
1999-05-03 09:29:11 +02:00
typedef struct lang_output_section_statement_struct
{
1999-05-03 09:29:11 +02:00
lang_statement_header_type header;
lang_statement_list_type children;
ld/ PR 63 * ldlang.h (lang_output_section_statement_type): Make "next" a struct lang_output_section_statement_struct *. (struct orphan_save): Move from elf32.em. Add "name" and "flags". (lang_output_section_find_by_flags, lang_insert_orphan): Declare. * ldlang.c (lang_output_section_find_1): Adjust for changed output_section_statement "next". (strip_excluded_output_sections): Likewise. (lang_record_phdrs): Likewise. (lang_output_section_find_by_flags): New function. (output_prev_sec_find): Move from pe.em. Adjust iterator. (lang_insert_orphan): New function. Tail end of elf32.em's place_orphan merged with that from pe.em. Allow bfd_section to be placed first. New heuristic for placing new output section statement in existing script, and accompanying split of __start symbol alignment into a separate assignment to dot. (lang_add_section): Consistently use output->bfd_section rather than an alias, section->output_section. (map_input_to_output_sections): Rename overly long arg. Move initialization of data_statement output section to here.. (lang_check_section_addresses): ..from here. (print_assignment): Correct printing of etree_assert. (print_all_symbols): Don't bomb if userdata is NULL. (IGNORE_SECTION): Rearrange. * emultempl/elf32.em (output_rel_find): Adjust interator. (output_prev_sec_find): Delete. (struct orphan_save): Delete. (gld${EMULATION_NAME}_place_orphan): Cater for zero bfd_section flags without creating a duplicate output section statement. Revise code holding history of various orphan section placements. Allow orphan sections to place before script specified output sections. Call lang_output_section_find_by_flags when placement by name fails. Use lang_insert_orphan. * emultempl/mmo.em (output_prev_sec_find): Delete. (struct orphan_save): Delete. (mmo_place_orphan): Revise code holding history of orphan placement. Allow orphans to place before existing output sections. Use lang_insert_orphan. * emultempl/pe.em (output_prev_sec_find): Delete. (struct orphan_save): Delete. (gld_${EMULATION_NAME}_place_orphan): Revise to suit use of lang_insert_orphan. ld/testsuite/ * ld-scripts/overlay-size.d: Update for changed orphan section placement. * ld-mmix/bpo-18.d: Likewise.
2004-10-14 14:54:47 +02:00
struct lang_output_section_statement_struct *next;
struct lang_output_section_statement_struct *prev;
1999-05-03 09:29:11 +02:00
const char *name;
asection *bfd_section;
lang_memory_region_type *region;
lang_memory_region_type *lma_region;
Support arbitrary length fill patterns. * ldexp.h (etree_value_type): Add "str" field. (union etree_union): Add "str" to "value" struct. (exp_bigintop): Declare. (exp_get_fill): Declare. * ldexp.c: Include "safe-ctype.h". (exp_intop): Set value.str to NULL. (exp_bigintop): New function. (new_rel): Pass in "str", and set new.str from it. (new_rel_from_section): Set new.str to NULL. (fold_name): Adjust calls to new_rel. (exp_fold_tree): Likewise. (exp_get_fill): New function. * ldgram.y (struct big_int bigint, fill_type *fill): New. (INT): Returns a "bigint". Adjust all code handling INTs. (fill_opt): Returns a "fill". (fill_exp): Split out of fill_opt, use for FILL. * ldlang.h (struct _fill_type): New. (fill_type): Move typedef to ldexp.h. (lang_output_section_statement_type): "fill" is now a pointer. (lang_fill_statement_type): Likewise. (lang_padding_statement_type): Likewise. (lang_add_fill): Now takes a "fill_type *" param. (lang_leave_output_section_statement): Likewise. (lang_do_assignments): Likewise. (lang_size_sections): Likewise. (lang_leave_overlay_section): Likewise. (lang_leave_overlay): Likewise. * ldlang.c: Include ldgram.h after ldexp.h. (lang_output_section_statement_lookup): Adjust for fill_type change. (print_fill_statement): Likewise. (print_padding_statement): Likewise. (insert_pad): Now takes a "fill_type *" arg. (size_input_section): Likewise. (lang_size_sections_1): Likewise. (lang_size_sections): Likewise. (lang_do_assignments): Likewise. (lang_add_fill): Likewise. (lang_leave_output_section_statement): Likewise. (lang_leave_overlay_section): Likewise. (lang_leave_overlay): Likewise. Adjust all callers of the above function. * ldlex.l: Include ldgram.h after ldexp.h. Allow hex numbers starting with "0X" as well as "0x". Return bigint.str for hex numbers starting with "0x" or "0X", zero bigint.str otherwise. Always use base 16 for numbers starting with "$". * ldmain.c: Include ldgram.h after ldexp.h. * ldwrite.c (build_link_order): Use bfd_data_link_order in place of bfd_fill_link_order. * pe-dll.c: Adjust lang_do_assignments calls. * emultempl/elf32.em: Likewise. * emultempl/hppaelf.em: Likewise. * emultempl/ppc64elf.em: Likewise. * emultempl/beos.em: Include ldgram.h after ldexp.h, adjust lang_add_assignment call. * emultempl/pe.em: Likewise.
2002-02-15 03:11:05 +01:00
fill_type *fill;
union etree_union *addr_tree;
1999-05-03 09:29:11 +02:00
union etree_union *load_base;
/* If non-null, an expression to evaluate after setting the section's
size. The expression is evaluated inside REGION (above) with '.'
set to the end of the section. Used in the last overlay section
to move '.' past all the overlaid sections. */
union etree_union *update_dot_tree;
lang_output_section_phdr_list *phdrs;
unsigned int block_value;
int subsection_alignment; /* Alignment of components. */
int section_alignment; /* Alignment of start of section. */
int constraint;
flagword flags;
enum section_type sectype;
unsigned int processed_vma : 1;
unsigned int processed_lma : 1;
unsigned int all_input_readonly : 1;
/* If this section should be ignored. */
unsigned int ignored : 1;
/* If there is a symbol relative to this section. */
unsigned int section_relative_symbol : 1;
1999-05-03 09:29:11 +02:00
} lang_output_section_statement_type;
typedef struct
{
1999-05-03 09:29:11 +02:00
lang_statement_header_type header;
} lang_common_statement_type;
typedef struct
{
1999-05-03 09:29:11 +02:00
lang_statement_header_type header;
} lang_object_symbols_statement_type;
typedef struct
{
1999-05-03 09:29:11 +02:00
lang_statement_header_type header;
Support arbitrary length fill patterns. * ldexp.h (etree_value_type): Add "str" field. (union etree_union): Add "str" to "value" struct. (exp_bigintop): Declare. (exp_get_fill): Declare. * ldexp.c: Include "safe-ctype.h". (exp_intop): Set value.str to NULL. (exp_bigintop): New function. (new_rel): Pass in "str", and set new.str from it. (new_rel_from_section): Set new.str to NULL. (fold_name): Adjust calls to new_rel. (exp_fold_tree): Likewise. (exp_get_fill): New function. * ldgram.y (struct big_int bigint, fill_type *fill): New. (INT): Returns a "bigint". Adjust all code handling INTs. (fill_opt): Returns a "fill". (fill_exp): Split out of fill_opt, use for FILL. * ldlang.h (struct _fill_type): New. (fill_type): Move typedef to ldexp.h. (lang_output_section_statement_type): "fill" is now a pointer. (lang_fill_statement_type): Likewise. (lang_padding_statement_type): Likewise. (lang_add_fill): Now takes a "fill_type *" param. (lang_leave_output_section_statement): Likewise. (lang_do_assignments): Likewise. (lang_size_sections): Likewise. (lang_leave_overlay_section): Likewise. (lang_leave_overlay): Likewise. * ldlang.c: Include ldgram.h after ldexp.h. (lang_output_section_statement_lookup): Adjust for fill_type change. (print_fill_statement): Likewise. (print_padding_statement): Likewise. (insert_pad): Now takes a "fill_type *" arg. (size_input_section): Likewise. (lang_size_sections_1): Likewise. (lang_size_sections): Likewise. (lang_do_assignments): Likewise. (lang_add_fill): Likewise. (lang_leave_output_section_statement): Likewise. (lang_leave_overlay_section): Likewise. (lang_leave_overlay): Likewise. Adjust all callers of the above function. * ldlex.l: Include ldgram.h after ldexp.h. Allow hex numbers starting with "0X" as well as "0x". Return bigint.str for hex numbers starting with "0x" or "0X", zero bigint.str otherwise. Always use base 16 for numbers starting with "$". * ldmain.c: Include ldgram.h after ldexp.h. * ldwrite.c (build_link_order): Use bfd_data_link_order in place of bfd_fill_link_order. * pe-dll.c: Adjust lang_do_assignments calls. * emultempl/elf32.em: Likewise. * emultempl/hppaelf.em: Likewise. * emultempl/ppc64elf.em: Likewise. * emultempl/beos.em: Include ldgram.h after ldexp.h, adjust lang_add_assignment call. * emultempl/pe.em: Likewise.
2002-02-15 03:11:05 +01:00
fill_type *fill;
1999-05-03 09:29:11 +02:00
int size;
asection *output_section;
} lang_fill_statement_type;
typedef struct
{
1999-05-03 09:29:11 +02:00
lang_statement_header_type header;
unsigned int type;
union etree_union *exp;
1999-05-03 09:29:11 +02:00
bfd_vma value;
asection *output_section;
bfd_vma output_offset;
1999-05-03 09:29:11 +02:00
} lang_data_statement_type;
/* Generate a reloc in the output file. */
typedef struct
{
1999-05-03 09:29:11 +02:00
lang_statement_header_type header;
/* Reloc to generate. */
bfd_reloc_code_real_type reloc;
/* Reloc howto structure. */
reloc_howto_type *howto;
/* Section to generate reloc against.
Exactly one of section and name must be NULL. */
1999-05-03 09:29:11 +02:00
asection *section;
/* Name of symbol to generate reloc against.
Exactly one of section and name must be NULL. */
1999-05-03 09:29:11 +02:00
const char *name;
/* Expression for addend. */
union etree_union *addend_exp;
/* Resolved addend. */
bfd_vma addend_value;
/* Output section where reloc should be performed. */
asection *output_section;
/* Offset within output section. */
bfd_vma output_offset;
1999-05-03 09:29:11 +02:00
} lang_reloc_statement_type;
typedef struct lang_input_statement_struct
{
1999-05-03 09:29:11 +02:00
lang_statement_header_type header;
/* Name of this file. */
const char *filename;
/* Name to use for the symbol giving address of text start.
Usually the same as filename, but for a file spec'd with
-l this is the -l switch itself rather than the filename. */
1999-05-03 09:29:11 +02:00
const char *local_sym_name;
1999-05-03 09:29:11 +02:00
bfd *the_bfd;
1999-05-03 09:29:11 +02:00
/* Point to the next file - whatever it is, wanders up and down
archives */
union lang_statement_union *next;
/* Point to the next file, but skips archive contents. */
union lang_statement_union *next_real_file;
const char *target;
unsigned int is_archive : 1;
1999-05-03 09:29:11 +02:00
/* 1 means search a set of directories for this file. */
unsigned int search_dirs_flag : 1;
/* 1 means this was found in a search directory marked as sysrooted,
if search_dirs_flag is false, otherwise, that it should be
searched in ld_sysroot before any other location, as long as it
starts with a slash. */
unsigned int sysrooted : 1;
1999-05-03 09:29:11 +02:00
/* 1 means this is base file of incremental load.
Do not load this file's text or data.
Also default text_start to after this file's bss. */
unsigned int just_syms_flag : 1;
1999-05-03 09:29:11 +02:00
/* Whether to search for this entry as a dynamic archive. */
unsigned int dynamic : 1;
1999-05-03 09:29:11 +02:00
/* Whether DT_NEEDED tags should be added for dynamic libraries in
DT_NEEDED tags from this entry. */
unsigned int add_needed : 1;
/* Whether this entry should cause a DT_NEEDED tag only when
satisfying references from regular files, or always. */
unsigned int as_needed : 1;
1999-05-03 09:29:11 +02:00
/* Whether to include the entire contents of an archive. */
unsigned int whole_archive : 1;
1999-05-03 09:29:11 +02:00
unsigned int loaded : 1;
unsigned int real : 1;
1999-05-03 09:29:11 +02:00
} lang_input_statement_type;
typedef struct
{
1999-05-03 09:29:11 +02:00
lang_statement_header_type header;
asection *section;
} lang_input_section_type;
1999-05-03 09:29:11 +02:00
typedef struct lang_wild_statement_struct lang_wild_statement_type;
typedef void (*callback_t) (lang_wild_statement_type *, struct wildcard_list *,
asection *, lang_input_statement_type *, void *);
typedef void (*walk_wild_section_handler_t) (lang_wild_statement_type *,
lang_input_statement_type *,
callback_t callback,
void *data);
typedef bfd_boolean (*lang_match_sec_type_func) (bfd *, const asection *,
bfd *, const asection *);
/* Binary search tree structure to efficiently sort sections by
name. */
typedef struct lang_section_bst
{
asection *section;
struct lang_section_bst *left;
struct lang_section_bst *right;
} lang_section_bst_type;
struct lang_wild_statement_struct
{
1999-05-03 09:29:11 +02:00
lang_statement_header_type header;
const char *filename;
bfd_boolean filenames_sorted;
struct wildcard_list *section_list;
bfd_boolean keep_sections;
1999-05-03 09:29:11 +02:00
lang_statement_list_type children;
walk_wild_section_handler_t walk_wild_section_handler;
struct wildcard_list *handler_data[4];
lang_section_bst_type *tree;
};
1999-05-03 09:29:11 +02:00
typedef struct lang_address_statement_struct
{
1999-05-03 09:29:11 +02:00
lang_statement_header_type header;
const char *section_name;
union etree_union *address;
const segment_type *segment;
1999-05-03 09:29:11 +02:00
} lang_address_statement_type;
typedef struct
{
1999-05-03 09:29:11 +02:00
lang_statement_header_type header;
bfd_vma output_offset;
size_t size;
asection *output_section;
Support arbitrary length fill patterns. * ldexp.h (etree_value_type): Add "str" field. (union etree_union): Add "str" to "value" struct. (exp_bigintop): Declare. (exp_get_fill): Declare. * ldexp.c: Include "safe-ctype.h". (exp_intop): Set value.str to NULL. (exp_bigintop): New function. (new_rel): Pass in "str", and set new.str from it. (new_rel_from_section): Set new.str to NULL. (fold_name): Adjust calls to new_rel. (exp_fold_tree): Likewise. (exp_get_fill): New function. * ldgram.y (struct big_int bigint, fill_type *fill): New. (INT): Returns a "bigint". Adjust all code handling INTs. (fill_opt): Returns a "fill". (fill_exp): Split out of fill_opt, use for FILL. * ldlang.h (struct _fill_type): New. (fill_type): Move typedef to ldexp.h. (lang_output_section_statement_type): "fill" is now a pointer. (lang_fill_statement_type): Likewise. (lang_padding_statement_type): Likewise. (lang_add_fill): Now takes a "fill_type *" param. (lang_leave_output_section_statement): Likewise. (lang_do_assignments): Likewise. (lang_size_sections): Likewise. (lang_leave_overlay_section): Likewise. (lang_leave_overlay): Likewise. * ldlang.c: Include ldgram.h after ldexp.h. (lang_output_section_statement_lookup): Adjust for fill_type change. (print_fill_statement): Likewise. (print_padding_statement): Likewise. (insert_pad): Now takes a "fill_type *" arg. (size_input_section): Likewise. (lang_size_sections_1): Likewise. (lang_size_sections): Likewise. (lang_do_assignments): Likewise. (lang_add_fill): Likewise. (lang_leave_output_section_statement): Likewise. (lang_leave_overlay_section): Likewise. (lang_leave_overlay): Likewise. Adjust all callers of the above function. * ldlex.l: Include ldgram.h after ldexp.h. Allow hex numbers starting with "0X" as well as "0x". Return bigint.str for hex numbers starting with "0x" or "0X", zero bigint.str otherwise. Always use base 16 for numbers starting with "$". * ldmain.c: Include ldgram.h after ldexp.h. * ldwrite.c (build_link_order): Use bfd_data_link_order in place of bfd_fill_link_order. * pe-dll.c: Adjust lang_do_assignments calls. * emultempl/elf32.em: Likewise. * emultempl/hppaelf.em: Likewise. * emultempl/ppc64elf.em: Likewise. * emultempl/beos.em: Include ldgram.h after ldexp.h, adjust lang_add_assignment call. * emultempl/pe.em: Likewise.
2002-02-15 03:11:05 +01:00
fill_type *fill;
1999-05-03 09:29:11 +02:00
} lang_padding_statement_type;
/* A group statement collects a set of libraries together. The
libraries are searched multiple times, until no new undefined
symbols are found. The effect is to search a group of libraries as
though they were a single library. */
typedef struct
{
1999-05-03 09:29:11 +02:00
lang_statement_header_type header;
lang_statement_list_type children;
} lang_group_statement_type;
typedef struct
{
lang_statement_header_type header;
const char *where;
bfd_boolean is_before;
} lang_insert_statement_type;
typedef union lang_statement_union
{
1999-05-03 09:29:11 +02:00
lang_statement_header_type header;
lang_wild_statement_type wild_statement;
lang_data_statement_type data_statement;
lang_reloc_statement_type reloc_statement;
lang_address_statement_type address_statement;
lang_output_section_statement_type output_section_statement;
lang_assignment_statement_type assignment_statement;
lang_input_statement_type input_statement;
lang_target_statement_type target_statement;
lang_output_statement_type output_statement;
lang_input_section_type input_section;
lang_common_statement_type common_statement;
lang_object_symbols_statement_type object_symbols_statement;
lang_fill_statement_type fill_statement;
lang_padding_statement_type padding_statement;
lang_group_statement_type group_statement;
lang_insert_statement_type insert_statement;
1999-05-03 09:29:11 +02:00
} lang_statement_union_type;
/* This structure holds information about a program header, from the
PHDRS command in the linker script. */
struct lang_phdr
{
1999-05-03 09:29:11 +02:00
struct lang_phdr *next;
const char *name;
unsigned long type;
bfd_boolean filehdr;
bfd_boolean phdrs;
1999-05-03 09:29:11 +02:00
etree_type *at;
etree_type *flags;
};
extern struct lang_phdr *lang_phdr_list;
1999-05-03 09:29:11 +02:00
/* This structure is used to hold a list of sections which may not
cross reference each other. */
typedef struct lang_nocrossref
{
1999-05-03 09:29:11 +02:00
struct lang_nocrossref *next;
const char *name;
} lang_nocrossref_type;
1999-05-03 09:29:11 +02:00
/* The list of nocrossref lists. */
struct lang_nocrossrefs
{
1999-05-03 09:29:11 +02:00
struct lang_nocrossrefs *next;
lang_nocrossref_type *list;
1999-05-03 09:29:11 +02:00
};
extern struct lang_nocrossrefs *nocrossref_list;
2001-01-14 05:36:35 +01:00
/* This structure is used to hold a list of input section names which
will not match an output section in the linker script. */
struct unique_sections
{
2001-01-14 05:36:35 +01:00
struct unique_sections *next;
const char *name;
};
/* This structure records symbols for which we need to keep track of
definedness for use in the DEFINED () test. */
struct lang_definedness_hash_entry
{
struct bfd_hash_entry root;
int iteration;
};
ld/ PR 63 * ldlang.h (lang_output_section_statement_type): Make "next" a struct lang_output_section_statement_struct *. (struct orphan_save): Move from elf32.em. Add "name" and "flags". (lang_output_section_find_by_flags, lang_insert_orphan): Declare. * ldlang.c (lang_output_section_find_1): Adjust for changed output_section_statement "next". (strip_excluded_output_sections): Likewise. (lang_record_phdrs): Likewise. (lang_output_section_find_by_flags): New function. (output_prev_sec_find): Move from pe.em. Adjust iterator. (lang_insert_orphan): New function. Tail end of elf32.em's place_orphan merged with that from pe.em. Allow bfd_section to be placed first. New heuristic for placing new output section statement in existing script, and accompanying split of __start symbol alignment into a separate assignment to dot. (lang_add_section): Consistently use output->bfd_section rather than an alias, section->output_section. (map_input_to_output_sections): Rename overly long arg. Move initialization of data_statement output section to here.. (lang_check_section_addresses): ..from here. (print_assignment): Correct printing of etree_assert. (print_all_symbols): Don't bomb if userdata is NULL. (IGNORE_SECTION): Rearrange. * emultempl/elf32.em (output_rel_find): Adjust interator. (output_prev_sec_find): Delete. (struct orphan_save): Delete. (gld${EMULATION_NAME}_place_orphan): Cater for zero bfd_section flags without creating a duplicate output section statement. Revise code holding history of various orphan section placements. Allow orphan sections to place before script specified output sections. Call lang_output_section_find_by_flags when placement by name fails. Use lang_insert_orphan. * emultempl/mmo.em (output_prev_sec_find): Delete. (struct orphan_save): Delete. (mmo_place_orphan): Revise code holding history of orphan placement. Allow orphans to place before existing output sections. Use lang_insert_orphan. * emultempl/pe.em (output_prev_sec_find): Delete. (struct orphan_save): Delete. (gld_${EMULATION_NAME}_place_orphan): Revise to suit use of lang_insert_orphan. ld/testsuite/ * ld-scripts/overlay-size.d: Update for changed orphan section placement. * ld-mmix/bpo-18.d: Likewise.
2004-10-14 14:54:47 +02:00
/* Used by place_orphan to keep track of orphan sections and statements. */
struct orphan_save {
const char *name;
flagword flags;
lang_output_section_statement_type *os;
asection **section;
lang_statement_union_type **stmt;
lang_output_section_statement_type **os_tail;
};
1999-05-03 09:29:11 +02:00
extern lang_output_section_statement_type *abs_output_section;
2000-04-25 07:14:16 +02:00
extern lang_statement_list_type lang_output_section_statement;
extern bfd_boolean lang_has_input_file;
1999-05-03 09:29:11 +02:00
extern etree_type *base;
extern lang_statement_list_type *stat_ptr;
extern bfd_boolean delete_output_file_on_failure;
1999-05-03 09:29:11 +02:00
extern struct bfd_sym_chain entry_symbol;
extern const char *entry_section;
extern bfd_boolean entry_from_cmdline;
extern lang_statement_list_type file_chain;
extern lang_statement_list_type input_file_chain;
1999-05-03 09:29:11 +02:00
extern int lang_statement_iteration;
2002-12-08 04:56:04 +01:00
extern void lang_init
2003-06-28 07:28:54 +02:00
(void);
extern void lang_finish
(void);
extern lang_memory_region_type *lang_memory_region_lookup
(const char *const, bfd_boolean);
extern lang_memory_region_type *lang_memory_region_default
2003-06-28 07:28:54 +02:00
(asection *);
2002-12-08 04:56:04 +01:00
extern void lang_map
2003-06-28 07:28:54 +02:00
(void);
2002-12-08 04:56:04 +01:00
extern void lang_set_flags
2003-06-28 07:28:54 +02:00
(lang_memory_region_type *, const char *, int);
2002-12-08 04:56:04 +01:00
extern void lang_add_output
2003-06-28 07:28:54 +02:00
(const char *, int from_script);
2000-04-25 07:14:16 +02:00
extern lang_output_section_statement_type *lang_enter_output_section_statement
2003-06-28 07:28:54 +02:00
(const char *output_section_statement_name,
etree_type *address_exp,
enum section_type sectype,
etree_type *align,
etree_type *subalign,
* ldgram.y (sect_constraint): New. (ONLY_IF_RO, ONLY_IF_RW): New tokens. (section): Add sect_constraint. Pass additional argument to lang_enter_output_section_statement. * mri.c (mri_draw_tree): Pass additional argument to lang_enter_output_section_statement. * emultempl/pe.em (place_orphan): Likewise. (output_prev_sec_find): Disregard output section statements with constraint == -1. * emultempl/mmo.em (output_prev_sec_find): Likewise. (mmo_place_orphan): Pass additional argument to lang_enter_output_section_statement. * emultempl/elf32.em (output_prev_sec_find): Disregard output section statements with constraint == -1. (place_orphan): Pass additional argument to lang_enter_output_section_statement. * ldlang.c (lang_enter_overlay_section): Likewise. (lang_output_section_find_1): New. (lang_output_section_find): Use it. (lang_output_section_statement_lookup_1): New. (lang_output_section_statement_lookup): Use it. (check_section_callback, check_input_sections): New. (map_input_to_output_sections): Check if all input sections are readonly if ONLY_IF_RO or ONLY_IF_RW was seen. (strip_excluded_output_sections): Disregard output section statements with constraint == -1. (lang_record_phdrs): Likewise. (lang_enter_output_section_statement): Add constraint argument. Use lang_output_section_statement_lookup_1. * ldlang.h (lang_output_section_statement_type): Add constraint and all_input_readonly fields. (lang_enter_output_section_statement): Adjust prototype. * ldlex.l (ONLY_IF_RO, ONLY_IF_RW): New tokens. * scripttempl/elf.sc (.eh_frame, .gcc_except_table): Move into text segment if all input sections are readonly.
2004-05-19 16:01:14 +02:00
etree_type *, int);
2002-12-08 04:56:04 +01:00
extern void lang_final
2003-06-28 07:28:54 +02:00
(void);
2002-12-08 04:56:04 +01:00
extern void lang_process
2003-06-28 07:28:54 +02:00
(void);
2002-12-08 04:56:04 +01:00
extern void lang_section_start
(const char *, union etree_union *, const segment_type *);
2002-12-08 04:56:04 +01:00
extern void lang_add_entry
2003-06-28 07:28:54 +02:00
(const char *, bfd_boolean);
extern void lang_default_entry
(const char *);
2002-12-08 04:56:04 +01:00
extern void lang_add_target
2003-06-28 07:28:54 +02:00
(const char *);
1999-05-03 09:29:11 +02:00
extern void lang_add_wild
2003-06-28 07:28:54 +02:00
(struct wildcard_spec *, struct wildcard_list *, bfd_boolean);
2002-12-08 04:56:04 +01:00
extern void lang_add_map
2003-06-28 07:28:54 +02:00
(const char *);
2002-12-08 04:56:04 +01:00
extern void lang_add_fill
2003-06-28 07:28:54 +02:00
(fill_type *);
extern lang_assignment_statement_type *lang_add_assignment
(union etree_union *);
2002-12-08 04:56:04 +01:00
extern void lang_add_attribute
2003-06-28 07:28:54 +02:00
(enum statement_enum);
2002-12-08 04:56:04 +01:00
extern void lang_startup
2003-06-28 07:28:54 +02:00
(const char *);
2002-12-08 04:56:04 +01:00
extern void lang_float
2003-06-28 07:28:54 +02:00
(bfd_boolean);
1999-05-03 09:29:11 +02:00
extern void lang_leave_output_section_statement
(fill_type *, const char *, lang_output_section_phdr_list *,
2003-06-28 07:28:54 +02:00
const char *);
2002-12-08 04:56:04 +01:00
extern void lang_abs_symbol_at_end_of
2003-06-28 07:28:54 +02:00
(const char *, const char *);
2002-12-08 04:56:04 +01:00
extern void lang_abs_symbol_at_beginning_of
2003-06-28 07:28:54 +02:00
(const char *, const char *);
2002-12-08 04:56:04 +01:00
extern void lang_statement_append
(lang_statement_list_type *, lang_statement_union_type *,
lang_statement_union_type **);
1999-05-03 09:29:11 +02:00
extern void lang_for_each_input_file
2003-06-28 07:28:54 +02:00
(void (*dothis) (lang_input_statement_type *));
1999-05-03 09:29:11 +02:00
extern void lang_for_each_file
2003-06-28 07:28:54 +02:00
(void (*dothis) (lang_input_statement_type *));
2002-12-08 04:56:04 +01:00
extern void lang_reset_memory_regions
2003-06-28 07:28:54 +02:00
(void);
extern void lang_do_assignments
* ld.h (lang_phase_type): Move to.. * ldexp.h: ..here. Add lang_mark_phase_enum. (node_type): Remove etree_undef and etree_unspec. (exp_data_seg): Delete. (struct ldexp_control, expld): New. (invalid, exp_mark_used_section): Delete. (exp_fold_tree, exp_get_vma, exp_get_value_int, exp_get_fill, exp_get_abs_int): Update prototypes. * ldexp.c (assigning_to_dot): Delete. (expld): Define. (make_abs): Operate directly on expld.result. Update all callers. (new_abs): Likewise. Return void. (new_rel_from_abs): Rename from new_rel_from_section. (new_rel, new_rel_from_abs): Operate on expld.result and return void. Update all callers. (fold_unary): Operate on expld.result and return void. Remove "current_section", "allocation_done", "dot", "dotp" and "mark_used" params. Update all callers. (fold_binary, fold_trinary, fold_name, exp_fold_tree_1): Likewise. (fold_unary <ALIGN_K>): Ensure alignment is absolute. (fold_unary <ABSOLUTE>): Use make_abs. (fold_unary <DATA_SEGMENT_END>): Evaluate mark_phase as for allocating_phase. (fold_binary <DATA_SEGMENT_ALIGN, DATA_SEGMENT_RELRO_END, >): Ditto. (fold_binary <'%','/'>): Don't error if marking. (fold_name <SIZEOF_HEADERS>): Don't call bfd_sizeof_headers when marking. (fold_name <NAME>): Remove FIXME; -R is handled correctly. Don't error when marking. (fold_name <ADDR, LOADADDR, SIZEOF>): Don't set SEC_KEEP. (exp_fold_tree_1): Don't error when marking. (exp_fold_tree_1 <etree_rel>): Evaluate in all phases except first. (exp_fold_tree_1 <etree_assign to dot>): Don't check for NULL current section, instead check for NULL dotp. (exp_fold_tree_1 <etree_provide>): Don't evaluate the assignment source unless the symbol is referenced and undefined. (exp_fold_tree): Remove "allocation_done" and "dot" params. Save params to expld. (exp_fold_tree_no_dot): Remove "current_section", "allocation_done and "mark_used" params. Save params to expld. Update all callers. (exp_assop): Do without temp var. (exp_print_tree <etree_undef>): Delete code. (exp_get_vma): Remove "allocation_done" param. Correct error return. (exp_get_fill, exp_get_abs_int): Likewise. (exp_get_value_int): Remove "allocation_done" param. (exp_mark_used_section): Delete. * ldgram.y (fill_exp): Update exp_get_fill call. (origin_spec, length_spec): Update exp_get_vma call. * ldlang.c (lang_init): Don't bother clearing lang_statement_iteration. (lang_mark_used_section_1, lang_mark_used_section): Delete. (strip_excluded_output_sections): Call one_lang_size_sections_pass in marking mode. Merge old lang_mark_used_section code. Correct handling of output sections with excluded input sections and data statements. Don't drop non-zero sized sections. Don't zap os->bfd_section. Do set SEC_EXCLUDE when appropriate. (print_output_section_statement): Update for changed ldexp.c interface. (print_assignment, lang_size_sections_1): Likewise. (lang_do_assignments_1, lang_enter_output_section_statement): Likewise. (lang_new_phdr, lang_record_phdrs): Likewise. (lang_size_sections): Likewise. (insert_pad): Use following statement if it is a pad, rather than creating a new one. (lang_size_sections_1 <lang_output_section_statement_enum>): Do process ignored output section to set vma and lma, but don't update dot for these sections. Don't error if marking. (lang_size_sections_1 <lang_assignment_statement_enum>): Don't update dot for ignored sections. (lang_size_sections_1 <lang_data_statement_enum>): Don't mark absolute section with SEC_ALLOC. (one_lang_size_sections_pass): New function. (lang_size_sections): Remove first five params. Set expld.phase on entry and exit. Use one_lang_size_sections_pass. (lang_do_assignments): Remove all params. Update all callers. (lang_reset_memory_regions): Clear os->processed for all output section statements. * ldlang.h (lang_do_assignments): Update prototype. (lang_size_sections): Likewise. (one_lang_size_sections_pass): Declare. * pe-dll.c (pe_dll_fill_sections, pe_exe_fill_sections): Update lang_size_sections and lang_do_assignments calls. * emultempl/elf32.em (layout_sections_again): Likewise. * emultempl/ppc64elf.em (ppc_before_allocation): Use one_lang_size_sections_pass.
2005-06-09 04:05:47 +02:00
(void);
1999-05-03 09:29:11 +02:00
2002-12-08 04:56:04 +01:00
#define LANG_FOR_EACH_INPUT_STATEMENT(statement) \
lang_input_statement_type *statement; \
for (statement = (lang_input_statement_type *) file_chain.head; \
statement != (lang_input_statement_type *) NULL; \
statement = (lang_input_statement_type *) statement->next) \
#define lang_output_section_find(NAME) \
lang_output_section_statement_lookup (NAME, 0, FALSE)
2002-12-08 04:56:04 +01:00
extern void lang_process
2003-06-28 07:28:54 +02:00
(void);
2002-12-08 04:56:04 +01:00
extern void ldlang_add_file
2003-06-28 07:28:54 +02:00
(lang_input_statement_type *);
ld/ PR 63 * ldlang.h (lang_output_section_statement_type): Make "next" a struct lang_output_section_statement_struct *. (struct orphan_save): Move from elf32.em. Add "name" and "flags". (lang_output_section_find_by_flags, lang_insert_orphan): Declare. * ldlang.c (lang_output_section_find_1): Adjust for changed output_section_statement "next". (strip_excluded_output_sections): Likewise. (lang_record_phdrs): Likewise. (lang_output_section_find_by_flags): New function. (output_prev_sec_find): Move from pe.em. Adjust iterator. (lang_insert_orphan): New function. Tail end of elf32.em's place_orphan merged with that from pe.em. Allow bfd_section to be placed first. New heuristic for placing new output section statement in existing script, and accompanying split of __start symbol alignment into a separate assignment to dot. (lang_add_section): Consistently use output->bfd_section rather than an alias, section->output_section. (map_input_to_output_sections): Rename overly long arg. Move initialization of data_statement output section to here.. (lang_check_section_addresses): ..from here. (print_assignment): Correct printing of etree_assert. (print_all_symbols): Don't bomb if userdata is NULL. (IGNORE_SECTION): Rearrange. * emultempl/elf32.em (output_rel_find): Adjust interator. (output_prev_sec_find): Delete. (struct orphan_save): Delete. (gld${EMULATION_NAME}_place_orphan): Cater for zero bfd_section flags without creating a duplicate output section statement. Revise code holding history of various orphan section placements. Allow orphan sections to place before script specified output sections. Call lang_output_section_find_by_flags when placement by name fails. Use lang_insert_orphan. * emultempl/mmo.em (output_prev_sec_find): Delete. (struct orphan_save): Delete. (mmo_place_orphan): Revise code holding history of orphan placement. Allow orphans to place before existing output sections. Use lang_insert_orphan. * emultempl/pe.em (output_prev_sec_find): Delete. (struct orphan_save): Delete. (gld_${EMULATION_NAME}_place_orphan): Revise to suit use of lang_insert_orphan. ld/testsuite/ * ld-scripts/overlay-size.d: Update for changed orphan section placement. * ld-mmix/bpo-18.d: Likewise.
2004-10-14 14:54:47 +02:00
extern lang_output_section_statement_type *lang_output_section_find_by_flags
(const asection *, lang_output_section_statement_type **,
lang_match_sec_type_func);
ld/ PR 63 * ldlang.h (lang_output_section_statement_type): Make "next" a struct lang_output_section_statement_struct *. (struct orphan_save): Move from elf32.em. Add "name" and "flags". (lang_output_section_find_by_flags, lang_insert_orphan): Declare. * ldlang.c (lang_output_section_find_1): Adjust for changed output_section_statement "next". (strip_excluded_output_sections): Likewise. (lang_record_phdrs): Likewise. (lang_output_section_find_by_flags): New function. (output_prev_sec_find): Move from pe.em. Adjust iterator. (lang_insert_orphan): New function. Tail end of elf32.em's place_orphan merged with that from pe.em. Allow bfd_section to be placed first. New heuristic for placing new output section statement in existing script, and accompanying split of __start symbol alignment into a separate assignment to dot. (lang_add_section): Consistently use output->bfd_section rather than an alias, section->output_section. (map_input_to_output_sections): Rename overly long arg. Move initialization of data_statement output section to here.. (lang_check_section_addresses): ..from here. (print_assignment): Correct printing of etree_assert. (print_all_symbols): Don't bomb if userdata is NULL. (IGNORE_SECTION): Rearrange. * emultempl/elf32.em (output_rel_find): Adjust interator. (output_prev_sec_find): Delete. (struct orphan_save): Delete. (gld${EMULATION_NAME}_place_orphan): Cater for zero bfd_section flags without creating a duplicate output section statement. Revise code holding history of various orphan section placements. Allow orphan sections to place before script specified output sections. Call lang_output_section_find_by_flags when placement by name fails. Use lang_insert_orphan. * emultempl/mmo.em (output_prev_sec_find): Delete. (struct orphan_save): Delete. (mmo_place_orphan): Revise code holding history of orphan placement. Allow orphans to place before existing output sections. Use lang_insert_orphan. * emultempl/pe.em (output_prev_sec_find): Delete. (struct orphan_save): Delete. (gld_${EMULATION_NAME}_place_orphan): Revise to suit use of lang_insert_orphan. ld/testsuite/ * ld-scripts/overlay-size.d: Update for changed orphan section placement. * ld-mmix/bpo-18.d: Likewise.
2004-10-14 14:54:47 +02:00
extern lang_output_section_statement_type *lang_insert_orphan
(asection *, const char *, int, lang_output_section_statement_type *,
* ldlang.h (lang_input_section_type): Remove "ifile" field. (lang_insert_orphan, lang_add_section): Update prototypes. * ldlang.c (lang_insert_orphan): Remove "file" param. (lang_add_section): Likewise. Update all callers. (wild_sort): Get an input section's bfd via "section->owner". (size_input_section): Access just_syms_flag via bfd usrdata. (lang_place_orphans): Update ldemul_place_orphan call. * ldemul.h (ldemul_place_orphan): Remove input_statement param. (struct ld_emulation_xfer_struct <place_orphan>): Likewise. * ldemul.c (ldemul_place_orphan): Likewise. * ldwrite.c (build_link_order): Access just_syms_flag via bfd usrdata. * emultempl/armelf.em (arm_elf_set_bfd_for_interworking): Likewise. * emultempl/beos.em (sort_by_file_name): Access bfd by section->owner. (sort_sections): Likewise. (place_orphan): Remove "file" param. Adjust lang_add_section call. * emultempl/elf32.em (place_orphan): Remove "file" param. Adjust lang_add_section and lang_insert_orphan calls. * emultempl/hppaelf.em (hppaelf_add_stub_section): Adjust lang_add_section call. (build_section_lists): Access just_syms_flag via bfd usrdata. * emultempl/m68hc1xelf.em (m68hc11elf_add_stub_section): Adjust lang_add_section call. * emultempl/mmo.em (mmo_place_orphan): Remove "file" param. Adjust lang_add_section and lang_insert_orphan calls. * emultempl/pe.em (place_orphan): Likewise. Access bfd via section owner. * emultempl/ppc64elf.em (ppc_add_stub_section): Adjust lang_add_section call. (build_toc_list): Access just_syms_flag via bfd usrdata. (build_section_lists): Likewise. * emultempl/xtensaelf.em (elf_xtensa_place_orphan): Remove "file" param. Adjust place_orphan call. (ld_build_required_section_dependence): Access bfd via section owner.
2005-11-17 01:10:05 +01:00
struct orphan_save *, etree_type *, lang_statement_list_type *);
1999-05-03 09:29:11 +02:00
extern lang_input_statement_type *lang_add_input_file
2003-06-28 07:28:54 +02:00
(const char *, lang_input_file_enum_type, const char *);
2002-12-08 04:56:04 +01:00
extern void lang_add_keepsyms_file
2003-06-28 07:28:54 +02:00
(const char *);
extern lang_output_section_statement_type *lang_output_section_statement_lookup
(const char *const, int, bfd_boolean);
2002-12-08 04:56:04 +01:00
extern void ldlang_add_undef
2003-06-28 07:28:54 +02:00
(const char *const);
2002-12-08 04:56:04 +01:00
extern void lang_add_output_format
2003-06-28 07:28:54 +02:00
(const char *, const char *, const char *, int);
2002-12-08 04:56:04 +01:00
extern void lang_list_init
2003-06-28 07:28:54 +02:00
(lang_statement_list_type *);
2002-12-08 04:56:04 +01:00
extern void lang_add_data
2003-06-28 07:28:54 +02:00
(int type, union etree_union *);
1999-05-03 09:29:11 +02:00
extern void lang_add_reloc
2003-06-28 07:28:54 +02:00
(bfd_reloc_code_real_type, reloc_howto_type *, asection *, const char *,
union etree_union *);
1999-05-03 09:29:11 +02:00
extern void lang_for_each_statement
2003-06-28 07:28:54 +02:00
(void (*) (lang_statement_union_type *));
extern void *stat_alloc
(size_t);
bfd/ * section.c (struct bfd_section): Replace link_order_head and link_order_tail with map_head and map_tail union. (STD_SECTION): Update. (_bfd_strip_section_from_output): Delete. * aoutx.h: Update throughout for above changes. * coff-ppc.c: Likewise. * cofflink.c: Likewise. * ecoff.c: Likewise. * elf-eh-frame.c: Likewise. * elf-m10300.c: Likewise. * elf.c: Likewise. * elf32-arm.c: Likewise. * elf32-cris.c: Likewise. * elf32-hppa.c: Likewise. * elf32-i386.c: Likewise. * elf32-m32r.c: Likewise. * elf32-m68hc1x.c: Likewise. * elf32-m68k.c: Likewise. * elf32-ppc.c: Likewise. * elf32-s390.c: Likewise. * elf32-sh.c: Likewise. * elf32-vax.c: Likewise. * elf32-xtensa.c: Likewise. * elf64-alpha.c: Likewise. * elf64-hppa.c: Likewise. * elf64-ppc.c: Likewise. * elf64-s390.c: Likewise. * elf64-sh64.c: Likewise. * elf64-x86-64.c: Likewise. * elflink.c: Likewise. * elfxx-ia64.c: Likewise. * elfxx-mips.c: Likewise. * elfxx-sparc.c: Likewise. * linker.c: Likewise. * merge.c: Likewise. * pdp11.c: Likewise. * xcofflink.c: Likewise. * elflink.c (bfd_boolean bfd_elf_size_dynsym_hash_dynstr): Split out from bfd_elf_size_dynamic_sections. * bfd-in.h (bfd_boolean bfd_elf_size_dynsym_hash_dynstr): Declare. * bfd-in2.h: Regenerate. ld/ * ldemul.c: Include bfdlink.h. (ldemul_before_allocation): Assume before_allocation is non-zero. (before_allocation_default): Call strip_excluded_output_sections. * ldlang.c (stripped_excluded_sections): New variable. (lang_add_section): Build input section list for each output section, attached via map_head and map_tail pointers. (strip_excluded_output_sections): Make global. Traverse the input section lists to find which output sections can go. Clear link_order pointers and set stripped_excluded_sections. (lang_process): Call strip_excluded_output_sections. * ldlang.h (strip_excluded_output_sections): Declare. * ldwrite.c: Update throuhout for link_order_head -> map_head change. * emultempl/aix.em (before_allocation): Call strip_excluded_output_sections. * emultempl/armcoff.em (before_allocation): Likewise. * emultempl/beos.em (before_allocation): Likewise. * emultempl/linux.em (before_allocation): Likewise. * emultempl/pe.em (before_allocation): Likewise. * emultempl/sunos.em (before_allocation): Likewise. * emultempl/elf32.em (before_allocation): Likewise. Call bfd_elf_size_dynsym_hash_dynstr too. * emultempl/lnk960.em (lnk960_before_allocation): Delete. (ld_lnk960): Use before_allocation_default.
2005-05-04 13:00:28 +02:00
extern void strip_excluded_output_sections
(void);
2002-12-08 04:56:04 +01:00
extern void dprint_statement
2003-06-28 07:28:54 +02:00
(lang_statement_union_type *, int);
* ld.h (lang_phase_type): Move to.. * ldexp.h: ..here. Add lang_mark_phase_enum. (node_type): Remove etree_undef and etree_unspec. (exp_data_seg): Delete. (struct ldexp_control, expld): New. (invalid, exp_mark_used_section): Delete. (exp_fold_tree, exp_get_vma, exp_get_value_int, exp_get_fill, exp_get_abs_int): Update prototypes. * ldexp.c (assigning_to_dot): Delete. (expld): Define. (make_abs): Operate directly on expld.result. Update all callers. (new_abs): Likewise. Return void. (new_rel_from_abs): Rename from new_rel_from_section. (new_rel, new_rel_from_abs): Operate on expld.result and return void. Update all callers. (fold_unary): Operate on expld.result and return void. Remove "current_section", "allocation_done", "dot", "dotp" and "mark_used" params. Update all callers. (fold_binary, fold_trinary, fold_name, exp_fold_tree_1): Likewise. (fold_unary <ALIGN_K>): Ensure alignment is absolute. (fold_unary <ABSOLUTE>): Use make_abs. (fold_unary <DATA_SEGMENT_END>): Evaluate mark_phase as for allocating_phase. (fold_binary <DATA_SEGMENT_ALIGN, DATA_SEGMENT_RELRO_END, >): Ditto. (fold_binary <'%','/'>): Don't error if marking. (fold_name <SIZEOF_HEADERS>): Don't call bfd_sizeof_headers when marking. (fold_name <NAME>): Remove FIXME; -R is handled correctly. Don't error when marking. (fold_name <ADDR, LOADADDR, SIZEOF>): Don't set SEC_KEEP. (exp_fold_tree_1): Don't error when marking. (exp_fold_tree_1 <etree_rel>): Evaluate in all phases except first. (exp_fold_tree_1 <etree_assign to dot>): Don't check for NULL current section, instead check for NULL dotp. (exp_fold_tree_1 <etree_provide>): Don't evaluate the assignment source unless the symbol is referenced and undefined. (exp_fold_tree): Remove "allocation_done" and "dot" params. Save params to expld. (exp_fold_tree_no_dot): Remove "current_section", "allocation_done and "mark_used" params. Save params to expld. Update all callers. (exp_assop): Do without temp var. (exp_print_tree <etree_undef>): Delete code. (exp_get_vma): Remove "allocation_done" param. Correct error return. (exp_get_fill, exp_get_abs_int): Likewise. (exp_get_value_int): Remove "allocation_done" param. (exp_mark_used_section): Delete. * ldgram.y (fill_exp): Update exp_get_fill call. (origin_spec, length_spec): Update exp_get_vma call. * ldlang.c (lang_init): Don't bother clearing lang_statement_iteration. (lang_mark_used_section_1, lang_mark_used_section): Delete. (strip_excluded_output_sections): Call one_lang_size_sections_pass in marking mode. Merge old lang_mark_used_section code. Correct handling of output sections with excluded input sections and data statements. Don't drop non-zero sized sections. Don't zap os->bfd_section. Do set SEC_EXCLUDE when appropriate. (print_output_section_statement): Update for changed ldexp.c interface. (print_assignment, lang_size_sections_1): Likewise. (lang_do_assignments_1, lang_enter_output_section_statement): Likewise. (lang_new_phdr, lang_record_phdrs): Likewise. (lang_size_sections): Likewise. (insert_pad): Use following statement if it is a pad, rather than creating a new one. (lang_size_sections_1 <lang_output_section_statement_enum>): Do process ignored output section to set vma and lma, but don't update dot for these sections. Don't error if marking. (lang_size_sections_1 <lang_assignment_statement_enum>): Don't update dot for ignored sections. (lang_size_sections_1 <lang_data_statement_enum>): Don't mark absolute section with SEC_ALLOC. (one_lang_size_sections_pass): New function. (lang_size_sections): Remove first five params. Set expld.phase on entry and exit. Use one_lang_size_sections_pass. (lang_do_assignments): Remove all params. Update all callers. (lang_reset_memory_regions): Clear os->processed for all output section statements. * ldlang.h (lang_do_assignments): Update prototype. (lang_size_sections): Likewise. (one_lang_size_sections_pass): Declare. * pe-dll.c (pe_dll_fill_sections, pe_exe_fill_sections): Update lang_size_sections and lang_do_assignments calls. * emultempl/elf32.em (layout_sections_again): Likewise. * emultempl/ppc64elf.em (ppc_before_allocation): Use one_lang_size_sections_pass.
2005-06-09 04:05:47 +02:00
extern void lang_size_sections
(bfd_boolean *, bfd_boolean);
extern void one_lang_size_sections_pass
(bfd_boolean *, bfd_boolean);
extern void lang_add_insert
(const char *, int);
2002-12-08 04:56:04 +01:00
extern void lang_enter_group
2003-06-28 07:28:54 +02:00
(void);
2002-12-08 04:56:04 +01:00
extern void lang_leave_group
2003-06-28 07:28:54 +02:00
(void);
extern void lang_add_section
2003-06-28 07:28:54 +02:00
(lang_statement_list_type *, asection *,
* ldlang.h (lang_input_section_type): Remove "ifile" field. (lang_insert_orphan, lang_add_section): Update prototypes. * ldlang.c (lang_insert_orphan): Remove "file" param. (lang_add_section): Likewise. Update all callers. (wild_sort): Get an input section's bfd via "section->owner". (size_input_section): Access just_syms_flag via bfd usrdata. (lang_place_orphans): Update ldemul_place_orphan call. * ldemul.h (ldemul_place_orphan): Remove input_statement param. (struct ld_emulation_xfer_struct <place_orphan>): Likewise. * ldemul.c (ldemul_place_orphan): Likewise. * ldwrite.c (build_link_order): Access just_syms_flag via bfd usrdata. * emultempl/armelf.em (arm_elf_set_bfd_for_interworking): Likewise. * emultempl/beos.em (sort_by_file_name): Access bfd by section->owner. (sort_sections): Likewise. (place_orphan): Remove "file" param. Adjust lang_add_section call. * emultempl/elf32.em (place_orphan): Remove "file" param. Adjust lang_add_section and lang_insert_orphan calls. * emultempl/hppaelf.em (hppaelf_add_stub_section): Adjust lang_add_section call. (build_section_lists): Access just_syms_flag via bfd usrdata. * emultempl/m68hc1xelf.em (m68hc11elf_add_stub_section): Adjust lang_add_section call. * emultempl/mmo.em (mmo_place_orphan): Remove "file" param. Adjust lang_add_section and lang_insert_orphan calls. * emultempl/pe.em (place_orphan): Likewise. Access bfd via section owner. * emultempl/ppc64elf.em (ppc_add_stub_section): Adjust lang_add_section call. (build_toc_list): Access just_syms_flag via bfd usrdata. (build_section_lists): Likewise. * emultempl/xtensaelf.em (elf_xtensa_place_orphan): Remove "file" param. Adjust place_orphan call. (ld_build_required_section_dependence): Access bfd via section owner.
2005-11-17 01:10:05 +01:00
lang_output_section_statement_type *);
1999-05-03 09:29:11 +02:00
extern void lang_new_phdr
2003-06-28 07:28:54 +02:00
(const char *, etree_type *, bfd_boolean, bfd_boolean, etree_type *,
etree_type *);
2002-12-08 04:56:04 +01:00
extern void lang_add_nocrossref
(lang_nocrossref_type *);
2002-12-08 04:56:04 +01:00
extern void lang_enter_overlay
(etree_type *, etree_type *);
2002-12-08 04:56:04 +01:00
extern void lang_enter_overlay_section
2003-06-28 07:28:54 +02:00
(const char *);
1999-05-03 09:29:11 +02:00
extern void lang_leave_overlay_section
(fill_type *, lang_output_section_phdr_list *);
1999-05-03 09:29:11 +02:00
extern void lang_leave_overlay
2003-06-28 07:28:54 +02:00
(etree_type *, int, fill_type *, const char *,
lang_output_section_phdr_list *, const char *);
1999-05-03 09:29:11 +02:00
extern struct bfd_elf_version_tree *lang_elf_version_info;
extern struct bfd_elf_version_expr *lang_new_vers_pattern
(struct bfd_elf_version_expr *, const char *, const char *, bfd_boolean);
1999-05-03 09:29:11 +02:00
extern struct bfd_elf_version_tree *lang_new_vers_node
2003-06-28 07:28:54 +02:00
(struct bfd_elf_version_expr *, struct bfd_elf_version_expr *);
1999-05-03 09:29:11 +02:00
extern struct bfd_elf_version_deps *lang_add_vers_depend
2003-06-28 07:28:54 +02:00
(struct bfd_elf_version_deps *, const char *);
1999-05-03 09:29:11 +02:00
extern void lang_register_vers_node
2003-06-28 07:28:54 +02:00
(const char *, struct bfd_elf_version_tree *, struct bfd_elf_version_deps *);
bfd/ 2006-09-07 H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (elf_link_hash_entry): Add a dynamic field. (bfd_elf_link_mark_dynamic_symbol): New. (SYMBOLIC_BIND): New. * elf32-i386.c (elf_i386_check_relocs): Replace info->symbolic with SYMBOLIC_BIND (info, h). (elf_i386_relocate_section): Likewise. * elf64-x86-64.c (elf64_x86_64_check_relocs): Likewise. (elf64_x86_64_relocate_section): Likewise. * elfxx-ia64.c (elfNN_ia64_check_relocs): Likewise. * elflink.c (bfd_elf_link_mark_dynamic_symbol): New. (bfd_elf_record_link_assignment): Call bfd_elf_link_mark_dynamic_symbol on new entry. (_bfd_elf_merge_symbol): Likewise. (_bfd_elf_export_symbol): Return if the symbol isn't exported. (_bfd_elf_fix_symbol_flags): Replace info->symbolic with SYMBOLIC_BIND (info, h). (_bfd_elf_dynamic_symbol_p): Likewise. (_bfd_elf_symbol_refs_local_p): Likewise. (bfd_elf_size_dynamic_sections): Updated. include/ 2006-09-07 H.J. Lu <hongjiu.lu@intel.com> * bfdlink.h (bfd_elf_dynamic_list): New. (bfd_link_info): Add a dynamic field. ld/ 2006-09-07 H.J. Lu <hongjiu.lu@intel.com> * Makefile.am (CXX): Set to g++. (CXX_FOR_TARGET): Likewise. * Makefile.in: Regenerated. * NEWS: Mention --dynamic-list. * ld.texinfo: Document --dynamic-list. * ldgram.y: Support dynamic list. * ldlang.c (lang_process): Call lang_finalize_version_expr_head on link_info.dynamic if needed. (lang_append_dynamic_list): New. (lang_append_dynamic_list_cpp_typeinfo): New. * ldlang.h (lang_append_dynamic_list): Likewise. * ldlang.h (lang_append_dynamic_list_cpp_typeinfo): Likewise. * ldlex.h (input_enum): Add input_dynamic_list. * ldlex.l: Handle it. * ldmain.c (main): Initialize link_info.dynamic. * lexsup.c (option_values): Add OPTION_DYNAMIC_LIST and OPTION_DYNAMIC_LIST_CPP_TYPEINFO. (ld_options): Add entries for OPTION_DYNAMIC_LIST and OPTION_DYNAMIC_LIST_CPP_TYPEINFO. (parse_args): Handle OPTION_DYNAMIC_LIST and OPTION_DYNAMIC_LIST_CPP_TYPEINFO. ld/testsuite/ 2006-09-07 H.J. Lu <hongjiu.lu@intel.com> * ld-elf/dl1.c: New file. * ld-elf/dl1.list: Likewise. * ld-elf/dl1.out: Likewise. * ld-elf/dl1main.c: Likewise. * ld-elf/dl2.c: Likewise. * ld-elf/dl2.list: Likewise. * ld-elf/dl2a.out: Likewise. * ld-elf/dl2b.out: Likewise. * ld-elf/dl2main.c: Likewise. * ld-elf/dl2xxx.c: Likewise. * ld-elf/dl2xxx.list: Likewise. * ld-elf/dl3.cc: Likewise. * ld-elf/dl3.list: Likewise. * ld-elf/dl3a.out: Likewise. * ld-elf/dl3b.out: Likewise. * ld-elf/dl3header.h: Likewise. * ld-elf/dl3main.cc: Likewise. * ld-elf/shared.exp: Updated. * lib/ld-lib.exp (run_ld_link_exec_tests): Take an optional argument for source language. Use CC/CXX for link, depending on source language. (run_cc_link_tests): Likewise.
2006-09-07 19:16:34 +02:00
extern void lang_append_dynamic_list (struct bfd_elf_version_expr *);
extern void lang_append_dynamic_list_cpp_typeinfo (void);
bfd/ 2007-01-16 H.J. Lu <hongjiu.lu@intel.com> PR ld/3831 * elf-bfd.h (bfd_elf_link_mark_dynamic_symbol): Add an argument, Elf_Internal_Sym *. * elflink.c (bfd_elf_link_mark_dynamic_symbol): Mark a data symbol dynamic if info->dynamic_data is TRUE. (bfd_elf_record_link_assignment): Updated call to bfd_elf_record_link_assignment. (_bfd_elf_merge_symbol): Likewise. Always call bfd_elf_link_mark_dynamic_symbol. include/ 2007-01-16 H.J. Lu <hongjiu.lu@intel.com> PR ld/3831 * bfdlink.h (bfd_link_info): Rename dynamic to dynamic_list. Add dynamic and dynamic_data. ld/ 2007-01-16 H.J. Lu <hongjiu.lu@intel.com> PR ld/3831 * NEWS: Mention -Bsymbolic-functions, --dynamic-list-data and --dynamic-list-cpp-new. * ld.texinfo: Document -Bsymbolic-functions, --dynamic-list-data and --dynamic-list-cpp-new. * ldlang.c (lang_append_dynamic_list_cpp_new): New. (lang_process): Change link_info.dynamic to link_info.dynamic_list. (lang_append_dynamic_list): Likewise. * ldmain.c (main): Likewise. Initialize link_info.dynamic and link_info.dynamic_data to FALSE. * ldlang.h (lang_append_dynamic_list_cpp_new): New. * lexsup.c (option_values): Add OPTION_DYNAMIC_LIST_DATA and OPTION_DYNAMIC_LIST_CPP_NEW. (ld_options): Add entries for -Bsymbolic-functions, --dynamic-list-data and --dynamic-list-cpp-new. Make -Bsymbolic-functions an alias of --dynamic-list-data. (parse_args): Change link_info.dynamic to link_info.dynamic_list. Set link_info.dynamic to TRUE for --dynamic-list and --dynamic-list-cpp-typeinfo. Handle --dynamic-list-data and --dynamic-list-cpp-new. ld/testsuite/ 2007-01-16 H.J. Lu <hongjiu.lu@intel.com> PR ld/3831 * ld-elf/del.cc: New. * ld-elf/dl5.cc: Likewise. * ld-elf/dl5.out: Likewise. * ld-elf/new.cc: Likewise. * ld-elf/shared.exp: Add tests for --dynamic-list-data and --dynamic-list-cpp-new.
2007-01-16 15:56:32 +01:00
extern void lang_append_dynamic_list_cpp_new (void);
2002-12-08 04:56:04 +01:00
extern void lang_add_unique
2003-06-28 07:28:54 +02:00
(const char *);
2002-12-08 04:56:04 +01:00
extern const char *lang_get_output_target
2003-06-28 07:28:54 +02:00
(void);
extern void lang_track_definedness (const char *);
extern int lang_symbol_definition_iteration (const char *);
extern void lang_update_definedness
(const char *, struct bfd_link_hash_entry *);
1999-05-03 09:29:11 +02:00
extern void add_excluded_libs (const char *);
2006-10-25 08:49:21 +02:00
extern bfd_boolean load_symbols
(lang_input_statement_type *, lang_statement_list_type *);
extern bfd_boolean
ldlang_override_segment_assignment
(struct bfd_link_info *, bfd *, asection *, asection *, bfd_boolean);
1999-05-03 09:29:11 +02:00
#endif