From dadd414a8917bf3d2e813d7ff0706fa7aaa8958c Mon Sep 17 00:00:00 2001 From: Steve Chamberlain Date: Fri, 8 Jan 1993 22:42:42 +0000 Subject: 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. --- ld/ChangeLog | 18 +++++++++++++ ld/ldgram.y | 84 +++++++++++++++++++++++++++++++----------------------------- ld/ldlex.l | 83 +++++++++++++++++++++++++++++++++++------------------------ 3 files changed, 112 insertions(+), 73 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index c4e7168..8061e99 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -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) * m68kcoff.sc-sh: define _end as well as end, for consistency with diff --git a/ld/ldgram.y b/ld/ldgram.y index 12acc19..eb9000a 100644 --- a/ld/ldgram.y +++ b/ld/ldgram.y @@ -44,7 +44,7 @@ extern boolean trace_files; extern boolean write_map; extern boolean option_longmap; boolean hex_mode; - +static int typebits; strip_symbols_type strip_symbols=STRIP_NONE; discard_locals_type discard_locals=DISCARD_NONE; @@ -58,7 +58,7 @@ lang_output_section_statement_type *lang_output_section_statement_lookup(); #ifdef __STDC__ 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 @@ -103,8 +103,8 @@ struct sec *section; } -%type exp opt_exp mustbe_exp -%type fill_opt opt_block opt_type +%type exp opt_exp_with_type mustbe_exp +%type fill_opt %type memspec_opt %token INT %token NAME @@ -133,6 +133,7 @@ struct sec *section; %token '{' '}' %token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH %token SIZEOF_HEADERS +%token INCLUDE %token MEMORY DEFSYMEND %token NOLOAD DSECT COPY INFO OVERLAY %token NAME DEFINED TARGET_K SEARCH_DIR MAP ENTRY @@ -143,17 +144,20 @@ struct sec *section; %token OPTION_v OPTION_V OPTION_M OPTION_t STARTUP HLL SYSLIB FLOAT NOFLOAT %token OPTION_Map %token OPTION_n OPTION_r OPTION_o OPTION_b OPTION_R OPTION_relax -%token OPTION_l OPTION_L OPTION_T OPTION_Aarch OPTION_Tfile OPTION_Texp +%token OPTION_l OPTION_L OPTION_T OPTION_Aarch OPTION_Tfile OPTION_Texp +%token OPTION_y %token OPTION_Ur %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 assign_op %type filename %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; @@ -278,7 +282,10 @@ command_line_option: lang_section_start($1,exp_intop($3)); hex_mode = 0; } - + | OPTION_y + { + add_ysym($1); + } | OPTION_Aarch { ldfile_add_arch($1); @@ -307,7 +314,7 @@ command_line_option: | OPTION_T filename { ldfile_open_command_file($2); } script_file -END { ldlex_command();} + END { ldlex_command();} | OPTION_l { @@ -325,7 +332,9 @@ END { ldlex_command();} | OPTION_defsym { ldlex_defsym(); } NAME '=' exp DEFSYMEND { ldlex_popstate(); lang_add_assignment(exp_assop($4,$3,$5)); - } + } + | OPTION_RETAIN_SYMBOLS_FILE filename + { lang_add_keepsyms_file ($2); } | '-' NAME { info("%P%F Unrecognized option -%s\n", $2); } @@ -375,6 +384,10 @@ mri_script_command: { mri_output_section($2, $3);} | SECT NAME '=' exp { 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 | LOAD mri_load_name_list | NAMEWORD NAME @@ -385,6 +398,8 @@ mri_script_command: { mri_alias($2,0,$4);} | BASE exp { mri_base($2); } + | TRUNCATE INT + { mri_truncate($2); } | ; @@ -449,6 +464,8 @@ ifile_p1: | INPUT '(' input_list ')' | MAP '(' filename ')' { lang_add_map($3); } + | INCLUDE filename + { ldfile_open_command_file($2); } ifile_list END ; input_list: @@ -759,50 +776,37 @@ exp : section: NAME { ldlex_expression(); } - opt_exp { ldlex_popstate(); } - opt_type opt_block ':' opt_things'{' + opt_exp_with_type { ldlex_popstate(); } + '{' { - 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(); - lang_leave_output_section_statement($14, $15); + lang_leave_output_section_statement($10, $11); } opt_comma ; -opt_type: - NOLOAD { $$ = SEC_NEVER_LOAD; } - | DSECT { $$ = 0; } - | COPY { $$ = 0; } - | INFO { $$ = 0; } - | OVERLAY { $$ = 0; } - | { $$ = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS; } +type: + NOLOAD { typebits = SEC_NEVER_LOAD; } + | DSECT { typebits = 0; } + | COPY { typebits = 0; } + | INFO { typebits = 0; } + | OVERLAY { typebits = 0; } + | { typebits = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS; } ; -opt_things: - { - }; - -opt_exp: - exp - { $$ = $1; } - | { $$= (etree_type *)NULL; } +opt_exp_with_type: + exp ':' { $$ = $1; typebits =0;} + | exp '(' type ')' ':' { $$ = $1; } + | ':' { $$= (etree_type *)NULL; typebits = 0} ; -opt_block: - BLOCK '(' exp ')' - { $$ = exp_get_value_int($3, - 1L, - "block", - lang_first_phase_enum); - } - | { $$ = 1; } - ; - memspec_opt: '>' NAME { $$ = $2; } diff --git a/ld/ldlex.l b/ld/ldlex.l index 3a4158d..d43cf49 100644 --- a/ld/ldlex.l +++ b/ld/ldlex.l @@ -51,6 +51,7 @@ static comment(); #define YY_FATAL_ERROR ; #define MAX_INCLUDE_DEPTH 10 YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; +char *file_name_stack[MAX_INCLUDE_DEPTH]; unsigned int include_stack_ptr = 0; @@ -278,7 +279,7 @@ NOCFILENAMECHAR [_a-zA-Z0-9\/\.\-\_\+\$\:\[\]\\\~] "SEARCH_DIR" { RTOKEN(SEARCH_DIR);} "OUTPUT" { RTOKEN(OUTPUT);} "INPUT" { RTOKEN(INPUT);} -"DEFINED" { RTOKEN(DEFINED);} +"DEFINED" { RTOKEN(DEFINED);} "CREATE_OBJECT_SYMBOLS" { RTOKEN(CREATE_OBJECT_SYMBOLS);} "CONSTRUCTORS" { RTOKEN( CONSTRUCTORS);} "FORCE_COMMON_ALLOCATION" { RTOKEN(FORCE_COMMON_ALLOCATION);} @@ -294,7 +295,7 @@ NOCFILENAMECHAR [_a-zA-Z0-9\/\.\-\_\+\$\:\[\]\\\~] "SHORT" { RTOKEN( SHORT);} "BYTE" { RTOKEN( BYTE);} "NOFLOAT" { RTOKEN(NOFLOAT);} -"NOLOAD" { RTOKEN(NOLOAD);} +"NOLOAD" { RTOKEN(NOLOAD);} "DSECT" { RTOKEN(DSECT);} "COPY" { RTOKEN(COPY);} "INFO" { RTOKEN(INFO);} @@ -303,6 +304,7 @@ NOCFILENAMECHAR [_a-zA-Z0-9\/\.\-\_\+\$\:\[\]\\\~] "org" { RTOKEN(ORIGIN);} "l" { RTOKEN( LENGTH);} "len" { RTOKEN( LENGTH);} +"INCLUDE" { RTOKEN(INCLUDE);} "\n" { ++ lineno; RTOKEN(NEWLINE); } "*".* { /* Mri comment line */ } "END" { RTOKEN(ENDWORD); } @@ -363,31 +365,45 @@ NOCFILENAMECHAR [_a-zA-Z0-9\/\.\-\_\+\$\:\[\]\\\~] [ \t] <> { - include_stack_ptr--; + extern char *ldfile_input_filename; + include_stack_ptr--; - if (include_stack_ptr == 0) - { - yyterminate(); - } - else - { - yy_switch_to_buffer(include_stack[include_stack_ptr]); - } - BEGIN(COMMAND); - return END; + if (include_stack_ptr == 0) + { + yyterminate(); + } + else + { + yy_switch_to_buffer(include_stack[include_stack_ptr]); + + } + if (include_stack_ptr==1) + { + BEGIN(COMMAND); + } + else + { + ldfile_input_filename = file_name_stack[include_stack_ptr-1]; } + + return END; +} %% void -DEFUN(lex_push_file,(file), - FILE *file) +DEFUN(lex_push_file,(file,name), + FILE *file AND + char *name) { if (include_stack_ptr >= MAX_INCLUDE_DEPTH) { 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; yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); @@ -439,18 +455,19 @@ DEFUN(lex_redirect,( string), YY_BUFFER_STATE tmp; int len = strlen(string); -yy_init = 0 ; + yy_init = 0 ; if (include_stack_ptr >= MAX_INCLUDE_DEPTH) { 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); yy_switch_to_buffer(tmp); BEGIN(COMMAND); -yyout = stdout; + yyout = stdout; } int state_stack[20]; @@ -459,50 +476,50 @@ int *state_stack_p = state_stack; void DEFUN_VOID(ldlex_script) { -*(state_stack_p)++ = yy_start; + *(state_stack_p)++ = yy_start; -BEGIN(SCRIPT); + BEGIN(SCRIPT); } void DEFUN_VOID(ldlex_mri_script) { -*(state_stack_p)++ = yy_start; -BEGIN(MRI); + *(state_stack_p)++ = yy_start; + BEGIN(MRI); } void DEFUN_VOID(ldlex_defsym) { -*(state_stack_p)++ = yy_start; -BEGIN(DEFSYMEXP); + *(state_stack_p)++ = yy_start; + BEGIN(DEFSYMEXP); } void DEFUN_VOID(ldlex_expression) { -*(state_stack_p)++ = yy_start; -BEGIN(EXPRESSION); + *(state_stack_p)++ = yy_start; + BEGIN(EXPRESSION); } void DEFUN_VOID(ldlex_both) { -*(state_stack_p)++ = yy_start; -BEGIN(BOTH); + *(state_stack_p)++ = yy_start; + BEGIN(BOTH); } void DEFUN_VOID(ldlex_command) { -*(state_stack_p)++ = yy_start; -BEGIN(COMMAND); + *(state_stack_p)++ = yy_start; + BEGIN(COMMAND); } void DEFUN_VOID(ldlex_popstate) { -yy_start = *(--state_stack_p); + yy_start = *(--state_stack_p); } yy_input(buf, result, max_size) -- cgit v1.1