Fix support for NOLOAD, add INCLUDE

* ldfile.c (ldfile_open_command_file): pass file name to
	lex_push_file.
	* ldlex.l, ldgram.y: tidy up, parse INCLUDE and NOLOAD
	* ldlang.c (wild_doit): make output sections inherit NEVER_LOAD
	attribute.
This commit is contained in:
Steve Chamberlain
1993-01-08 22:42:42 +00:00
parent c1d53021ae
commit dadd414a89
3 changed files with 112 additions and 73 deletions

View File

@ -1,3 +1,21 @@
Fri Jan 8 14:39:07 1993 Steve Chamberlain (sac@thepub.cygnus.com)
Fix support for NOLOAD, add INCLUDE
* ldfile.c (ldfile_open_command_file): pass file name to
lex_push_file.
* ldlex.l, ldgram.y: tidy up, parse INCLUDE and NOLOAD
* ldlang.c (wild_doit): make output sections inherit NEVER_LOAD
attribute.
Thu Jan 7 10:22:19 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
* Makefile.in, config.h: no more default emulation. Make the lack
of emulation a compile time error
Wed Jan 6 01:08:37 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
* configure.in: recognise all sparclite variants, not just 'sparclite'
Mon Dec 28 11:15:35 1992 Ian Lance Taylor (ian@cygnus.com) Mon Dec 28 11:15:35 1992 Ian Lance Taylor (ian@cygnus.com)
* m68kcoff.sc-sh: define _end as well as end, for consistency with * m68kcoff.sc-sh: define _end as well as end, for consistency with

View File

@ -44,7 +44,7 @@ extern boolean trace_files;
extern boolean write_map; extern boolean write_map;
extern boolean option_longmap; extern boolean option_longmap;
boolean hex_mode; boolean hex_mode;
static int typebits;
strip_symbols_type strip_symbols=STRIP_NONE; strip_symbols_type strip_symbols=STRIP_NONE;
discard_locals_type discard_locals=DISCARD_NONE; discard_locals_type discard_locals=DISCARD_NONE;
@ -58,7 +58,7 @@ lang_output_section_statement_type *lang_output_section_statement_lookup();
#ifdef __STDC__ #ifdef __STDC__
void lang_add_data(int type, union etree_union *exp); void lang_add_data(int type, union etree_union *exp);
void lang_enter_output_section_statement(char *output_section_statement_name, etree_type *address_exp, int flags, bfd_vma block_value); void lang_enter_output_section_statement(char *output_section_statement_name, etree_type *address_exp, int flags, bfd_vma block_value,etree_type*,etree_type*);
#else #else
@ -103,8 +103,8 @@ struct sec *section;
} }
%type <etree> exp opt_exp mustbe_exp %type <etree> exp opt_exp_with_type mustbe_exp
%type <integer> fill_opt opt_block opt_type %type <integer> fill_opt
%type <name> memspec_opt %type <name> memspec_opt
%token <integer> INT %token <integer> INT
%token <name> NAME %token <name> NAME
@ -133,6 +133,7 @@ struct sec *section;
%token '{' '}' %token '{' '}'
%token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH %token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH
%token SIZEOF_HEADERS %token SIZEOF_HEADERS
%token INCLUDE
%token MEMORY DEFSYMEND %token MEMORY DEFSYMEND
%token NOLOAD DSECT COPY INFO OVERLAY %token NOLOAD DSECT COPY INFO OVERLAY
%token NAME DEFINED TARGET_K SEARCH_DIR MAP ENTRY %token NAME DEFINED TARGET_K SEARCH_DIR MAP ENTRY
@ -144,16 +145,19 @@ struct sec *section;
%token OPTION_Map %token OPTION_Map
%token OPTION_n OPTION_r OPTION_o OPTION_b OPTION_R OPTION_relax %token OPTION_n OPTION_r OPTION_o OPTION_b OPTION_R OPTION_relax
%token <name> OPTION_l OPTION_L OPTION_T OPTION_Aarch OPTION_Tfile OPTION_Texp %token <name> OPTION_l OPTION_L OPTION_T OPTION_Aarch OPTION_Tfile OPTION_Texp
%token <name> OPTION_y
%token OPTION_Ur %token OPTION_Ur
%token ORIGIN FILL OPTION_g %token ORIGIN FILL OPTION_g
%token LENGTH CREATE_OBJECT_SYMBOLS INPUT OUTPUT CONSTRUCTORS %token LENGTH CREATE_OBJECT_SYMBOLS INPUT OUTPUT CONSTRUCTORS
%token OPTION_RETAIN_SYMBOLS_FILE ALIGNMOD
%type <token> assign_op %type <token> assign_op
%type <name> filename %type <name> filename
%token CHIP LIST SECT ABSOLUTE LOAD NEWLINE ENDWORD ORDER NAMEWORD %token CHIP LIST SECT ABSOLUTE LOAD NEWLINE ENDWORD ORDER NAMEWORD
%token FORMAT PUBLIC DEFSYMEND BASE ALIAS %token FORMAT PUBLIC DEFSYMEND BASE ALIAS TRUNCATE
%{ %{
ld_config_type config; ld_config_type config;
@ -278,7 +282,10 @@ command_line_option:
lang_section_start($1,exp_intop($3)); lang_section_start($1,exp_intop($3));
hex_mode = 0; hex_mode = 0;
} }
| OPTION_y
{
add_ysym($1);
}
| OPTION_Aarch | OPTION_Aarch
{ {
ldfile_add_arch($1); ldfile_add_arch($1);
@ -307,7 +314,7 @@ command_line_option:
| OPTION_T filename | OPTION_T filename
{ ldfile_open_command_file($2); } script_file { ldfile_open_command_file($2); } script_file
END { ldlex_command();} END { ldlex_command();}
| OPTION_l | OPTION_l
{ {
@ -326,6 +333,8 @@ END { ldlex_command();}
NAME '=' exp DEFSYMEND { ldlex_popstate(); NAME '=' exp DEFSYMEND { ldlex_popstate();
lang_add_assignment(exp_assop($4,$3,$5)); lang_add_assignment(exp_assop($4,$3,$5));
} }
| OPTION_RETAIN_SYMBOLS_FILE filename
{ lang_add_keepsyms_file ($2); }
| '-' NAME | '-' NAME
{ info("%P%F Unrecognized option -%s\n", $2); } { info("%P%F Unrecognized option -%s\n", $2); }
@ -375,6 +384,10 @@ mri_script_command:
{ mri_output_section($2, $3);} { mri_output_section($2, $3);}
| SECT NAME '=' exp | SECT NAME '=' exp
{ mri_output_section($2, $4);} { mri_output_section($2, $4);}
| ALIGN_K NAME '=' exp
{ mri_align($2,$4); }
| ALIGNMOD NAME '=' exp
{ mri_alignmod($2,$4); }
| ABSOLUTE mri_abs_name_list | ABSOLUTE mri_abs_name_list
| LOAD mri_load_name_list | LOAD mri_load_name_list
| NAMEWORD NAME | NAMEWORD NAME
@ -385,6 +398,8 @@ mri_script_command:
{ mri_alias($2,0,$4);} { mri_alias($2,0,$4);}
| BASE exp | BASE exp
{ mri_base($2); } { mri_base($2); }
| TRUNCATE INT
{ mri_truncate($2); }
| |
; ;
@ -449,6 +464,8 @@ ifile_p1:
| INPUT '(' input_list ')' | INPUT '(' input_list ')'
| MAP '(' filename ')' | MAP '(' filename ')'
{ lang_add_map($3); } { lang_add_map($3); }
| INCLUDE filename
{ ldfile_open_command_file($2); } ifile_list END
; ;
input_list: input_list:
@ -759,48 +776,35 @@ exp :
section: NAME { ldlex_expression(); } section: NAME { ldlex_expression(); }
opt_exp { ldlex_popstate(); } opt_exp_with_type { ldlex_popstate(); }
opt_type opt_block ':' opt_things'{' '{'
{ {
lang_enter_output_section_statement($1,$3,$5,$6); lang_enter_output_section_statement($1,$3,typebits,0,0,0);
} }
statement '}' {ldlex_expression();} fill_opt memspec_opt statement
'}' {ldlex_expression();} fill_opt memspec_opt
{ {
ldlex_popstate(); ldlex_popstate();
lang_leave_output_section_statement($14, $15); lang_leave_output_section_statement($10, $11);
} }
opt_comma opt_comma
; ;
opt_type: type:
NOLOAD { $$ = SEC_NEVER_LOAD; } NOLOAD { typebits = SEC_NEVER_LOAD; }
| DSECT { $$ = 0; } | DSECT { typebits = 0; }
| COPY { $$ = 0; } | COPY { typebits = 0; }
| INFO { $$ = 0; } | INFO { typebits = 0; }
| OVERLAY { $$ = 0; } | OVERLAY { typebits = 0; }
| { $$ = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS; } | { typebits = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS; }
; ;
opt_things:
{
};
opt_exp_with_type:
opt_exp: exp ':' { $$ = $1; typebits =0;}
exp | exp '(' type ')' ':' { $$ = $1; }
{ $$ = $1; } | ':' { $$= (etree_type *)NULL; typebits = 0}
| { $$= (etree_type *)NULL; }
;
opt_block:
BLOCK '(' exp ')'
{ $$ = exp_get_value_int($3,
1L,
"block",
lang_first_phase_enum);
}
| { $$ = 1; }
; ;
memspec_opt: memspec_opt:

View File

@ -51,6 +51,7 @@ static comment();
#define YY_FATAL_ERROR ; #define YY_FATAL_ERROR ;
#define MAX_INCLUDE_DEPTH 10 #define MAX_INCLUDE_DEPTH 10
YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
char *file_name_stack[MAX_INCLUDE_DEPTH];
unsigned int include_stack_ptr = 0; unsigned int include_stack_ptr = 0;
@ -278,7 +279,7 @@ NOCFILENAMECHAR [_a-zA-Z0-9\/\.\-\_\+\$\:\[\]\\\~]
<BOTH,SCRIPT>"SEARCH_DIR" { RTOKEN(SEARCH_DIR);} <BOTH,SCRIPT>"SEARCH_DIR" { RTOKEN(SEARCH_DIR);}
<BOTH,SCRIPT>"OUTPUT" { RTOKEN(OUTPUT);} <BOTH,SCRIPT>"OUTPUT" { RTOKEN(OUTPUT);}
<BOTH,SCRIPT>"INPUT" { RTOKEN(INPUT);} <BOTH,SCRIPT>"INPUT" { RTOKEN(INPUT);}
<BOTH,SCRIPT>"DEFINED" { RTOKEN(DEFINED);} <EXPRESSION,BOTH,SCRIPT>"DEFINED" { RTOKEN(DEFINED);}
<BOTH,SCRIPT>"CREATE_OBJECT_SYMBOLS" { RTOKEN(CREATE_OBJECT_SYMBOLS);} <BOTH,SCRIPT>"CREATE_OBJECT_SYMBOLS" { RTOKEN(CREATE_OBJECT_SYMBOLS);}
<BOTH,SCRIPT>"CONSTRUCTORS" { RTOKEN( CONSTRUCTORS);} <BOTH,SCRIPT>"CONSTRUCTORS" { RTOKEN( CONSTRUCTORS);}
<BOTH,SCRIPT>"FORCE_COMMON_ALLOCATION" { RTOKEN(FORCE_COMMON_ALLOCATION);} <BOTH,SCRIPT>"FORCE_COMMON_ALLOCATION" { RTOKEN(FORCE_COMMON_ALLOCATION);}
@ -294,7 +295,7 @@ NOCFILENAMECHAR [_a-zA-Z0-9\/\.\-\_\+\$\:\[\]\\\~]
<BOTH,SCRIPT>"SHORT" { RTOKEN( SHORT);} <BOTH,SCRIPT>"SHORT" { RTOKEN( SHORT);}
<BOTH,SCRIPT>"BYTE" { RTOKEN( BYTE);} <BOTH,SCRIPT>"BYTE" { RTOKEN( BYTE);}
<BOTH,SCRIPT>"NOFLOAT" { RTOKEN(NOFLOAT);} <BOTH,SCRIPT>"NOFLOAT" { RTOKEN(NOFLOAT);}
<BOTH,SCRIPT>"NOLOAD" { RTOKEN(NOLOAD);} <EXPRESSION,BOTH,SCRIPT>"NOLOAD" { RTOKEN(NOLOAD);}
<BOTH,SCRIPT>"DSECT" { RTOKEN(DSECT);} <BOTH,SCRIPT>"DSECT" { RTOKEN(DSECT);}
<BOTH,SCRIPT>"COPY" { RTOKEN(COPY);} <BOTH,SCRIPT>"COPY" { RTOKEN(COPY);}
<BOTH,SCRIPT>"INFO" { RTOKEN(INFO);} <BOTH,SCRIPT>"INFO" { RTOKEN(INFO);}
@ -303,6 +304,7 @@ NOCFILENAMECHAR [_a-zA-Z0-9\/\.\-\_\+\$\:\[\]\\\~]
<BOTH,SCRIPT>"org" { RTOKEN(ORIGIN);} <BOTH,SCRIPT>"org" { RTOKEN(ORIGIN);}
<BOTH,SCRIPT>"l" { RTOKEN( LENGTH);} <BOTH,SCRIPT>"l" { RTOKEN( LENGTH);}
<BOTH,SCRIPT>"len" { RTOKEN( LENGTH);} <BOTH,SCRIPT>"len" { RTOKEN( LENGTH);}
<BOTH,SCRIPT>"INCLUDE" { RTOKEN(INCLUDE);}
<MRI>"\n" { ++ lineno; RTOKEN(NEWLINE); } <MRI>"\n" { ++ lineno; RTOKEN(NEWLINE); }
<MRI>"*".* { /* Mri comment line */ } <MRI>"*".* { /* Mri comment line */ }
<MRI>"END" { RTOKEN(ENDWORD); } <MRI>"END" { RTOKEN(ENDWORD); }
@ -363,6 +365,7 @@ NOCFILENAMECHAR [_a-zA-Z0-9\/\.\-\_\+\$\:\[\]\\\~]
<MRI,COMMAND,BOTH,SCRIPT,EXPRESSION>[ \t] <MRI,COMMAND,BOTH,SCRIPT,EXPRESSION>[ \t]
<<EOF>> { <<EOF>> {
extern char *ldfile_input_filename;
include_stack_ptr--; include_stack_ptr--;
if (include_stack_ptr == 0) if (include_stack_ptr == 0)
@ -372,22 +375,35 @@ NOCFILENAMECHAR [_a-zA-Z0-9\/\.\-\_\+\$\:\[\]\\\~]
else else
{ {
yy_switch_to_buffer(include_stack[include_stack_ptr]); yy_switch_to_buffer(include_stack[include_stack_ptr]);
} }
if (include_stack_ptr==1)
{
BEGIN(COMMAND); BEGIN(COMMAND);
return END;
} }
else
{
ldfile_input_filename = file_name_stack[include_stack_ptr-1];
}
return END;
}
%% %%
void void
DEFUN(lex_push_file,(file), DEFUN(lex_push_file,(file,name),
FILE *file) FILE *file AND
char *name)
{ {
if (include_stack_ptr >= MAX_INCLUDE_DEPTH) if (include_stack_ptr >= MAX_INCLUDE_DEPTH)
{ {
einfo("%F:includes nested too deeply"); einfo("%F:includes nested too deeply");
} }
include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER; file_name_stack[include_stack_ptr] = name;
include_stack[include_stack_ptr] = YY_CURRENT_BUFFER;
include_stack_ptr++;
yyin = file; yyin = file;
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
@ -439,18 +455,19 @@ DEFUN(lex_redirect,( string),
YY_BUFFER_STATE tmp; YY_BUFFER_STATE tmp;
int len = strlen(string); int len = strlen(string);
yy_init = 0 ; yy_init = 0 ;
if (include_stack_ptr >= MAX_INCLUDE_DEPTH) if (include_stack_ptr >= MAX_INCLUDE_DEPTH)
{ {
einfo("%F: macros nested too deeply"); einfo("%F: macros nested too deeply");
} }
include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER; file_name_stack[include_stack_ptr] = "redirect";
include_stack[include_stack_ptr] = YY_CURRENT_BUFFER;
include_stack_ptr++;
tmp = yy_create_string_buffer(string, len); tmp = yy_create_string_buffer(string, len);
yy_switch_to_buffer(tmp); yy_switch_to_buffer(tmp);
BEGIN(COMMAND); BEGIN(COMMAND);
yyout = stdout; yyout = stdout;
} }
int state_stack[20]; int state_stack[20];
@ -459,50 +476,50 @@ int *state_stack_p = state_stack;
void void
DEFUN_VOID(ldlex_script) DEFUN_VOID(ldlex_script)
{ {
*(state_stack_p)++ = yy_start; *(state_stack_p)++ = yy_start;
BEGIN(SCRIPT); BEGIN(SCRIPT);
} }
void void
DEFUN_VOID(ldlex_mri_script) DEFUN_VOID(ldlex_mri_script)
{ {
*(state_stack_p)++ = yy_start; *(state_stack_p)++ = yy_start;
BEGIN(MRI); BEGIN(MRI);
} }
void void
DEFUN_VOID(ldlex_defsym) DEFUN_VOID(ldlex_defsym)
{ {
*(state_stack_p)++ = yy_start; *(state_stack_p)++ = yy_start;
BEGIN(DEFSYMEXP); BEGIN(DEFSYMEXP);
} }
void void
DEFUN_VOID(ldlex_expression) DEFUN_VOID(ldlex_expression)
{ {
*(state_stack_p)++ = yy_start; *(state_stack_p)++ = yy_start;
BEGIN(EXPRESSION); BEGIN(EXPRESSION);
} }
void void
DEFUN_VOID(ldlex_both) DEFUN_VOID(ldlex_both)
{ {
*(state_stack_p)++ = yy_start; *(state_stack_p)++ = yy_start;
BEGIN(BOTH); BEGIN(BOTH);
} }
void void
DEFUN_VOID(ldlex_command) DEFUN_VOID(ldlex_command)
{ {
*(state_stack_p)++ = yy_start; *(state_stack_p)++ = yy_start;
BEGIN(COMMAND); BEGIN(COMMAND);
} }
void void
DEFUN_VOID(ldlex_popstate) DEFUN_VOID(ldlex_popstate)
{ {
yy_start = *(--state_stack_p); yy_start = *(--state_stack_p);
} }
yy_input(buf, result, max_size) yy_input(buf, result, max_size)